I’m trying to trigger an event from my client to server but I can’t figure out why it isn’t working.
Here is my client code:

And here is the server code:

The server never prints out the message.

I know I’ve got an empty function and else statement at the bottom but I’m going to fill those when I get the handler working.

RegisterServerEvent not RegisterNetEvent

RegisterNetEvent is for client events.

Whoops, dumb mistake! Have that everywhere else in my code. Fixed, but it still does not print the message. Any other ideas?

It should be printing? You sure you made the correct change? Any errors?

No errors and no printing. I even tried sending a client event back and printing there but I get nothing. I’m restarting my server to see if that magically fixes it but other than that I’ve got no clue.

Server restart has netted no positive results. I’m baffled, but probably making a stupid mistake somewhere

You are sure that NUI Callback is being called?

Yes, I placed a print statement in there and that printed. I even the trigger event in the client citizen thread and the server still did not pick up on it.

Hm. Honestly it all looks correct. I am sure someone will swoop in here and see what we do not or you might figure it out.

No? RegisterNetEvent works on both client and server.

Then why th does RegisterServerEvent even exist if we can just use RegisterNetEvent for both.

Well I have just about no clue where to go from here. I’ve exhausted my own problem solving skills

My guess is that it was made at a later date, perhaps during the switch from CitMP -> FXServer. Who knows?

Yeah. After I posted that I was thinking maybe it was a thing in CitMP and they didnt wanna remove it do to past resources calling it and breaking them.

Ok after looking at the rest of my previously working addon, it looks like literally none of my server event handlers are working. Any idea why this is?

Did you load the server script in the __resource.lua

I did. The entire addon worked as of 3 hours ago and now none of it does - quite confusing. I’ve restarted the server too, nothing. I have absolutely 0 clue what is happening

Maybe you should take a break and come back in a couple hours. Just close everything down and get a fresh mind.

2 Likes

Just got it working. Don’t know how I fixed it, but the server still refuses to print the message. I can, however, trigger client scripts.

1 Like

Do you have something overriding AddEventHandler? Since I’m not sure why you have that s parameter. Also you are comparing plate to null instead of nil. Unless you are doing something like “null = nil”