Jump to content

Custom event is not working


Recommended Posts

Hello!

I am trying to make a new custom server-sided event for my weather system, but for some reason it doesn't work in an other script. Here's the handling of my custom event in weatherS.lua:

addEvent("onWeatherChange", true)
local lastWeather = getWeather()
function checkNewWeather()
    local weather = getWeather()
    if weather ~= lastWeather then
        triggerEvent("onWeatherChange", getRootElement(), lastWeather, weather)
        lastWeather = weather
    end
end
setTimer(checkNewWeather, 50, 0)

And here's the part that doesn't work inside waterS.lua:

function testWeatherEvent(lastWeather, weather)
  	outputChatBox(tostring(weather))
	outputChatBox("lol")
end
addEventHandler("onWeatherChange", getRootElement(), testWeatherEvent)

It doesn't output anything from the waterS.lua, not even the "lol" string.

Finally, here's my meta.xml:

<meta>
	<download_priority_group/>2<download_priority_group/>
	
	<script src="waterS.lua" type="server" />
	<script src="weatherS.lua" type="server" />
	<script src="timecycS.lua" type="server" />
	
	<export function="onWeatherChange" type="server" />
</meta>

Could somebody tell me what is the problem or what am I doing wrong, or help me fixing this?

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...