GetPlayerAmmoInClip: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{Server client function}} | |||
{{Needs_Checking|Should return ''false'' instead of 0 if player's invalid, for consistency}} | {{Needs_Checking|Should return ''false'' instead of 0 if player's invalid, for consistency}} | ||
__NOTOC__ | __NOTOC__ | ||
Line 4: | Line 5: | ||
==Syntax== | ==Syntax== | ||
<section name="Server" class="server" show="true"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
int getPlayerAmmoInClip ( player thePlayer | int getPlayerAmmoInClip ( player thePlayer ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''thePlayer''': The [[player]] whose ammo you want to check. | *'''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. | |||
</section> | |||
<section name="Client" class="client" show="true"> | |||
<syntaxhighlight lang="lua"> | |||
int getPlayerAmmoInClip ( player thePlayer [, int weaponSlot = current ] ) | |||
</syntaxhighlight> | |||
===Required Arguments=== | |||
*'''thePlayer:''' The [[player]] whose ammo you want to check. | |||
===Optional Arguments=== | ===Optional Arguments=== | ||
*'''weaponSlot''' | *'''weaponSlot:''' an integer representing the weapon slot (set to the player's currently selected slot if not specified). | ||
===Returns=== | ===Returns=== | ||
Returns an [[int]] containing the | 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. | ||
</section> | |||
==Example== | ==Example== | ||
This example outputs the amount of ammo the specified player has in his current slot. For example: 'ammo someguy'. | 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( | function showAmmo( thePlayer, command, who ) | ||
local targetPlayer = getPlayerFromNick ( who ) | |||
if (thePlayer | if ( thePlayer ) then | ||
local ammo = getPlayerAmmoInClip( | local ammo = getPlayerAmmoInClip ( targetPlayer ) | ||
outputChatBox(who.." has "..ammo.." in his active clip", | outputChatBox(who .. " has "..ammo .. " in his active clip", thePlayer) | ||
else | else | ||
outputChatBox("Player '"..who.."' not found.", | outputChatBox("Player '" .. who .. "' not found.", thePlayer) | ||
end | end | ||
end | end |
Revision as of 15:13, 19 August 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
Click to collapse [-]
Serverint 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 [-]
Clientint 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 player's currently selected slot if not specified).
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
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 .. " in his active clip", thePlayer) else outputChatBox("Player '" .. who .. "' not found.", thePlayer) 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