GetPlayerAmmoInClip: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 18: Line 18:
<section name="Client" class="client" show="true">
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int getPlayerAmmoInClip ( player thePlayer , int weaponSlot )
int getPlayerAmmoInClip ( player thePlayer, int weaponSlot )
</syntaxhighlight>
</syntaxhighlight>



Revision as of 01:37, 20 April 2008

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

Syntax

Click to collapse [-]
Server
int getPlayerAmmoInClip ( player thePlayer )

Required Arguments

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

Returns

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

Click to collapse [-]
Client
int getPlayerAmmoInClip ( player thePlayer, int weaponSlot )

Required Arguments

  • thePlayer: The player whose ammo you want to check.
  • weaponSlot: an integer representing the weapon slot.

Returns

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

Example

Click to collapse [-]
Server

This example outputs the amount of ammo the specified player has in his current slot. For example: 'ammo someguy'.

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

See Also