DiGiTal Posted September 3, 2017 Share Posted September 3, 2017 Hi, when i click to a button for to spawn the car it will spawn after it will be destroyed. when i delete the destroy the player can Spam with spawning. i want once it's spawned he can't spawn again . addEvent("spawncar1",true) addEventHandler("spawncar1",getRootElement(), function() if not (isGuestAccount(getPlayerAccount(client))) then if not (isPedInVehicle(client)) then local x,y,z = getElementPosition(client) if (getElementData(client,"mycar1")) and (getElementData(client,"mycar1")~= nil) --[[and (getElementType(getElementData(client,"mycar1")) =="vehicle")]] then local vehicle = getElementData(client,"mycar1") outputChatBox("Vehicle destroyed",client) elseif not (getElementData(client,"mycar1")) then local account = getPlayerAccount(client) local name = getAccountName(account) local playercar = executeSQLQuery("SELECT Model,Paintjob,Color,Upgrade0,Upgrade1,Upgrade2,Upgrade3,Upgrade4,Upgrade5,Upgrade6,Upgrade7,Upgrade8,Upgrade9,Upgrade10,Upgrade11,Upgrade12,Upgrade13,Upgrade14,Upgrade15,Upgrade16 FROM carslot1 WHERE PlayerName = ?",name) if (playercar) then if #playercar > 0 then local x,y,z = getElementPosition(client) local vehicle = createVehicle(playercar[1].Model,x + 5,y +2,z) setVehiclePaintjob(vehicle,playercar[1].Paintjob) setElementData(vehicle,"vehicleOwner","mycar1") setElementData (vehicle,"mycar1",getPlayerName(source)) setElementData (client, "mycar1", vehicle) setElementData(vehicle,"VOwner",getPlayerName(client)) outputChatBox ("Car spawned.", source, 153,51,255) addVehicleUpgrade(vehicle, playercar[1].Upgrade0) addVehicleUpgrade(vehicle, playercar[1].Upgrade1) addVehicleUpgrade(vehicle, playercar[1].Upgrade2) addVehicleUpgrade(vehicle, playercar[1].Upgrade3) addVehicleUpgrade(vehicle, playercar[1].Upgrade4) addVehicleUpgrade(vehicle, playercar[1].Upgrade5) addVehicleUpgrade(vehicle, playercar[1].Upgrade6) addVehicleUpgrade(vehicle, playercar[1].Upgrade7) addVehicleUpgrade(vehicle, playercar[1].Upgrade8) addVehicleUpgrade(vehicle, playercar[1].Upgrade9) addVehicleUpgrade(vehicle, playercar[1].Upgrade10) addVehicleUpgrade(vehicle, playercar[1].Upgrade11) addVehicleUpgrade(vehicle, playercar[1].Upgrade12) addVehicleUpgrade(vehicle, playercar[1].Upgrade13) addVehicleUpgrade(vehicle, playercar[1].Upgrade14) addVehicleUpgrade(vehicle, playercar[1].Upgrade15) addVehicleUpgrade(vehicle, playercar[1].Upgrade16) local col1 = gettok (playercar[1].Color, 1, string.byte(',') ) local col2 = gettok (playercar[1].Color, 2, string.byte(',') ) local col3 = gettok (playercar[1].Color, 3, string.byte(',') ) local col4 = gettok (playercar[1].Color, 4, string.byte(',') ) local col5 = gettok (playercar[1].Color, 5, string.byte(',') ) local col6 = gettok (playercar[1].Color, 6, string.byte(',') ) outputChatBox(col1) if col1 then setVehicleColor(vehicle, tonumber(col1), tonumber(col2), tonumber(col3), tonumber(col4), tonumber(col5), tonumber(col6)) end else outputChatBox("You have not buy a car for this slot yet",client) end end end else outputChatBox("You need to get out of your vehicle first",client) end else outputChatBox("You need to log in first",client) end end) Link to comment
itHyperoX Posted September 3, 2017 Share Posted September 3, 2017 (edited) just add this after if #playercar > 0 then setElementData(client,"mycar1 - > Spawned",true) then replace this: if not (isPedInVehicle(client)) then to this: if not (isPedInVehicle(client)) and not getElementData(client,"mycar1 -> Spawned") == true then when you destroy: removeElementData(client,"mycar1 -> Spawned") or setElementData(client,"mycar1 - > Spawned",false) Edited September 3, 2017 by TheMOG 1 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