Jump to content

Help regarding a jetpack script.


remaked

Recommended Posts

Hello. So I basically created this simple script which gives the player a jetpack when he types /jet.

  1. function giveJetpack(thePlayer, commandName) -- Our function and arguments.
  2.          if(givePedJetPack(thePlayer)) then -- Checks if the player got his jetpack, we don't need an output here since the player will clearly see the jetpack.
  3.                   return true --
  4.                 end -- ending the "if".
  5.                  if(getPedOccupiedVehicle(thePlayer)) then -- Checks if the player is in a vehicle, so if he's he won't get his jetpack.
  6.                  outputChatBox("You can't use this command while in vehicle!", thePlayer, 255, 255, 0) -- If he's, it will output a message.
  7.                   return false -- returns false so he doesn't get the jetpack.
  8.             end -- ending the "if".
  9. end     -- ending the function.
  10. addCommandHandler("jet", giveJetpack) -- the command we chose which is /jet in this case, keep in mind you can change it.
 
I want to know what should I do so when a player types /jet again the jetpack gets removed, thanks in advance.
Edited by Remaked
Link to comment
  1.  
    function giveJetpack(thePlayer, commandName) -- Our function and arguments.
             if(givePedJetPack(thePlayer)) then -- Checks if the player got his jetpack, we don't need an output here since the player will clearly see the jetpack.
                      return true --
                    end --ending the "if".
    elseif
     doesPedHaveJetPack(thePlayer) then -- Check if the player already has a jetpack.
            removePedJetPack(thePlayer) -- Remove the jetpack if he has one.
            return -- And stop the function here.
        end
                     if(getPedOccupiedVehicle(thePlayer)) then -- Checks if the player is in a vehicle, so if he's he won't get his jetpack.
                     outputChatBox("You can't use this command while in vehicle!", thePlayer, 255, 255, 0) -- If he's, it will output a message.
                      return false -- returns false so he doesn't get the jetpack.
                end -- ending the "if".
    end     -- ending the function.
    addCommandHandler("jet", giveJetpack)
     
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...