GetPlayerWeapon: Difference between revisions
(Fixed example, added example section, minor changes) |
No edit summary |
||
Line 4: | Line 4: | ||
==Syntax== | ==Syntax== | ||
<section name="Server" class="server"> | <section name="Server" class="server" show="true"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
int getPlayerWeapon ( player thePlayer ) | int getPlayerWeapon ( player thePlayer ) | ||
Line 16: | Line 16: | ||
</section> | </section> | ||
<section name="Client" class="client"> | <section name="Client" class="client" show="true"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
int getPlayerWeapon ( player thePlayer, [ int weaponSlot = current ] ) | int getPlayerWeapon ( player thePlayer, [ int weaponSlot = current ] ) | ||
Line 30: | Line 30: | ||
Returns an [[int]] indicating the type of the weapon the player has in the specified slot. | Returns an [[int]] indicating the type of the weapon the player has in the specified slot. | ||
It should be noted that if a player runs out of ammo for a weapon, it will still return the ID of that weapon in the slot (even if it appears as if the player does not have a weapon at all), though [[getPlayerTotalAmmo]] will return '''0'''. | It should be noted that if a player runs out of ammo for a weapon, it will still return the ID of that weapon in the slot (even if it appears as if the player does not have a weapon at all), though [[getPlayerTotalAmmo]] will return '''0'''. Therefore, [[getPlayerTotalAmmo]] should be used in conjunction with [[getPlayerWeapon]] in order to check if a player has a weapon. | ||
</section> | </section> | ||
Revision as of 20:20, 29 November 2007
This function tells you which weapon type is in the player's current slot (clientside, you can optionally specify a slot other than the current one). See Weapon Info
Syntax
int getPlayerWeapon ( player thePlayer )
Required Arguments
- thePlayer: the player you want to get the weapon type from.
Returns
Returns an int indicating the type of the weapon the player has currently equipped.
int getPlayerWeapon ( player thePlayer, [ int weaponSlot = current ] )
Required Arguments
- thePlayer: the player you want to get the weapon type from.
Optional Arguments
- weaponSlot: an integer representing the weapon slot (set to the players current slot if not given).
Returns
Returns an int indicating the type of the weapon the player has in the specified slot.
It should be noted that if a player runs out of ammo for a weapon, it will still return the ID of that weapon in the slot (even if it appears as if the player does not have a weapon at all), though getPlayerTotalAmmo will return 0. Therefore, getPlayerTotalAmmo should be used in conjunction with getPlayerWeapon in order to check if a player has a weapon.
Example
This serverside example will display a player's current weapon type. In this case, it is hard coded to use the player called someguy.
-- Find a player called someguy and find his current weapon id. local weaponType = getPlayerWeapon ( getPlayerFromNick ( "someguy" ) ) -- If a weapon type was returned then if ( weaponType ) then outputChatBox ( "someguy's current Weapon-type: " .. weaponType .. "." ) -- Display the weapon type in the chat box end
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