DoesPlayerHaveJetPack
Jump to navigation
Jump to search
This function is used to determine whether or not a player has a jetpack. Jetpacks can be given to player's using the givePlayerJetPack function and removed with the removePlayerJetPack function.
Syntax
bool doesPlayerHaveJetPack ( player thePlayer )
Required Arguments
- thePlayer: The player you are checking.
Returns
Returns true if a player has a jetpack, false otherwise.
Example
Example 1: This examples adds a "jetpack" console command, which gives or removes a jetpack from the player.
[lua] -- Checks whether or not the player has a jetpack, and gives or removes it from the player function consoleJetPack ( thePlayer, commandName ) if ( not doesPlayerHaveJetPack ( thePlayer ) ) then --if the player doesn't have a jetpack local status = givePlayerJetPack ( thePlayer ) --give him one if ( not status ) then outputConsole ( "Failed to give jetpack.", thePlayer )--tell him if it failed end else local status = removePlayerJetPack ( 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 )
Example 2: This example provides a check to see if players have a jetpack when they enter a particular marker.
[lua] function onWarpMarkerHit(thePlayer, matchingDimension) -- check whether the player has a jetpack and store it in the hasJetPack flag local hasJetPack = doesPlayerHaveJetPack(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 it's onMarkerHit event addEventHandler("onMarkerHit", createMarker(3180, 200, 27), onWarpMarkerHit)
See Also
- getPlayerTeam
- getPlayerBlurLevel
- setPlayerBlurLevel
- getPlayerSerial
- forcePlayerMap
- getPlayerScriptDebugLevel
- getPlayerFromName
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
- getPlayerWantedLevel
- givePlayerMoney
- isPlayerMapForced
- isPlayerNametagShowing
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
- takePlayerMoney
- countPlayersInTeam
- getPlayersInTeam
- isVoiceEnabled
- setControlState
- getControlState