SetPlayerArmor: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(8 intermediate revisions by 5 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Deprecated|setPedArmor}}
This function allows you to set the armor value of a [[player]].
This function allows you to set the armor value of a [[player]].


Line 13: Line 15:


==Example==
==Example==
This example removes the armor of a player called someguy and tells them that it has.
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
This example removes the armor of a player.
-- Find a player called 'someguy'
<syntaxhighlight lang="lua">function givePlayerArmor ( player, command )
someguy = findPlayer ( "someguy" )
setPlayerArmor ( player, 100 ) --Set player's armor to 100 when he types the command 'addarmor'
-- If the player was found then
end
if ( someguy ) then
addCommandHandler ( "addarmor", givePlayerArmor )
-- Set the player's armor to 0
 
if ( setPlayerArmor ( someguy, 0 ) ) then
function removePlayerArmor ( player, command )
-- Tell the player you've removed their armor
setPlayerArmor ( player, 0 ) --Set player's armor to 0 when he types the command 'removearmor'
outputChatBox ( "Sorry someguy, no armor for you!", someguy )
end
end
end
</syntaxhighlight>
addCommandHandler ( "removearmor", removePlayerArmor )</syntaxhighlight> </section>


==See Also==
==See Also==
{{Player functions}}
{{Player functions}}
{{Server function}}

Latest revision as of 22:00, 5 July 2014


Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions.

Please use setPedArmor instead.


This function allows you to set the armor value of a player.

Syntax

bool setPlayerArmor ( player thePlayer, float playerArmor )

Required Arguments

  • thePlayer: the player whose armor you want to modify.
  • playerArmor: the amount of armor you want to set on the player. Valid values are from 0 to 100.

Returns

Returns true if the armor was changed succesfully. Returns false if an invalid player is specified, or the armor value specified is out of acceptable range.

Example

Click to collapse [-]
Server

This example removes the armor of a player.

function givePlayerArmor ( player, command )
	setPlayerArmor ( player, 100 ) --Set player's armor to 100 when he types the command 'addarmor'
end
addCommandHandler ( "addarmor", givePlayerArmor )

function removePlayerArmor ( player, command )
	setPlayerArmor ( player, 0 ) --Set player's armor to 0 when he types the command 'removearmor'
end
addCommandHandler ( "removearmor", removePlayerArmor )

See Also