setPedHeadless | Multi Theft Auto: Wiki Skip to content

setPedHeadless

Client-side
Server-side
Shared

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


With this function, you can set if a ped has a head or not.

OOP Syntax Help! I don't understand this!

  • Method:ped:setHeadless(...)
  • Variable: .headless

Syntax

bool setPedHeadless ( ped thePed, bool headState )
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

  • bool: value

Returns true if successful, false otherwise

Code Examples

shared

This 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