Dzsozi (h03) Posted March 19, 2017 Share Posted March 19, 2017 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
NeXuS™ Posted March 19, 2017 Share Posted March 19, 2017 Try removing <export function="onWeatherChange" type="server" /> from your meta. It's not a function. Link to comment
Dzsozi (h03) Posted March 19, 2017 Author Share Posted March 19, 2017 Still not working, btw, it must be added there so you can use the event in other resources as well. Link to comment
NeXuS™ Posted March 19, 2017 Share Posted March 19, 2017 This one works totally fine for me: Spoiler Just tested your script, works perfectly for me. 1 Link to comment
Dzsozi (h03) Posted March 19, 2017 Author Share Posted March 19, 2017 Fixed it by myself omg... The problem was in the meta, I should write the weatherS.lua before the waterS.lua, not after the waterS.lua. Thank you anyway! 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