SetPedHeadless: Difference between revisions
Jump to navigation
Jump to search
Dutchman101 (talk | contribs) m (t) |
|||
(12 intermediate revisions by 11 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{ | {{Server client function}} | ||
With this function, you can set if a ped has a head or not. | With this function, you can set if a ped has a head or not. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">bool setPedHeadless | <syntaxhighlight lang="lua"> | ||
bool setPedHeadless(ped thePed, bool headState) | |||
</syntaxhighlight> | |||
[[File:Headless.png|thumb|exmaple]] | |||
{{OOP||[[ped]]:setHeadless|headless}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''thePed''': The [[ped]] to check. | *'''thePed''': The [[ped]] to check. | ||
*'''headState''': head state, use | *'''headState''': head state, use true if you want the ped be headless, use false to give back the head. | ||
===Returns=== | ===Returns=== | ||
Returns ''true'' if successful, ''false'' otherwise | Returns ''true'' if successful, ''false'' otherwise | ||
==Example== | |||
<section name="Server" class="server" show="true"> | |||
This example enables a player to behead themselves (or give themselves their head back) | |||
<syntaxhighlight lang="lua"> | |||
function beheadMe(p, cmd) | |||
local hasHead = not isPedHeadless(p) | |||
if hasHead then | |||
setPedHeadless(p, true) -- Remove head | |||
outputChatBox("You have been beheaded!", p, 255, 0, 0) -- A confirmation message for the player | |||
else | |||
setPedHeadless(p, false) -- Restore head | |||
outputChatBox("You have been given a head!", p, 255, 0, 0) -- A confirmation message for the player | |||
end | |||
end | |||
addCommandHandler("togglehead", beheadMe) | |||
</syntaxhighlight> | |||
</section> | |||
==See Also== | ==See Also== | ||
{{Ped functions}} | {{Ped functions}} | ||
[[ru:setPedHeadless]] |
Latest revision as of 06:55, 23 August 2021
With this function, you can set if a ped has a head or not.
Syntax
bool setPedHeadless(ped thePed, bool headState)
OOP Syntax Help! I don't understand this!
- Method: ped:setHeadless(...)
- Variable: .headless
Required Arguments
- thePed: The ped to check.
- headState: head state, use true if you want the ped be headless, use false to give back the head.
Returns
Returns true if successful, false otherwise
Example
Click to collapse [-]
ServerThis example enables a player to behead themselves (or give themselves their head back)
function beheadMe(p, cmd) local hasHead = not isPedHeadless(p) if hasHead then setPedHeadless(p, true) -- Remove head outputChatBox("You have been beheaded!", p, 255, 0, 0) -- A confirmation message for the player else setPedHeadless(p, false) -- Restore head outputChatBox("You have been given a head!", p, 255, 0, 0) -- A confirmation message for the player end end addCommandHandler("togglehead", beheadMe)
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