Sign in to follow this  
Thesicstar

Get Weapons and Ammo

Recommended Posts

Hey Guys, i'm pretty new to RageMP scripting so it may just be me beeing dumb but:

I'm trying to get all weapons with the corresponding ammo the player has equipped (client-side), but i simply just can't figure out how. I have read the wiki and searched the forums but there doesn't seem to be a solution. What i've tried so far:

  • Player::weapon
  • Player::weaponAmmo
  • Player::weapons
  • Weapons::all

None of them seem to work, either returning 0 or "undefined". Also most of these aren't documented on the wiki, so i might just be using them wrong.

I hope you guys can tell me what i'm doing wrong.

 

Share this post


Link to post
Share on other sites
Am 1.4.2019 um 17:24 schrieb Thesicstar:

Hey Guys, i'm pretty new to RageMP scripting so it may just be me beeing dumb but:

I'm trying to get all weapons with the corresponding ammo the player has equipped (client-side), but i simply just can't figure out how. I have read the wiki and searched the forums but there doesn't seem to be a solution. What i've tried so far:

  • Player::weapon
  • Player::weaponAmmo
  • Player::weapons
  • Weapons::all

None of them seem to work, either returning 0 or "undefined". Also most of these aren't documented on the wiki, so i might just be using them wrong.

I hope you guys can tell me what i'm doing wrong.

 

You mind posting a snippet on how you used this in your code?

Here's a short example:

var weapon_hash = mp.players.local.weapon; // returns weapon as a hash => uint
let ammoClip = mp.players.local.getAmmoInClip(weapon_hash); // returns ur ammo in clip
let ammoWeapon  = mp.players.local.getWeaponAmmo(weapon_hash); // returns ur wep ammo

 

Share this post


Link to post
Share on other sites
Am 3.4.2019 um 23:00 schrieb Division:

let ammoWeapon = mp.players.local.getWeaponAmmo(weapon_hash); // returns ur wep ammo

Ah! Thanks for the explanation, i thought this returns the ammo of the current equipped weapon so i just used it like

mp.players.local.getWeaponAmmo();

 

So it was just my lack of API knowledge. Thanks a lot for the explanation!

Share this post


Link to post
Share on other sites

Seems not to work to get current ammo in players weapon clip. alsways returns a strange value above 20.000:

    var weapon_hash = localPlayer.weapon;
    var ammoInClip = mp.game.invoke("0x2E1202248937775C", localPlayer.handle, weapon_hash, false); // returns bullshit


    

 

 

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.

Guest
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.

Sign in to follow this