GetPlayerAmmoInClip: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 18: | Line 18: | ||
==Example== | ==Example== | ||
This example outputs the amount of ammo | This example outputs the amount of ammo the specified player has in his current slot. For example: 'ammo someguy'. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function showAmmo( player, command, who ) | |||
thePlayer = getPlayerFromNick(who) | |||
if (thePlayer ~= false) then | |||
if ( | local ammo = getPlayerAmmoInClip(thePlayer) | ||
outputChatBox(who.." has "..ammo.." in his active clip", player) | |||
else | |||
outputChatBox("Player '"..who.."' not found.", player) | |||
outputChatBox ( " | end | ||
end | end | ||
addCommandHandler( "ammo", showAmmo ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Player functions}} | {{Player functions}} |
Revision as of 21:45, 29 July 2007
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)
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
- getPlayerTeam
- getPlayerBlurLevel
- setPlayerBlurLevel
- getPlayerSerial
- forcePlayerMap
- getPlayerScriptDebugLevel
- getPlayerFromName
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
- getPlayerWantedLevel
- givePlayerMoney
- isPlayerMapForced
- isPlayerNametagShowing
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
- takePlayerMoney
- countPlayersInTeam
- getPlayersInTeam
- isVoiceEnabled
- setControlState
- getControlState