Jump to content

triggerClientEvent


Killerbee_x.

Recommended Posts

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'

Link to comment
  
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.

Link to comment

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.

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