GetPlayerWeapon: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server client function}}
This function tells you which weapon type is in a player's weapon slot. See [[weapon|Weapon Info]]
This function tells you which weapon type is in a player's weapon slot. See [[weapon|Weapon Info]]


==Syntax==
==Syntax==
<section name="Server" class="server">
<syntaxhighlight lang="lua">
int getPlayerWeapon ( player thePlayer )
</syntaxhighlight>
===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. </section>
<section name="Client" class="client">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int getPlayerWeapon ( player thePlayer, [ int weaponSlot = current ] )
int getPlayerWeapon ( player thePlayer, [ int weaponSlot = current ] )
Line 16: Line 29:
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'''.</section>


==Example==
==Example==

Revision as of 16:29, 3 August 2007

This function tells you which weapon type is in a player's weapon slot. See Weapon Info

Syntax

Click to expand [+]
Server
Click to expand [+]
Client

Example

This 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.
weaponType = getPlayerWeapon ( findPlayer ( "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