Limit usage of createTimer, use getTickCount instead.
Always localize variables i.e local x = 1 when required
Always check arguments are met/set and use return when necessary to as to ensure a long function isn't carried out only to give an error in the end.
Timers create a timer object which horde, albeit a minute amount, resources. Tick counts on the other hand just check the time since your computer has been running, comparisons can give you differences in time, just like a timer.
local spawnDelayTime = 120000 -- delay time in ms
local spawnTimers = { }
function carSpawn ()
if spawnTimer[source] then
local timePassed = tonumber(getTickCount() - spawnTimer[source])
if timePassed < spawnDelayTime then
local timeleft = math.ceil(timePassed/1000 ) -- Get seconds left from timer
local secondString = " second"
if timeleft > 1 then secondString = " seconds"
outputChatBox("You may spawn your vehicle again in "..tostring(timeleft)..secondString)
return false
end
end
if not (isGuestAccount (getPlayerAccount (source))) and not (isPedInVehicle(source)) then
spawnTimer[source] = getTickCount()
end
This is more resource-efficient as it doesn't create timers for every player on your server. Unfortunately, I haven't tested it but it should work, in theory.
I had a similar idea but with tank models. Basically getting normal vehicles to work like tanks with moving wheels and turrets and all, quite similar to this I must say. I could share the code with you if you like? Quite buggy tho
i made an 'extra seats' resource when I used to script here, basiically making any vehicle have an infinite amount of seats. Try attaching players to the vehicle, making them invisible and setting their camera to focus on the driver to simulate the effect.
Hello, I'd like to know if it's possible for players to download files from the internet straight to their computers from the mta CEGUI browser created with guiCreateBrowser