Jump to content

Problem with getting Weapon Ammunition


Recommended Posts

Posted

I am currently working on a roleplay gamemode which uses a database for datastorage and I stumbled upon a problem while trying to save the players weapons and ammunition. I know there have already been threads discussing the topic of saving ammunition but every solution returned 0 for me.

I have tried:
player.getWeaponAmmo(weaponHash) [Server-Side]
mp.game.invoke("0x015A522136D7F951", mp.players.local.handle, weaponHash); [Client-Side]

 

Both of these have returned 0 for me, also by using different Weapons (Pistol, Carbine-Rifle). I hope that someone has a solution to this problem or could fix the player.getWeaponAmmo(weaponHash) command.
Regards,
Miep3r

Posted (edited)

Are you passing the weaponHash or the weaponName? Because if in your code weaponHash equals to the name of the weapon, than it would not work.

Try this way with a pistol:

let pistolAmmo = mp.game.invoke("0x015A522136D7F951", mp.players.local.handle, mp.joaat('weapon_pistol'));

Basicaly mp.joaat() convert an entity name to hash, exactly what the function expects. Good luck!

Edited by Pilatus
Posted

Thanks for the quick answer,

That is exactly the way I did it but it just doesn't seem to work. I even set the weaponHash to something static like mp.game.joaat("weapon_carbinerifle"), still didn't work.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...