SetPedWearingJetpack: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Server function}} {{New feature/item|3.0156|1.5.6|| This function is used to give or take a jetpack from a ped, it won't work if the ped is in a vehicle. As such,...")
 
mNo edit summary
Line 4: Line 4:
This function is used to give or take a jetpack from a ped, it won't work if the ped is in a vehicle.
This function is used to give or take a jetpack from a ped, it won't work if the ped is in a vehicle.


As such, you should either expect it to fail sometimes, or repeatedly try to give a jetpack every second or so until [[isPedWearingJetpack]] returns true. Alternatively, you can force the ped into a 'safe' position (e.g. standing on the ground) before giving the jetpack, or use a [[pickup]] to handle it.
As such, you should either expect it to fail sometimes, or repeatedly try to give a jetpack every second or so until [[isPedWearingJetpack]] returns true. Alternatively, you can force the ped into a 'safe' position (e.g. standing on the ground) before giving the jetpack, or use a [[pickup]] to handle it.}}
}}


==Syntax==
==Syntax==

Revision as of 20:57, 31 July 2018

This function is used to give or take a jetpack from a ped, it won't work if the ped is in a vehicle.

As such, you should either expect it to fail sometimes, or repeatedly try to give a jetpack every second or so until isPedWearingJetpack returns true. Alternatively, you can force the ped into a 'safe' position (e.g. standing on the ground) before giving the jetpack, or use a pickup to handle it.

Syntax

bool setPedWearingJetpack ( ped thePed, bool state )


OOP Syntax Help! I don't understand this!

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


Required Arguments

  • thePed: The ped you want to give a jetpack to.
  • state: A boolean representing whether to give or take the jetpack.

Returns

Returns true if a jetpack was successfully set for the ped, false if setting it failed.

Example

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

addCommandHandler ( "jetpack",
    function ( player )
        setPedWearingJetpack ( player, not isPedWearingJetpack ( player ) )
    end
)

See Also