SetPedArmor: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
(Added second example) |
||
Line 16: | Line 16: | ||
==Example== | ==Example== | ||
This example | This example adds an amount of armor that the player defined in command 'addarmor' | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function givePlayerArmor ( player, command ) | function givePlayerArmor( player, command, amount ) | ||
setPedArmor ( player, | if getPedArmor(player) == 100 then | ||
return | |||
outputChatBox("Your armor already is complete!", player, 220, 0, 0 ) -- Inform the player if your armor already is complete. | |||
end | |||
if amount and amount >= 1 or amount <= 100 then -- If amount is between 1 and 100. | |||
setPedArmor( player, amount ) -- Set amount armor that player chosen on the command. | |||
end | |||
if not amount then | |||
outputChatBox( "sintax: /addarmor [armor-amount]", player, 220, 0, 0 ) -- Inform the player if 'amount' argument is missing. | |||
end | |||
end | end | ||
addCommandHandler ( "addarmor", givePlayerArmor | addCommandHandler( "addarmor", givePlayerArmor ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 04:04, 17 August 2012
This function allows you to set the armor value of a ped.
Syntax
bool setPedArmor ( ped thePed, float armor )
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 adds an amount of armor that the player defined in command 'addarmor'
function givePlayerArmor( player, command, amount ) if getPedArmor(player) == 100 then return outputChatBox("Your armor already is complete!", player, 220, 0, 0 ) -- Inform the player if your armor already is complete. end if amount and amount >= 1 or amount <= 100 then -- If amount is between 1 and 100. setPedArmor( player, amount ) -- Set amount armor that player chosen on the command. end if not amount then outputChatBox( "sintax: /addarmor [armor-amount]", 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