Problem with getting Weapon Ammunition

Recommended Posts

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.

Share this post

Link to post
Share on other sites
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

Share this post

Link to post
Share on other sites

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.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.