remaked Posted June 30, 2017 Share Posted June 30, 2017 (edited) Hello. So I basically created this simple script which gives the player a jetpack when he types /jet. 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". 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) -- 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 June 30, 2017 by Remaked Link to comment
Amine#TN Posted June 30, 2017 Share Posted June 30, 2017 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now