GetPlayerAmmoInClip: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
This function returns an integer that contains the current ammo in a specified [[player]]'s current weapon.
This function returns an integer that contains the ammo in a specified [[player]]'s weapon. See [[weapon|Weapon Info]]


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int getPlayerAmmoInClip ( player thePlayer )
int getPlayerAmmoInClip ( player thePlayer, [ int weaponSlot = current ] )
</syntaxhighlight>
</syntaxhighlight>


===Required Arguments===
===Required Arguments===
*'''thePlayer''': The [[player]] whose ammo you want to check.
*'''thePlayer''': The [[player]] whose ammo you want to check.
===Optional Arguments===
*'''weaponSlot''': an integer representing the weapon slot (set to the players current slot if not given)


===Returns===
===Returns===
Line 14: Line 17:


==Example==
==Example==
This example outputs the ammount of ammo a player called ''Someguy'' has in his weapon's clip.
This example outputs the amount of ammo a player called ''Someguy'' has in his current weapon's clip.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- Find the player called 'Someguy'
-- Find the player called 'Someguy'

Revision as of 18:27, 13 December 2006

This function returns an integer that contains the ammo in a specified player's weapon. See Weapon Info

Syntax

int getPlayerAmmoInClip ( player thePlayer, [ int weaponSlot = current ] )

Required Arguments

  • thePlayer: The player whose ammo you want to check.

Optional Arguments

  • weaponSlot: an integer representing the weapon slot (set to the players current slot if not given)

Returns

Returns an int containing the ammount of ammo in the specified player's clip, or 0 if the player specified is invalid.

Example

This example outputs the amount of ammo a player called Someguy has in his current weapon's clip.

-- Find the player called 'Someguy'
myPlayer = findPlayer ( "Someguy" )
-- If a player called 'Someguy' was found then
if ( myPlayer ~= false )
	-- Retrieve the ammount of ammo in the clip for that player, and store it in a variable called 'ammo'
	ammo = getPlayerAmmoInClip ( myPlayer )
	-- Tell all the players how much ammo 'Someguy' has
	outputChatBox ( "Someguy's current ammo-in-clip: ", ammo, "." )
end

See Also