GetPedTotalAmmo: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Informed users of the bugs in this function)
mNo edit summary
Line 16: Line 16:
===Returns===
===Returns===
Returns an [[int]] containing the total amount of ammo for the specified ped's weapon, or 0 if the ped specified is invalid.
Returns an [[int]] containing the total amount of ammo for the specified ped's weapon, or 0 if the ped specified is invalid.
===Issues===
*'''#6253''': Weapons in slot 8 can return 1 instead of 0 when ammo is depleted.
*'''#6639''': Flame thrower ammo will be returned ten times higher than what they're given.


==Example==
==Example==
Line 34: Line 30:
end
end
</syntaxhighlight>
</syntaxhighlight>
==Issues==
{{Issues|
{{Issue|6253|Weapons in slot 8 can return 1 instead of 0 when ammo is depleted.}}
{{Issue|6639|Flame thrower ammo will be returned ten times higher than what they're given.}}
}}


==See Also==
==See Also==
{{Client_ped_functions}}
{{Client_ped_functions}}

Revision as of 11:21, 27 June 2012

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

Syntax

int getPedTotalAmmo ( 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 current slot if not given)

Returns

Returns an int containing the total amount of ammo for the specified ped's weapon, or 0 if the ped specified is invalid.

Example

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

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

Issues

Issue ID Description
#6253 Weapons in slot 8 can return 1 instead of 0 when ammo is depleted.
#6639 Flame thrower ammo will be returned ten times higher than what they're given.

See Also