IsPedWearingJetpack: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Server client function}} {{New feature/item|3.0156|1.5.6||Checks whether or not a ped is currently wearing a jetpack.}} ==Syntax== <syntaxhighlight lang="lua"> bo...")
 
(Requirements)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server client function}}
{{Server client function}}
{{New feature/item|3.0156|1.5.6||Checks whether or not a ped is currently wearing a jetpack.}}
{{New feature/item|3.0156|1.5.5|13846|Checks whether or not a ped is currently wearing a jetpack.}}


==Syntax==
==Syntax==
Line 46: Line 46:
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>
==Requirements==
{{Requirements|1.5.5-9.13846|1.5.5-9.13846|}}


==See Also==
==See Also==
{{Ped functions}}
{{Ped functions}}

Latest revision as of 20:02, 12 September 2018

Checks whether or not a ped is currently wearing a jetpack.

Syntax

bool isPedWearingJetpack ( ped thePed )


OOP Syntax Help! I don't understand this!

Method: ped:isWearingJetpack(...)
Variable: .jetpack


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 [-]
Server

Example 1: This examples adds a "jetpack" console command, which toggles a jetpack for the player.

addCommandHandler ( "jetpack",
    function ( player )
        setPedWearingJetpack ( player, not isPedWearingJetpack ( player ) )
    end
)
Click to collapse [-]
Server

Example 2: This example provides a check to see if players have a jetpack when they enter a particular marker.

function onWarpMarkerHit ( player )
   -- check whether the player has a jetpack
   if ( not isPedWearingJetpack ( player ) ) then
      -- warp the player to their destination
      setElementPosition ( player, 1337, 1337, 50 )
   else
      -- tell the player to remove their jetpack
      outputChatBox ( "You must remove your jetpack to use this marker!", player )
   end
end

-- create a marker and add the function above to its onMarkerHit event
addEventHandler ( "onMarkerHit", createMarker( 3180, 200, 27 ), onWarpMarkerHit )

Requirements

Minimum server version 1.5.5-9.13846
Minimum client version 1.5.5-9.13846

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version server="1.5.5-9.13846" client="1.5.5-9.13846" />

See Also