IsPedHeadless: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ {{Client function}} With this function, you can check if a ped has a head or not. ==Syntax== <syntaxhighlight lang="lua">bool isPedHeadless ( ped thePed )</syntaxhighlight> ===Required Arguments=== *'''...)
 
mNo edit summary
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Server client function}}
With this function, you can check if a ped has a head or not.
With this function, you can check if a ped has a head or not.
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">bool isPedHeadless ( ped thePed )</syntaxhighlight>
<syntaxhighlight lang="lua">
bool isPedHeadless(ped thePed)
</syntaxhighlight>


===Required Arguments===
===Required Arguments===
Line 13: Line 15:
==Example==
==Example==
<section class="client" name="Client" show="true">
<section class="client" name="Client" show="true">
TODO
Add a command to check whether the player is a zombie or not
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- TODO
function checkZombie(commandName)
  local player = getLocalPlayer()
  -- check whether the player is headless (a zombie)
  local message = isPedHeadless(player) and "Yes, you are a zombie!" or "No, you aren't a zombie yet!"
  outputChatBox(message)
end
 
addCommandHandler("zombie", checkZombie)
</syntaxhighlight>
</section>
<section class="server" name="Server" show="true">
Add a command to check whether a player is a zombie or not
<syntaxhighlight lang="lua">
function checkZombie(playerSource, commandName, playerTargetNick)
  local playerTarget = getPlayerFromName(playerTargetNick)
  if (not playerTarget) then return outputChatBox("Player not online!", playerSource, 255, 0, 0) end
 
  -- check whether the playerTarget is headless (a zombie)
  local message = isPedHeadless(playerTarget) and "This Player is a zombie!" or "This player is not a zombie!"
  outputChatBox(message, playerSource)
end
 
addCommandHandler("zombie", checkZombie)
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>

Latest revision as of 13:15, 5 August 2021

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

Syntax

bool isPedHeadless(ped thePed)

Required Arguments

  • thePed: The ped to check.

Returns

Returns true if the ped is headless, false otherwise.

Example

Click to collapse [-]
Client

Add a command to check whether the player is a zombie or not

function checkZombie(commandName)
   local player = getLocalPlayer()
   -- check whether the player is headless (a zombie)
   local message = isPedHeadless(player) and "Yes, you are a zombie!" or "No, you aren't a zombie yet!"
   outputChatBox(message)
end

addCommandHandler("zombie", checkZombie)
Click to collapse [-]
Server

Add a command to check whether a player is a zombie or not

function checkZombie(playerSource, commandName, playerTargetNick)
   local playerTarget = getPlayerFromName(playerTargetNick)
   if (not playerTarget) then return outputChatBox("Player not online!", playerSource, 255, 0, 0) end

   -- check whether the playerTarget is headless (a zombie)
   local message = isPedHeadless(playerTarget) and "This Player is a zombie!" or "This player is not a zombie!"
   outputChatBox(message, playerSource)
end

addCommandHandler("zombie", checkZombie)

See Also