Lendiz Posted August 17, 2016 Share Posted August 17, 2016 Hello there! Serverside addEvent("onRaceStateChanging", true) addEventHandler("onRaceStateChanging", getRootElement(), function(newStateName) if(newStateName == "Running") then triggerClientEvent(source,"mapRunningServer",source) end end) Clientside addEvent("mapRunningServer",true) function musicStart() if isTransferBoxActive() == false then sound = playSound("sound.mp3") else setTimer(musicStart,500,0) end end addEventHandler("mapRunningServer",root,musicStart) Getting error Server trigger event mapRunningServer but event not added to clientside What wrong can be here? Link to comment
Lendiz Posted August 18, 2016 Author Share Posted August 18, 2016 UPD: This error when player still have download and race state changed to Running Link to comment
LabiVila Posted August 19, 2016 Share Posted August 19, 2016 triggerClientEvent(source,"mapRunningServer",source) Source is not defined. Try changing it to: triggerClientEvent("mapRunningServer", root) Link to comment
Lendiz Posted August 19, 2016 Author Share Posted August 19, 2016 Same error. Here is meta, maybe will need... And, if client has downloaded files before race Running - script works fine Link to comment
Simple0x47 Posted August 20, 2016 Share Posted August 20, 2016 The only problem I can think of is that you call a main function with onResourceStartwhich then triggers the server event "onRaceStateChanging", which give's almost no time to the client to 'create' the event on clientside. I would recommend to start your script with onClientResourceStartfor this kind of things. Link to comment
Lendiz Posted August 20, 2016 Author Share Posted August 20, 2016 I think, i wrong understand you. You mean not use onRaceStateChanging? And why u write about onResourceStart, if dont have it in script. Link to comment
Lendiz Posted August 22, 2016 Author Share Posted August 22, 2016 Problem solved by adding setElementData Link to comment
Big Smoker Posted March 5, 2019 Share Posted March 5, 2019 usou o setElementData a onde? eu to com mesmo problema Link to comment
Moderators IIYAMA Posted March 6, 2019 Moderators Share Posted March 6, 2019 (edited) On 20/08/2016 at 13:43, Lendiz said: I think, i wrong understand you. You mean not use onRaceStateChanging? And why u write about onResourceStart, if dont have it in script. He is talking about the solution for this situation: The server sending a triggerClientEvent. But unfortunately the client is still downloading/loading the scripts. So the message isn't delivered and will give you that error that you are having. onClientResourceStart can be used as indication that the client is loaded and ready to receive triggerClientEvent's. (For that specific resource atleast) Edited March 6, 2019 by IIYAMA 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