GetPlayerAmmoInClip

From Multi Theft Auto: Wiki
Revision as of 21:59, 29 July 2007 by Talidan (talk | contribs)
Jump to navigation Jump to search
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 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). Please note this argument is only relevant when using the function clientside.

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 the specified player has in his current slot. For example: 'ammo someguy'.

function showAmmo( player, command, who )
	thePlayer = getPlayerFromNick(who)
	if (thePlayer ~= false) then
		local ammo = getPlayerAmmoInClip(thePlayer)
		outputChatBox(who.." has "..ammo.." in his active clip", player)
	else
		outputChatBox("Player '"..who.."' not found.", player)
	end
end
addCommandHandler( "ammo", showAmmo )

See Also

Shared