GetPedAmmoInClip: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server client function}}
{{Server client function}}
{{New feature|4|1.0.4|
This function is added server-side in 1.0.4. This means this function will only be available client-side for non-1.0.4 servers.
}}
This function returns an integer that contains the ammo in a specified [[ped]]'s weapon. See [[weapon|Weapon Info]]
This function returns an integer that contains the ammo in a specified [[ped]]'s weapon. See [[weapon|Weapon Info]]



Revision as of 21:07, 11 June 2010

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

Syntax

int getPedAmmoInClip ( ped thePed [, int weaponSlot = current ] )

Required Arguments

  • thePed: The ped whose ammo you want to check.

Optional Arguments

  • weaponSlot: an integer representing the weapon slot (set to the ped's currently selected slot if not specified).

Returns

Returns an int containing the amount of ammo in the specified ped's currently selected or specified clip, or 0 if the ped 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( command, who )
	local targetPlayer = getPlayerFromNick ( who )
	if ( thePlayer ) then
		local ammo = getPedAmmoInClip ( targetPlayer )
		outputChatBox ( who .. " has " .. ammo .. " ammo in his active clip" )
	else
		outputChatBox ( "Player '" .. who .. "' not found." )
	end
end
addCommandHandler( "ammo", showAmmo )

See Also