GetPlayerTotalAmmo: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
{{Needs_Checking|Should return ''false'' instead of 0 if player's invalid, for consistency}}
{{Needs_Checking|Should return ''false'' instead of 0 if player's invalid, for consistency}}
__NOTOC__
__NOTOC__
{{Server client function}}
This function returns an integer that contains the total ammo in a specified [[player]]'s weapon. See [[weapon|Weapon Info]]
This function returns an integer that contains the total ammo in a specified [[player]]'s weapon. See [[weapon|Weapon Info]]


==Syntax==
==Syntax==
<section name="Server" class="server">
<syntaxhighlight lang="lua">
int getPlayerTotalAmmo ( player thePlayer )
</syntaxhighlight>
===Required Arguments===
*'''thePlayer''': The [[player]] whose ammo you want to check.
===Returns===
Returns an [[int]] containing the total amount of ammo for the player's current weapon.
</section>
<section name="Client" class="client">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int getPlayerTotalAmmo ( player thePlayer, [ int weaponSlot = current ] )
int getPlayerTotalAmmo ( player thePlayer, [ int weaponSlot = current ] )
Line 13: Line 26:
===Optional Arguments===
===Optional Arguments===
*'''weaponSlot''': an integer representing the weapon slot (set to the players current slot if not given)
*'''weaponSlot''': an integer representing the weapon slot (set to the players current slot if not given)


===Returns===
===Returns===
Returns an [[int]] containing the total amount of ammo for the specified player's weapon, or 0 if the player specified is invalid.
Returns an [[int]] containing the total amount of ammo for the specified player's weapon, or 0 if the player specified is invalid.</section>


==Example==
==Example==

Revision as of 16:35, 3 August 2007

Dialog-information.png This article needs checking.

Reason(s): Should return false instead of 0 if player's invalid, for consistency

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

Syntax

Click to expand [+]
Server
Click to expand [+]
Client

Example

This example outputs the total amount of ammo a player called Someguy has for his weapon.

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

See Also