Jump to content

Get Weapons and Ammo


Thesicstar

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.

 

Link to comment
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

 

  • Like 1
Link to comment
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!

Link to comment
Share on other sites

  • 3 weeks later...

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


    

 

 

Link to comment
Share on other sites

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