GetWeaponClipAmmo: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
(The code is client-side only, so outputChatBox haven't visibleTo argument.)
Line 19: Line 19:
   local weapon = getPedWeapon(player) -- Create a local variable with the value of getPedWeapon ( the weapon of the player )!
   local weapon = getPedWeapon(player) -- Create a local variable with the value of getPedWeapon ( the weapon of the player )!
   local clipAmmo = getWeaponClipAmmo(weapon) -- Now use the local variable and get the weapon's clip ammo!
   local clipAmmo = getWeaponClipAmmo(weapon) -- Now use the local variable and get the weapon's clip ammo!
   outputChatBox(tostring(clipAmmo), player) -- Output the clipAmmo to the player, Please use tostring for it or it will give you a error that it should be a string!
   outputChatBox(tostring(clipAmmo)) -- Output the clipAmmo to the player, Please use tostring for it or it will give you a error that it should be a string!
end -- End the function
end -- End the function
</syntaxhighlight>
</syntaxhighlight>

Revision as of 03:39, 15 October 2014

This function gets the amount of ammo in a custom weapons magazine/clip.

Syntax

int getWeaponClipAmmo ( weapon theWeapon )

Required Arguments

  • theWeapon: the weapon to get the clip ammo of.

Returns

Returns the amount of ammo in the custom weapons clip, false otherwise.

Example

This example gets your ammo and output it!

[lua]
function getMyAmmo(player) -- Create a function named getMyAmmo and add player as the first parameter of addCommandHandler!
   local weapon = getPedWeapon(player) -- Create a local variable with the value of getPedWeapon ( the weapon of the player )!
   local clipAmmo = getWeaponClipAmmo(weapon) -- Now use the local variable and get the weapon's clip ammo!
   outputChatBox(tostring(clipAmmo)) -- Output the clipAmmo to the player, Please use tostring for it or it will give you a error that it should be a string!
end -- End the function

See Also