SetPedArmor: Difference between revisions
Jump to navigation
Jump to search
(New page: __NOTOC__ This function allows you to set the armor value of a ped. ==Syntax== <syntaxhighlight lang="lua">bool setPedArmor ( ped thePed, float armor )</syntaxhighlight> ===Required Arguments=== *'''thePed'''...) |
Fernando187 (talk | contribs) (Remove obsolete Requirements section) |
||
(22 intermediate revisions by 14 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Shared function}} | |||
This function allows you to set the armor value of a [[ped]]. | This function allows you to set the armor value of a [[ped]]. | ||
{{New feature/item|3.0158|1.5.7|19626|Function also added client-side.}} | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">bool setPedArmor ( ped thePed, float armor )</syntaxhighlight> | <syntaxhighlight lang="lua"> | ||
bool setPedArmor ( ped thePed, float armor ) | |||
</syntaxhighlight> | |||
[[File:Armor.png|thumb|Armor bar on the hud]] | |||
{{OOP||[[ped]]:setArmor|armor|getPedArmor}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 14: | Line 20: | ||
==Example== | ==Example== | ||
This example removes the armor of a player. | This example removes the armor of a player. | ||
<syntaxhighlight lang="lua">function | <syntaxhighlight lang="lua"> | ||
function armor (player, command) | |||
if command == "addarmor" then | |||
setPedArmor ( player, 100 ) -- Set player's armor to 100 when he types the command 'addarmor' | |||
elseif command == "removearmor" then | |||
setPedArmor ( player, 0 ) -- Set player's armor to 0 when he types the command 'removearmor' | |||
end | |||
end | end | ||
addCommandHandler ( "addarmor", givePlayerArmor ) | addCommandHandler ("addarmor", armor) | ||
addCommandHandler ("removearmor", armor) | |||
</syntaxhighlight> | |||
In this, adds an amount of armor that the player defined in command 'addarmor'. | |||
<syntaxhighlight lang="lua"> | |||
function givePlayerArmor( player, command, amount ) | |||
if getPedArmor(player) == 100 then | |||
outputChatBox("Your armor already is complete!", player, 220, 0, 0 ) -- Inform the player if your armor already is complete. | |||
return | |||
end | |||
if amount and tonumber(amount) >= 1 or tonumber(amount) <= 100 then -- If amount is between 1 and 100. | |||
setPedArmor(player, tonumber(amount)) -- Set amount armor that player chosen on the command. | |||
else | |||
outputChatBox( "Syntax: /addarmor [armor-amount] the amount should be between 1 and 100", player, 220, 0, 0 ) -- Inform the player if 'amount' argument is missing. | |||
end | |||
end | end | ||
addCommandHandler ( " | addCommandHandler( "addarmor", givePlayerArmor ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Ped functions}} | {{Ped functions}} | ||
[[ru:setPedArmor]] |
Latest revision as of 15:32, 7 November 2024
This function allows you to set the armor value of a ped. Function also added client-side.
Syntax
bool setPedArmor ( ped thePed, float armor )
OOP Syntax Help! I don't understand this!
- Method: ped:setArmor(...)
- Variable: .armor
- Counterpart: getPedArmor
Required Arguments
- thePed: the ped whose armor you want to modify.
- armor: the amount of armor you want to set on the ped. Valid values are from 0 to 100.
Returns
Returns true if the armor was changed succesfully. Returns false if an invalid ped was specified, or the armor value specified is out of acceptable range.
Example
This example removes the armor of a player.
function armor (player, command) if command == "addarmor" then setPedArmor ( player, 100 ) -- Set player's armor to 100 when he types the command 'addarmor' elseif command == "removearmor" then setPedArmor ( player, 0 ) -- Set player's armor to 0 when he types the command 'removearmor' end end addCommandHandler ("addarmor", armor) addCommandHandler ("removearmor", armor)
In this, adds an amount of armor that the player defined in command 'addarmor'.
function givePlayerArmor( player, command, amount ) if getPedArmor(player) == 100 then outputChatBox("Your armor already is complete!", player, 220, 0, 0 ) -- Inform the player if your armor already is complete. return end if amount and tonumber(amount) >= 1 or tonumber(amount) <= 100 then -- If amount is between 1 and 100. setPedArmor(player, tonumber(amount)) -- Set amount armor that player chosen on the command. else outputChatBox( "Syntax: /addarmor [armor-amount] the amount should be between 1 and 100", player, 220, 0, 0 ) -- Inform the player if 'amount' argument is missing. end end addCommandHandler( "addarmor", givePlayerArmor )
See Also
- addPedClothes
- getPedClothes
- removePedClothes
- createPed
- getPedAmmoInClip
- getPedArmor
- getPedFightingStyle
- getPedOccupiedVehicle
- getPedOccupiedVehicleSeat
- getPedStat
- getPedTarget
- getPedTotalAmmo
- getPedWalkingStyle
- getPedWeapon
- getPedWeaponSlot
- getPedContactElement
- getValidPedModels
- isPedChoking
- isPedDead
- isPedDoingGangDriveby
- isPedDucked
- isPedHeadless
- isPedInVehicle
- isPedOnFire
- isPedOnGround
- isPedWearingJetpack
- killPed
- removePedFromVehicle
- setPedAnimation
- setPedAnimationProgress
- setPedAnimationSpeed
- setPedArmor
- setPedDoingGangDriveby
- setPedFightingStyle
- setPedHeadless
- setPedOnFire
- setPedStat
- setPedWalkingStyle
- setPedWeaponSlot
- warpPedIntoVehicle