GetPedControlState: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
(5 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | {{Client function}} | ||
Checks whether a ped has a certain control pressed. | Checks whether a ped or the localplayer has a certain control pressed. | ||
==Syntax== | ==Syntax== | ||
Line 7: | Line 7: | ||
bool getPedControlState ( ped thePed, string control ) | bool getPedControlState ( ped thePed, string control ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[Ped]]:getControlState}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 14: | Line 15: | ||
===Returns=== | ===Returns=== | ||
Returns ''true'' if the ped is pressing the specified control, ''false'' if not or an invalid argument was passed. | Returns ''true'' if the ped is pressing the specified control, ''false'' if not or an invalid argument was passed. | ||
===Example=== | |||
<section name="Client" class="client" show="true"> | |||
<syntaxhighlight lang="lua"> | |||
local controlTable = {"forwards", "backwards", "left", "right", "jump", "crouch"} | |||
function invisibleOnSpawn() | |||
setElementAlpha (localPlayer, 0) | |||
checkControlState = setTimer(controlState, 50, 0) | |||
end | |||
addEventHandler ("onClientPlayerSpawn", localPlayer, invisibleOnSpawn) | |||
function controlState() | |||
for i,control in ipairs(controlTable) do | |||
local state = getPedControlState(localPlayer, control) | |||
if (state) then | |||
setElementAlpha (localPlayer, 255) | |||
if (isTimer(checkControlState)) then | |||
killTimer(checkControlState) | |||
checkControlState = nil | |||
end | |||
end | |||
end | |||
end | |||
</syntaxhighlight> | |||
</section> | |||
==Changelog== | |||
{{ChangelogHeader}} | |||
{{ChangelogItem|1.5.5-3.11427|Works with the [[getLocalPlayer|local player]] as well. Deprecated [[setControlState]] and [[getControlState]].}} | |||
==See Also== | ==See Also== | ||
{{Client ped functions}} | {{Client ped functions}} | ||
[[hu:getPedControlState]] |
Latest revision as of 03:05, 13 November 2018
Checks whether a ped or the localplayer has a certain control pressed.
Syntax
bool getPedControlState ( ped thePed, string control )
OOP Syntax Help! I don't understand this!
- Method: Ped:getControlState(...)
Required Arguments
- thePed: the ped you want to check.
- control: the control to get the status of. See control names for a list of valid names.
Returns
Returns true if the ped is pressing the specified control, false if not or an invalid argument was passed.
Example
Click to collapse [-]
Clientlocal controlTable = {"forwards", "backwards", "left", "right", "jump", "crouch"} function invisibleOnSpawn() setElementAlpha (localPlayer, 0) checkControlState = setTimer(controlState, 50, 0) end addEventHandler ("onClientPlayerSpawn", localPlayer, invisibleOnSpawn) function controlState() for i,control in ipairs(controlTable) do local state = getPedControlState(localPlayer, control) if (state) then setElementAlpha (localPlayer, 255) if (isTimer(checkControlState)) then killTimer(checkControlState) checkControlState = nil end end end end
Changelog
Version | Description |
---|
1.5.5-3.11427 | Works with the local player as well. Deprecated setControlState and getControlState. |
See Also
- canPedBeKnockedOffBike
- getPedAnalogControlState
- getPedAnimation
- getPedBonePosition
- getPedCameraRotation
- getPedControlState
- getPedMoveState
- getPedOxygenLevel
- getPedSimplestTask
- getPedTargetCollision
- getPedTargetEnd
- getPedTargetStart
- getPedTask
- getPedVoice
- getPedWeaponMuzzlePosition
- givePedWeapon
- isPedBleeding
- isPedDoingTask
- isPedReloadingWeapon
- isPedTargetingMarkerEnabled
- setAnalogControlState
- setPedAimTarget
- setPedAnalogControlState
- setPedBleeding
- setPedCameraRotation
- setPedCanBeKnockedOffBike
- setPedControlState
- setPedEnterVehicle
- setPedExitVehicle
- IsPedFootBloodEnabled
- setPedFootBloodEnabled
- setPedLookAt
- setPedOxygenLevel
- setPedTargetingMarkerEnabled
- setPedVoice
- Shared
- 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