GivePlayerJetPack

From Multi Theft Auto: Wiki
Revision as of 16:12, 13 August 2006 by EAi (talk | contribs)
Jump to navigation Jump to search

This function is used to give a player a jetpack.

This function is not guaranteed to succeed. There are some cases where the jetpack cannot be given, for example:

  • If the player is in a vehicle
  • If the player is falling
  • Probably others too.

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

Syntax

bool givePlayerJetPack ( player thePlayer )

Required Arguments

  • player: The player you want to give a jetpack to.

Returns

Returns 'true' if the player was on-foot and didn't already have a jetpack, 'false' otherwise.

Example

addCommandHandler ( "jetpack", "jetPackCommand" )
function jetPackCommand ( source, key )
  if ( doesPlayerHaveJetPack ( source ) ) then -- if he has a jetpack
    removePlayerJetPack ( source ) -- remove it
  else
    givePlayerJetPack ( source ) -- give him one
  end
end

See Also