Ch3ck3r Posted October 23, 2009 Share Posted October 23, 2009 Hi, i want to have some weather changing effect in my server. So i scripted the following resource, but it does not work. On resource start, the weather is set correctly as far as i can assess. After the first change, the weather should change every quarter (at minute 00, 15, 30 and 45). But it doesn't do anything. I added the command /weather to change the weather manually and check if it works, but it always says me, that there is already a change happening. I am not able to find the error, any help appreciated (The script is serverside) function startWeatherSim() local id = getRandomWeatherId() if(not setWeatherBlended(id)) then outputDebugString("Changing weather failed with weatherid "..tostring(id), 1) end local minute = getRealTime().minute local toNextQuarter = 15 - (minute%15) setTimer(setTimer, toNextQuarter*60*1000, 1, changeWeather, 15*60*1000, 0) setTimer(changeWeather, toNextQuarter*60*1000, 1) end function changeWeather() weatherid, changing = getWeather() if(changing ~= nil) then outputDebugString("Weather is already changing at the moment"..tostring(weatherid), 1) return false end local id = getRandomWeatherId() if (not setWeatherBlended(id)) then outputDebugString("Changing weather failed with weatherid "..tostring(id), 1) end end function getRandomWeatherId() local id = math.random(1, 255) outputDebugString("Random Weather is "..tostring(id), 3) return id end addEventHandler("onResourceStart", getResourceRootElement(), startWeatherSim) addCommandHandler("weather", changeWeather) Link to comment
AeroXbird Posted October 26, 2009 Share Posted October 26, 2009 im sorry but why do u do the following in the script: setTimer(setTimer, toNextQuarter*60*1000, 1, changeWeather, 15*60*1000, 0) i believe that is a problematic line because u are doing a setTimer in a setTimer wich is in my eyes not quite possible. 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