Jump to content

Problem with setWeatherBlended


Ch3ck3r

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...