Weapon::getWeaponClipSize: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
No edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
// Returns the size of the default weapon component clip.<br><br>Use it like this:<br><br>char cClipSize[32];<br>Hash cur;<br>if (WEAPON::GET_CURRENT_PED_WEAPON(playerPed, &amp;cur, 1))<br>{<br>    if (WEAPON::IS_WEAPON_VALID(cur))<br>    {<br>        int iClipSize = WEAPON::GET_WEAPON_CLIP_SIZE(cur);<br>        sprintf_s(cClipSize, 'ClipSize: %.d', iClipSize);<br>        vDrawString(cClipSize, 0.5f, 0.5f);<br>    }<br>}<br>
{{ClientsideJsFunction}}
==Syntax==
{{JSContainer|
<syntaxhighlight lang="javascript">mp.game.weapon.getWeaponClipSize(weaponHash);</syntaxhighlight>
Returns the clip size of given weapon hash.
=== Required Arguments ===
===Required Params===
*'''weaponHash:''' Model hash or name
*'''weaponHash''' {{RageType|Number}} [[https://wiki.rage.mp/index.php?title=Weapons Weapon List]]
===Return value===
 
*'''int'''
===Return Value===
*''' {{RageType|Number}} '''
 
===Syntax===
<pre>
mp.game.weapon.getWeaponClipSize(weaponHash);
</pre>
 
==Example==
==Example==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// todo
const { weapon } = mp.players.local; //get the weapon from local players
if (weapon !== mp.game.joaat("weapon_unarmed")) {
const clipSize = mp.game.weapon.getWeaponClipSize(weapon);
mp.console.logInfo(`Current player weapon clip size is ${clipSize}`);
}
</syntaxhighlight>
</syntaxhighlight>
}}
==See also==
==See also==
{{Weapon_s_function_c}}
{{Weapon_s_function_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]

Latest revision as of 11:15, 28 April 2024

Client-Side
Function

 JavaScript



JavaScript Syntax

Returns the clip size of given weapon hash.

Required Params

Return Value

  • Number

Syntax

mp.game.weapon.getWeaponClipSize(weaponHash);

Example

const { weapon } = mp.players.local; //get the weapon from local players
if (weapon !== mp.game.joaat("weapon_unarmed")) {
	const clipSize = mp.game.weapon.getWeaponClipSize(weapon);
	mp.console.logInfo(`Current player weapon clip size is ${clipSize}`);
}



See also