GetPlayerArmor: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
{{Server client function}}
__NOTOC__
__NOTOC__
This function returns a float that contains the current armor for the specified [[player]].
This function returns a float that contains the current armor for the specified [[player]].


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">float getPlayerArmor ( player player )</syntaxhighlight>
<syntaxhighlight lang="lua">float getPlayerArmor ( player thePlayer )</syntaxhighlight>


===Required Arguments===
===Required Arguments===
*'''player''': The [[player]] whose armor you want to check
*'''thePlayer:''' The [[player]] whose armor you want to check


==Returns==
===Returns===
A ''float'' with the armor, ''false'' if a invalid player was given.
A ''float'' with the armor, ''false'' if an invalid player was given.


==Example==
==Example==
This example outputs the amount of armor the player who calls the function 'showArmor' currently has.
This example defines a "showarmor" console command that shows the player that executes it how much armor he has.
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function showArmor( player )
function showArmor ( )
local armor = getPlayerArmor(player)
local me = getLocalPlayer ( )
outputChatBox("Your armor: "..armor)
local armor = getPlayerArmor ( me )
outputChatBox( "Your armor: " .. armor, me )
end
end
addCommandHandler("showArmor", showArmor)
addCommandHandler ( "showarmor", showArmor )
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Player functions}}
{{Player functions}}

Revision as of 15:53, 19 August 2007

This function returns a float that contains the current armor for the specified player.

Syntax

float getPlayerArmor ( player thePlayer )

Required Arguments

  • thePlayer: The player whose armor you want to check

Returns

A float with the armor, false if an invalid player was given.

Example

This example defines a "showarmor" console command that shows the player that executes it how much armor he has.

Click to collapse [-]
Client
function showArmor ( )
	local me = getLocalPlayer ( )
	local armor = getPlayerArmor ( me )
	outputChatBox( "Your armor: " .. armor, me )
end
addCommandHandler ( "showarmor", showArmor )

See Also