IsPedDucked: Difference between revisions
Jump to navigation
Jump to search
(Added new example) |
mNo edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 5: | Line 5: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">bool isPedDucked ( ped thePed )</syntaxhighlight> | <syntaxhighlight lang="lua">bool isPedDucked ( ped thePed )</syntaxhighlight> | ||
{{OOP||[[ped]]:isDucked|ducked}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 28: | Line 29: | ||
local alreadyDucked = isPedDucked(ped) | local alreadyDucked = isPedDucked(ped) | ||
if (alreadyDucked and not bool) then | if (alreadyDucked and not bool) then | ||
setPedControlState(ped, "crouch", true) | |||
setTimer(setPedControlState, 50, 1, ped, "crouch", false) | |||
return true | return true | ||
elseif (not alreadyDucked and bool) then | elseif (not alreadyDucked and bool) then | ||
setPedControlState(ped, "crouch", true) | |||
setTimer(setPedControlState, 50, 1, ped, "crouch", false) | |||
return true | return true | ||
end | end |
Latest revision as of 23:05, 8 July 2018
This function checks if the specified ped is ducked (crouched) or not.
Syntax
bool isPedDucked ( ped thePed )
OOP Syntax Help! I don't understand this!
- Method: ped:isDucked(...)
- Variable: .ducked
Required Arguments
- thePed: The ped to check.
Returns
Returns true if the ped is ducked, false otherwise.
Example
Click to collapse [-]
ClientThis example checks if a random player is ducked or not, and if so displays a message in the chat box.
local players = getElementsByType ( "player" ) local randomPlayer = players[math.random(#players)] if isPedDucked ( randomPlayer ) then outputChatBox ( getPlayerName ( randomPlayer ) .. " is currently crouching." ) end
This example creates a function that lets you toggle the crouching state of a ped.
function setPedDucked(ped, bool) local alreadyDucked = isPedDucked(ped) if (alreadyDucked and not bool) then setPedControlState(ped, "crouch", true) setTimer(setPedControlState, 50, 1, ped, "crouch", false) return true elseif (not alreadyDucked and bool) then setPedControlState(ped, "crouch", true) setTimer(setPedControlState, 50, 1, ped, "crouch", false) return true end return false end
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