Jump to content

Uh, client has not added event


Extremo

Recommended Posts

Hey guys,

I am literally ripping my hair out here. I've been working on this since the morning and it just keeps on giving me the same error no matter what I try. It's funny because I actually don't see anything wrong at all - so I guess another pair of eyes might be nice.

The problem is that I call a client-event from my server but I keep getting the issue back that apparently this "client-event" has not been added by the client.

Here's a couple lines:

Server:

  
function ShowAccountMenu() 
    setElementFrozen(source, true) 
    if getAccount(getPlayerName(source)) then 
        triggerClientEvent("extremo::login::show", source) 
    else 
        triggerClientEvent("extremo::register::show", source) 
    end 
end 
  

Client:

  
addEvent("extremo::login::show", true, true) 
addEvent("extremo::register::show", true, true) 
addEvent("extremo::login::ok", true, true) 
addEvent("extremo::register::ok", true, true) 
addEvent("extremo::login::bad",true, true) 
addEvent("extremo::register::bad",true, true) 
  
addEventHandler("extremo::login::show", getRootElement(),  
function () 
    guiSetVisible(accMenu, true) 
    showCursor(true) 
    guiSetInputEnabled(true) 
end ) 
  

Clearly I have added the event and I've even told the code that it can be remotely called by the server. I tried it with false on the remote part. I tried it without that parameter at all. I tried moving it around. I had an external function at first - so then I put the function into the addEventHandler. I don't know what else to do really, not even the debug shows me any errors. I am lost here.

Link to comment

The problem is probably that the triggerClientEvent is called before the client script is running.

Depending on how you want your script to work, you could triggerServerEvent from client, and then in that event server sided, you call your triggerClientEvent("extremo::login::show", source).

or, that you forgot that addEvent only has two arguments.

Link to comment

Hm, I tested your idea about triggering a server event as well, but it didn't work either. So I am having a guess here that somewhere inside the code there is an error that makes it impossible for the client to load the script at all. I'll have a look at it now and see if I can find any error - if not I'll probably get back to this thread and post some more code. The code is quite big and I don't wanna end up asking you to make it for me.

EDIT:

You're actually right - the problem lies in the simple fact that the client script is not yet loaded when the server is requesting the particular event. Is there some way to make sure that something is only triggered after all files have been loaded?

Right - I just triggered a server event whenever the client resource was started and it now works flawlessly - not a single error. This is resolved =)

Regards.

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