DoesPedHaveJetPack: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
(Deprecated) |
||
(9 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | {{Server client function}} | ||
{{Deprecated|isPedWearingJetpack}} | |||
Checks whether or not a ped currently has a jetpack. | Checks whether or not a ped currently has a jetpack. | ||
Line 8: | Line 9: | ||
bool doesPedHaveJetPack ( ped thePed ) | bool doesPedHaveJetPack ( ped thePed ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[ped]]:doesHaveJetpack}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 14: | Line 17: | ||
===Returns=== | ===Returns=== | ||
Returns ''true'' if the ped is carrying a jetpack, ''false'' if he is not or an invalid element was passed. | Returns ''true'' if the ped is carrying a jetpack, ''false'' if he is not or an invalid element was passed. | ||
==Example== | |||
<section name="Server" class="server" show="true"> | |||
'''Example 1:''' This examples adds a "jetpack" console command, which gives or removes a jetpack from the player. | |||
<syntaxhighlight lang="lua"> | |||
-- Checks whether or not the player has a jetpack, and gives or removes it from the player | |||
function consoleJetPack ( thePlayer, commandName ) | |||
if ( not doesPedHaveJetPack ( thePlayer ) ) then -- if the player doesn't have a jetpack | |||
local status = givePedJetPack ( thePlayer ) -- give him one | |||
if ( not status ) then | |||
outputConsole ( "Failed to give jetpack.", thePlayer ) -- tell him if it failed | |||
end | |||
else | |||
local status = removePedJetPack ( thePlayer ) -- remove his jetpack | |||
if ( not status ) then | |||
outputConsole ( "Failed to remove jetpack.", thePlayer ) -- tell him if it failed | |||
end | |||
end | |||
end | |||
-- add the function above to handle the "jetpack" command | |||
addCommandHandler ( "jetpack", consoleJetPack ) | |||
</syntaxhighlight> | |||
</section> | |||
<section name="Server" class="server" show="true"> | |||
'''Example 2:''' This example provides a check to see if players have a jetpack when they enter a particular marker. | |||
<syntaxhighlight lang="lua"> | |||
function onWarpMarkerHit ( thePlayer, matchingDimension ) | |||
-- check whether the player has a jetpack and store it in the hasJetPack flag | |||
local hasJetPack = doesPedHaveJetPack ( thePlayer ) | |||
if ( not hasJetPack ) then | |||
-- warp the player to their destination | |||
setElementPosition ( thePlayer, 1337, 1337, 50 ) | |||
else | |||
-- tell the player to remove their jetpack | |||
outputChatBox ( "You must remove your jetpack to use this marker!", thePlayer ) | |||
end | |||
end | |||
-- create a marker and add the function above to its onMarkerHit event | |||
addEventHandler ( "onMarkerHit", createMarker(3180, 200, 27), onWarpMarkerHit ) | |||
</syntaxhighlight> | |||
</section> | |||
==See Also== | ==See Also== | ||
{{Ped functions}} | {{Ped functions}} |
Latest revision as of 09:06, 9 November 2018
This function is deprecated. This means that its use is discouraged and that it might not exist in future versions. | |
Please use isPedWearingJetpack instead. |
Checks whether or not a ped currently has a jetpack.
Syntax
bool doesPedHaveJetPack ( ped thePed )
OOP Syntax Help! I don't understand this!
- Method: ped:doesHaveJetpack(...)
Required Arguments
- thePed: the ped you want to check
Returns
Returns true if the ped is carrying a jetpack, false if he is not or an invalid element was passed.
Example
Click to collapse [-]
ServerExample 1: This examples adds a "jetpack" console command, which gives or removes a jetpack from the player.
-- Checks whether or not the player has a jetpack, and gives or removes it from the player function consoleJetPack ( thePlayer, commandName ) if ( not doesPedHaveJetPack ( thePlayer ) ) then -- if the player doesn't have a jetpack local status = givePedJetPack ( thePlayer ) -- give him one if ( not status ) then outputConsole ( "Failed to give jetpack.", thePlayer ) -- tell him if it failed end else local status = removePedJetPack ( thePlayer ) -- remove his jetpack if ( not status ) then outputConsole ( "Failed to remove jetpack.", thePlayer ) -- tell him if it failed end end end -- add the function above to handle the "jetpack" command addCommandHandler ( "jetpack", consoleJetPack )
Click to collapse [-]
ServerExample 2: This example provides a check to see if players have a jetpack when they enter a particular marker.
function onWarpMarkerHit ( thePlayer, matchingDimension ) -- check whether the player has a jetpack and store it in the hasJetPack flag local hasJetPack = doesPedHaveJetPack ( thePlayer ) if ( not hasJetPack ) then -- warp the player to their destination setElementPosition ( thePlayer, 1337, 1337, 50 ) else -- tell the player to remove their jetpack outputChatBox ( "You must remove your jetpack to use this marker!", thePlayer ) end end -- create a marker and add the function above to its onMarkerHit event addEventHandler ( "onMarkerHit", createMarker(3180, 200, 27), onWarpMarkerHit )
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