GetPlayerWeapon: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(Fixed example, added example section, minor changes) |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | {{Server client function}} | ||
This function tells you which weapon type is in | 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|Weapon Info]] | ||
==Syntax== | ==Syntax== | ||
Line 13: | Line 13: | ||
===Returns=== | ===Returns=== | ||
Returns an [[int]] indicating the type of the weapon the player has currently equipped. </section> | Returns an [[int]] indicating the type of the weapon the player has currently equipped. | ||
</section> | |||
<section name="Client" class="client"> | <section name="Client" class="client"> | ||
Line 29: | 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'''.</section> | 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'''. | ||
</section> | |||
==Example== | ==Example== | ||
This example will display a player's current weapon type. In this case, it is hard coded to use the player called ''someguy''. | <section name="Example" class="server" show="true"> | ||
This serverside example will display a player's current weapon type. In this case, it is hard coded to use the player called ''someguy''. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- Find a player called someguy and find his current weapon id. | -- Find a player called someguy and find his current weapon id. | ||
weaponType = getPlayerWeapon ( | local weaponType = getPlayerWeapon ( getPlayerFromNick ( "someguy" ) ) | ||
-- If a weapon type was returned then | -- If a weapon type was returned then | ||
if ( weaponType ) then | if ( weaponType ) then | ||
outputChatBox ( " | outputChatBox ( "someguy's current Weapon-type: " .. weaponType .. "." ) -- Display the weapon type in the chat box | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{Player functions}} | {{Player functions}} |
Revision as of 11:41, 13 August 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
Click to expand [+]
ServerClick to expand [+]
ClientExample
Click to collapse [-]
ExampleThis 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