IsPedHeadless: Difference between revisions
Jump to navigation
Jump to search
(added code examples) |
mNo edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 3: | Line 3: | ||
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 | <syntaxhighlight lang="lua"> | ||
bool isPedHeadless(ped thePed) | |||
</syntaxhighlight> | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 22: | Line 24: | ||
end | end | ||
addCommandHandler(" | addCommandHandler("zombie", checkZombie) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
Line 30: | Line 32: | ||
function checkZombie(playerSource, commandName, playerTargetNick) | function checkZombie(playerSource, commandName, playerTargetNick) | ||
local playerTarget = getPlayerFromName(playerTargetNick) | local playerTarget = getPlayerFromName(playerTargetNick) | ||
if (not playerTarget) then outputChatBox("Player not online!", playerSource, 255, 0, 0) end | if (not playerTarget) then return outputChatBox("Player not online!", playerSource, 255, 0, 0) end | ||
-- check whether the playerTarget is headless (a zombie) | -- 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!" | local message = isPedHeadless(playerTarget) and "This Player is a zombie!" or "This player is not a zombie!" | ||
Line 36: | Line 39: | ||
end | end | ||
addCommandHandler(" | 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 [-]
ClientAdd 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 [-]
ServerAdd 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
- 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
- isPedReloadingWeapon
- isPedWearingJetpack
- killPed
- removePedFromVehicle
- setPedAnimation
- setPedAnimationProgress
- setPedAnimationSpeed
- setPedArmor
- setPedDoingGangDriveby
- setPedFightingStyle
- setPedHeadless
- setPedOnFire
- setPedStat
- setPedWalkingStyle
- setPedWeaponSlot
- warpPedIntoVehicle