Vigo.K Posted November 27, 2010 Share Posted November 27, 2010 Hello, guys. I'm just download "Emergancy Lights". And there is some bug, can't turn off that lights and in consule it's shows: WARNING: vehicles\elights.lua:9: Bad argument @ 'killTimer' WARNING: vehicles\elights.lua:10: Bad argument @ 'killTimer' Script file: function EmergencyLights ( source ) theVehicle = getPlayerOccupiedVehicle ( source ) if ( theVehicle ) then if ( getVehicleOverrideLights ( theVehicle ) ~= 2 ) then setVehicleOverrideLights ( theVehicle, 2 ) setTimer ( setLight, 400, 1 ) else setVehicleOverrideLights ( theVehicle, 0 ) killTimer ( setLight ) killTimer ( setLight2 ) end end end function setLight ( ) setTimer ( setLight2, 400, 1 ) setVehicleHeadLightColor (theVehicle, 000, 000, 255) end function setLight2 ( ) setVehicleHeadLightColor (theVehicle, 255, 000, 000) setTimer ( setLight, 400, 1 ) end addCommandHandler ( "elights", EmergencyLights ) Waiting your answers. Link to comment
dzek (varez) Posted November 27, 2010 Share Posted November 27, 2010 setTimer returns timer variable, and this is what you need to kill.. before you copy-paste it without reading: this will fail on server side (if 2 players activate it - one player timers won't stop) will work fine on client for server you need to create a table with timers like: timers1 = { } then set/kill timer like that: timers1[playerElement] = setTimer (blabla) --and kill killTimer(timers1[playerElement]) where playerElement is .. your player element function EmergencyLights ( source ) theVehicle = getPlayerOccupiedVehicle ( source ) if ( theVehicle ) then if ( getVehicleOverrideLights ( theVehicle ) ~= 2 ) then setVehicleOverrideLights ( theVehicle, 2 ) setTimer ( setLight, 400, 1 ) else setVehicleOverrideLights ( theVehicle, 0 ) killTimer ( timer1 ) killTimer ( timer2 ) end end end function setLight ( ) setTimer ( setLight2, 400, 1 ) timer1 = setVehicleHeadLightColor (theVehicle, 000, 000, 255) end function setLight2 ( ) setVehicleHeadLightColor (theVehicle, 255, 000, 000) timer2 = setTimer ( setLight, 400, 1 ) end addCommandHandler ( "elights", EmergencyLights ) Link to comment
Vigo.K Posted November 27, 2010 Author Share Posted November 27, 2010 :D Buddy, can you make please ready script? :D Link to comment
Aibo Posted November 27, 2010 Share Posted November 27, 2010 (edited) blueTimers = {} -- vehicle table for your blue timers redTimers = {} -- for your red timers function EmergencyLights(source) local theVehicle = getPedOccupiedVehicle(source) -- getPlayerOccupiedVehicle() is deprecated -- thevehicle must be local, since we can have more than 1 player with vehicles if theVehicle then if getVehicleOverrideLights(theVehicle) ~= 2 then setVehicleOverrideLights(theVehicle, 2) blueTimers[theVehicle] = setTimer(setLight, 400, 1, theVehicle) -- vehicle element must be passed to the timer/function, since theVehicle is now local else setVehicleOverrideLights(theVehicle, 0) if isTimer(blueTimers[theVehicle]) then killTimer(blueTimers[theVehicle]) end if isTimer(redTimers[theVehicle]) then killTimer(redTimers[theVehicle]) end end end end function setLight(car) setVehicleHeadLightColor(car, 0, 0, 255) redTimers[car] = setTimer(setLight2, 400, 1, car) end function setLight2(car) setVehicleHeadLightColor(car, 255, 0, 0) blueTimers[car] = setTimer(setLight, 400, 1, car) end addCommandHandler("elights", EmergencyLights) Edited November 29, 2010 by Guest Link to comment
Vigo.K Posted November 27, 2010 Author Share Posted November 27, 2010 Maybe someone of you have other emergency lights? Like - MTA Valhalla? :D Link to comment
attemptIt Posted November 27, 2010 Share Posted November 27, 2010 If you want to steal other people's ideas why not just stay and play in Valhalla or check your resources folder for it? Link to comment
dzek (varez) Posted November 27, 2010 Share Posted November 27, 2010 or check your resources folder for it? this is stealing. idea copying isn't as bad as taking somebody's work Link to comment
attemptIt Posted November 27, 2010 Share Posted November 27, 2010 Well, Valhalla is copyrighted anyways. I never recommended him to steal it, I was more likely to call him to view the code and see what he can learn from it. Link to comment
dzek (varez) Posted November 27, 2010 Share Posted November 27, 2010 everything done by anyone is copyrighted.. Link to comment
attemptIt Posted November 27, 2010 Share Posted November 27, 2010 Hm, if so the stuff on the wiki are stuff we can't use aswell? ; [ Link to comment
dzek (varez) Posted November 28, 2010 Share Posted November 28, 2010 just read: http://en.wikipedia.org/wiki/Copyright http://en.wikipedia.org/wiki/License also notice the info while editing wiki: Please note that all contributions to Multi Theft Auto: Wiki are considered to be released under the GNU Free Documentation License 1.2 (see Multi Theft Auto: Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission! short summary: you ALWAYS have copyrights to your work, but you can allow ppl to freely use and edit the result of your work. Link to comment
Vigo.K Posted December 1, 2010 Author Share Posted December 1, 2010 Yes guys, but how to make in this script, when can turn off that Emergency Lights. When I write /elights it's just stay on Emergency Lights mod. ;// Please help me. P.S. What's happened with http://Community.mtasa.com? Link to comment
Aibo Posted December 1, 2010 Share Posted December 1, 2010 Yes guys, but how to make in this script, when can turn off that Emergency Lights.When I write /elights it's just stay on Emergency Lights mod. ;// Please help me. P.S. What's happened with http://Community.mtasa.com? in the script i posted above it is turned on/off by the same command. Link to comment
Vigo.K Posted December 1, 2010 Author Share Posted December 1, 2010 Yes guys, but how to make in this script, when can turn off that Emergency Lights.When I write /elights it's just stay on Emergency Lights mod. ;// Please help me. P.S. What's happened with http://Community.mtasa.com? in the script i posted above it is turned on/off by the same command. Yes, but its stay on red/blue color not to white (default). ;( Link to comment
Static-X Posted December 1, 2010 Share Posted December 1, 2010 Just type /elights again to turn it back to white. Link to comment
Vigo.K Posted December 1, 2010 Author Share Posted December 1, 2010 Just type /elights again to turn it back to white. Nope, its doesn't work. I said, it's stay to red or blue. ;( That's problem. Link to comment
Aibo Posted December 1, 2010 Share Posted December 1, 2010 you cant add 1 line to it to switch to white when off? blueTimers = {} -- vehicle table for your blue timers redTimers = {} -- for your red timers function EmergencyLights(source) local theVehicle = getPedOccupiedVehicle(source) -- getPlayerOccupiedVehicle() is deprecated -- thevehicle must be local, since we can have more than 1 player with vehicles if theVehicle then if getVehicleOverrideLights(theVehicle) ~= 2 then setVehicleOverrideLights(theVehicle, 2) blueTimers[theVehicle] = setTimer(setLight, 400, 1, theVehicle) -- vehicle element must be passed to the timer/function, since theVehicle is now local else setVehicleOverrideLights(theVehicle, 0) setVehicleHeadLightColor(theVehicle, 255, 255, 255) -- this if isTimer(blueTimers[theVehicle]) then killTimer(blueTimers[theVehicle]) end if isTimer(redTimers[theVehicle]) then killTimer(redTimers[theVehicle]) end end end end function setLight(car) setVehicleHeadLightColor(car, 0, 0, 255) redTimers[car] = setTimer(setLight2, 400, 1, car) end function setLight2(car) setVehicleHeadLightColor(car, 255, 0, 0) blueTimers[car] = setTimer(setLight, 400, 1, car) end addCommandHandler("elights", EmergencyLights) Link to comment
Vigo.K Posted December 1, 2010 Author Share Posted December 1, 2010 you cant add 1 line to it to switch to white when off? blueTimers = {} -- vehicle table for your blue timers redTimers = {} -- for your red timers function EmergencyLights(source) local theVehicle = getPedOccupiedVehicle(source) -- getPlayerOccupiedVehicle() is deprecated -- thevehicle must be local, since we can have more than 1 player with vehicles if theVehicle then if getVehicleOverrideLights(theVehicle) ~= 2 then setVehicleOverrideLights(theVehicle, 2) blueTimers[theVehicle] = setTimer(setLight, 400, 1, theVehicle) -- vehicle element must be passed to the timer/function, since theVehicle is now local else setVehicleOverrideLights(theVehicle, 0) setVehicleHeadLightColor(theVehicle, 255, 255, 255) -- this if isTimer(blueTimers[theVehicle]) then killTimer(blueTimers[theVehicle]) end if isTimer(redTimers[theVehicle]) then killTimer(redTimers[theVehicle]) end end end end function setLight(car) setVehicleHeadLightColor(car, 0, 0, 255) redTimers[car] = setTimer(setLight2, 400, 1, car) end function setLight2(car) setVehicleHeadLightColor(car, 255, 0, 0) blueTimers[car] = setTimer(setLight, 400, 1, car) end addCommandHandler("elights", EmergencyLights) Thanks man! <3 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