Gamesnert Posted June 22, 2008 Share Posted June 22, 2008 Hello all, I have another problem, again I can't seem to solve it... It's this problem: I have a server which is not yet done, so I'm oftenly messing around with the other co-admins and they with me. With vehicles. Problem is: when refreshing, they don't disappear. After a while, they don't disappear... They don't disappear until a whole server restart. So I made a small piece of code made out of other pieces of code and it... Doesn't work... function initWreckageDestroy(source) setTimer("destroyElement",41000,1,source) end addEventHandler("onVehicleExplode", getRootElement(), initWreckageDestroy) function killWreckageDestroyTimer() timers = getTimers(1000) for timerKey, timerValue in ipairs(timers) do killTimer(timerValue) end end addEventHandler("onVehicleRespawn", getRootElement(), killWreckageDestroyTimer) So I'm asking for some advice. I still need to learn scripting so don't fix the script completely, just explain a bit how to fix it. Edit: Forgot the error message... WARNING: script.lua: Bad argument @ 'setTimer' Line: 322 Thanks in advance, Gamesnert. Link to comment
Mr.Hankey Posted June 22, 2008 Share Posted June 22, 2008 ... setTimer(destroyElement,41000,1,source) ... Link to comment
Gamesnert Posted June 22, 2008 Author Share Posted June 22, 2008 That's it? I feel stupid >.< Thanks. Link to comment
Gamesnert Posted June 23, 2008 Author Share Posted June 23, 2008 Hmmm... Last time I checked, it didn't give an error, and I thought it was working. But now it turns out not to work... Can anyone see anything else that's wrong in my script? Link to comment
tma Posted June 24, 2008 Share Posted June 24, 2008 Well every time a vehicle respawns you're killing every timer you've created in the last second, regardless of what they're connected with. So you could stop timers that weren't meant to destroy the vehicle for one. So you when you create your timer you need to save this and associate it with the vehicle it's designed to destroy - so you can handle only it's timer when it respawns. 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