UsErFaiLed Posted September 12, 2013 Share Posted September 12, 2013 Hello, Guys wanted someone to help me up next I want when I create a car like the script below can only spawn one car at a time type spawns 1 Car then it is creating another what he is destroyed before cryo Help me Please Google translate function car ( thePlayer, command ) local x, y, z = getElementPosition ( thePlayer ) createVehicle ( 432, x, y, z + 10 ) end addCommandHandler ( "createtank", car ) Link to comment
-ffs-AbodyRulez Posted September 12, 2013 Share Posted September 12, 2013 Use a flag that equals 0, and changes to 1 if createVehicle == true function car ( thePlayer, command ) if flag == 1 then return end local flag = 0 local x, y, z = getElementPosition ( thePlayer ) local flag_bool = createVehicle ( 432, x, y, z + 10 ) if flag_bool == true then flag = 1 end end addCommandHandler ( "createtank", car ) Link to comment
UsErFaiLed Posted September 12, 2013 Author Share Posted September 12, 2013 Use a flag that equals 0, and changes to 1 if createVehicle == true function car ( thePlayer, command ) if flag == 1 then return end local flag = 0 local x, y, z = getElementPosition ( thePlayer ) local flag_bool = createVehicle ( 432, x, y, z + 10 ) if flag_bool == true then flag = 1 end end addCommandHandler ( "createtank", car ) Thanks Link to comment
nic062 Posted September 12, 2013 Share Posted September 12, 2013 (edited) But if there's many players on the server this dont work, I recommend this : local veh = {} function car(player, command, arg1) local x, y, z = getElementPosition(player) if veh[player] then destroyElement(veh[player]) end veh[player] = createVehicle(432, x, y, z) if arg1 == "in" then warpPedIntoVehicle(player, veh[player]) end end addCommandHandler("createtank", car) And if you type "/createtank in" you are warped into the tank. Edited September 12, 2013 by Guest Link to comment
UsErFaiLed Posted September 12, 2013 Author Share Posted September 12, 2013 But if there's many players on the server this dont work, I recommend this : local veh = {} function car(player, command, arg1) local x, y, z = getElementPosition(player) if veh[player] then destroyElement(veh[player]) end veh[player] = createVehicle(432, x, y, z) if arg1 == "in" then warpPedIntoVehicle(player, veh[player]) end end addCommandHandler("ct", car) And if you type "/createtank in" you are warped into the tank. Thank you so much better 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