enzopaul4 Posted December 12, 2016 Share Posted December 12, 2016 function createVehicleForPlayer(thePlayer, command, vehicleModel) local x,y,z = getElementPosition(thePlayer) x = x + 5 local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z) if (createdVehicle == false) then outputChatBox("SYNTAX:/createvehicle [id]",thePlayer) end end addCommandHandler("createvehicle", createVehicleForPlayer) setTimer ( createVehicleForPlayer, 1000, 1, "You cannot create a vehicle now!!Please try later again!" ) If i write in chat /createvehicle 410 it's spawn a manana but if i write again it is spawn me again one , what is wrong with setTimer ? Link to comment
Overkillz Posted December 12, 2016 Share Posted December 12, 2016 Im not sure if you are trying to block the function to create vehicle during a second after creating one. In case of yes, try this local allowedToSpawnVehicle = true function createVehicleForPlayer(thePlayer, command, vehicleModel) if allowedToSpawnVehicle then local x,y,z = getElementPosition(thePlayer) x = x + 5 local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z) if (createdVehicle == false) then outputChatBox("SYNTAX:/createvehicle [id]",thePlayer) end allowedToSpawnVehicle = false blockerTime = setTimer(function() allowedToSpawnVehicle = true end,1000,1) else outputChatBox("You cannot create a vehicle now!!Please try later again!",thePlayer,255,255,255,true) end end addCommandHandler("createvehicle", createVehicleForPlayer) It is not tested Regards. Link to comment
enzopaul4 Posted December 12, 2016 Author Share Posted December 12, 2016 Just now, Overkillz said: Im not sure if you are trying to block the function to create vehicle during a second after creating one. In case of yes, try this local allowedToSpawnVehicle = true function createVehicleForPlayer(thePlayer, command, vehicleModel) if allowedToSpawnVehicle then local x,y,z = getElementPosition(thePlayer) x = x + 5 local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z) if (createdVehicle == false) then outputChatBox("SYNTAX:/createvehicle [id]",thePlayer) end allowedToSpawnVehicle = false blockerTime = setTimer(function() allowedToSpawnVehicle = true end,1000,1) else outputChatBox("You cannot create a vehicle now!!Please try later again!",thePlayer,255,255,255,true) end end addCommandHandler("createvehicle", createVehicleForPlayer) It is not tested Regards. It isn't working i try to block it for 1 minute Link to comment
Overkillz Posted December 12, 2016 Share Posted December 12, 2016 local allowedToSpawnVehicle = true function createVehicleForPlayer(thePlayer, command, vehicleModel) if allowedToSpawnVehicle then local x,y,z = getElementPosition(thePlayer) x = x + 5 if not vehicleModel then outputChatBox("SYNTAX:/createvehicle [id]",thePlayer) return end createVehicle(tonumber(vehicleModel),x,y,z) allowedToSpawnVehicle = false blockerTime = setTimer(function() allowedToSpawnVehicle = true end,1000,1) else outputChatBox("You cannot create a vehicle now!!Please try later again!",thePlayer,255,255,255,true) end end addCommandHandler("createvehicle", createVehicleForPlayer) Remember that it 1000 miliseconds is ONE second, so, be aware of it, I have changed something on the code, try it now. Regards. PS: The script is serverside Link to comment
enzopaul4 Posted December 12, 2016 Author Share Posted December 12, 2016 now it is working thank you! Link to comment
iPrestege Posted December 12, 2016 Share Posted December 12, 2016 createdVehicle = { } aVoidSpam = { } function createVehicleForPlayer ( thePlayer,command,vehicleModel ) if isTimer ( aVoidSpam[thePlayer] ) then return outputChatBox ('You cannot create a vehicle now!!Please try later again!',thePlayer) end if not vehicleModel or not tonumber ( vehicleModel ) then return outputChatBox("SYNTAX:/createvehicle [id]",thePlayer) end local x,y,z = getElementPosition(thePlayer) local createdVehicle[thePlayer] = createVehicle ( tonumber ( vehicleModel ),x+5,y,z ) aVoidSpam[thePlayer] = setTimer ( function( thePlayer ) aVoidSpam [thePlayer] = nil end,1000,1,thePlayer ) end addCommandHandler("createvehicle", createVehicleForPlayer) Link to comment
TorNix~|nR Posted December 13, 2016 Share Posted December 13, 2016 @enzopaul4 you still have the problem? Link to comment
Overkillz Posted December 13, 2016 Share Posted December 13, 2016 2 hours ago, TorNix~|nR said: @enzopaul4 you still have the problem? I don't think so On 12/12/2016 at 7:23 PM, enzopaul4 said: now it is working thank you! Link to comment
TorNix~|nR Posted December 13, 2016 Share Posted December 13, 2016 (edited) okey , sorry I didn't see it Edited December 13, 2016 by TorNix~|nR 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