Weapon::getWeaponClipSize: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
No edit summary
Line 8: Line 8:
==Example==
==Example==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// todo
mp.keys.bind(0x76, false, function () { // F7 key
    let weaponHash = mp.game.invoke(`0x0A6DB4965674D243`, mp.players.local.handle); //GET_SELECTED_PED_WEAPON
    let clipSize = mp.game.weapon.getWeaponClipSize(weaponHash);
    mp.gui.chat.push(`hash: ${weaponHash}, clipSize: ${clipSize}`);
})
</syntaxhighlight>
</syntaxhighlight>
==See also==
==See also==
{{Weapon_s_function_c}}
{{Weapon_s_function_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]

Revision as of 04:24, 31 July 2018

// Returns the size of the default weapon component clip.

Use it like this:

char cClipSize[32];
Hash cur;
if (WEAPON::GET_CURRENT_PED_WEAPON(playerPed, &cur, 1))
{
if (WEAPON::IS_WEAPON_VALID(cur))
{
int iClipSize = WEAPON::GET_WEAPON_CLIP_SIZE(cur);
sprintf_s(cClipSize, 'ClipSize: %.d', iClipSize);
vDrawString(cClipSize, 0.5f, 0.5f);
}
}

Syntax

mp.game.weapon.getWeaponClipSize(weaponHash);

Required Arguments

  • weaponHash: Model hash or name

Return value

  • int

Example

mp.keys.bind(0x76, false, function () { // F7 key
    let weaponHash = mp.game.invoke(`0x0A6DB4965674D243`, mp.players.local.handle); //GET_SELECTED_PED_WEAPON
    let clipSize = mp.game.weapon.getWeaponClipSize(weaponHash);
    mp.gui.chat.push(`hash: ${weaponHash}, clipSize: ${clipSize}`);
})

See also