Piorun Posted July 16, 2014 Share Posted July 16, 2014 Hi, I want to ask you why if i have code: addEventHandler("onPlayerJoin",root, function() triggerClientEvent(source,"playerJoined",root) end ) Someone who enters first time to server gots an error : server triggered client side event, but event is not added client side? Link to comment
ADCX Posted July 16, 2014 Share Posted July 16, 2014 Client: function playerJoined() outputChatBox("welcome") end addEvent("playerJoined",true) addEventHandler("playerJoined",getRootElement(),playerJoined) Link to comment
_DrXenon Posted July 16, 2014 Share Posted July 16, 2014 You have to add the event in client file: addEvent("name",true) then to trigger the event: addEventHandler("name",root,function) Just like ADCX said.. Else ,your client side function is missed up..or got smthing wrong Link to comment
Mr_Moose Posted July 17, 2014 Share Posted July 17, 2014 I think he knows about adding the code to the client, it's all in the documentation of: triggerClientEvent The problem however is that the client files haven't been downloaded when onPlayerJoin is triggered server side which means that the client code doesn't exist yet. A better solution would be to use the client sided event: addEventHandler( "onClientResourceStart", getRootElement( ), function ( startedRes ) -- Client resources has finished downloading here. end ); 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