Killerbee_x. Posted December 7, 2014 Posted December 7, 2014 Hey there, While scripting I stumbled upon the following problem: I want to trigger a clientsided function when a player joins the server. But for some reason the script does not recognise the addEvent() I added in client. I hope anybody has a way to solve this issue or knows a way around this. Thanks in advance server code: addEventHandler("onPlayerJoin", getRootElement(), function() setElementData(source, "loggedOn", false) redirectOpenPanel(source) end ) function redirectOpenPanel() triggerClientEvent("openPanel", source) end client code: function openUserpanel() -- Do stuff end addEvent("openPanel", true) addEventHandler("openPanel", getRootElement(), openUserpanel) debug gives the standard 'triggering client event. but event is not added clientside'
Jaydan Posted December 7, 2014 Posted December 7, 2014 function redirectOpenPanel(source) triggerClientEvent(source, "openPanel", source) end Without putting source in the parameters how is it going to know what 'source' is? You also forgot to put source as the first parameter in the triggerClientEvent function, without doing that it would send it to every client. Also make sure your meta.xml file is correct, if you aren't sure post it below.
Killerbee_x. Posted December 8, 2014 Author Posted December 8, 2014 Even when altering the lines like you mentioned it is not working properly. The fact that I also trigger the clientside script on client by calling the function indicates that the function is working as intended. Though, it used to work as intended via the triggerClientEvent, but somewhere along the scripting process it stopped working. Hope anyone else has had the similar problem and knows a solution.
Moderators IIYAMA Posted December 8, 2014 Moderators Posted December 8, 2014 Problem: The client hasn't loaded the script before the server is sending him a trigger. Solution: "onClientResourceStart"(resourceRoot) > triggerServerEvent > triggerClientEvent > openpanel
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