Event not Greenlit?

Afternoon all,

So for some reason it seems like my events are firing correctly, which understandably is becoming quite the pain. In my client file I have the RegisterNetEvent(‘eventname’), along with the TriggerServerEvent(‘eventname’), in the server file I have my RegisterServerEvent(‘eventname’) and my EventHandler…

So understandably I’m lost as to why it wouldn’t be greenlit? I’m being instructed to add RegisterServerEvent yet I clear have it, spelled correctly and whatnot.

AddEventHandler('eventname', function(stuff_to_pass_in)
	--Do Stuff

Above is registering an event for the client. Below is for the server.

AddEventHandler("serverEvent", function(stuff_to_pass_in) 
    --Do stuff

Do yours look like this?

It does indeed :slight_smile:

Now it seems to register the events correctly now (for whatever reason), however now I’m met with another issue where it claims it cannot call a nil value, whereas all I’m sending is a integer and a string.

How are you calling it? And whats the evnt look like

Essentially I’m triggering the server event using this:

TriggerServerEvent('eventName', value, name)

Plus RegisterNetEvent has been used and whatnot.

AddEventHandler("eventName", function(value, name)
    for id = 0, 64 do
        if (string.match(NetworkPlayerGetName(id), name)) then

That’s a general summary of how I’m achieving this, however I’m getting:

"Exception has been thrown by the target of an invocation"

It simply states that it cannot call a nil value, however it doesn’t state which value is nil.

I think your problem isn’t the event declaration.

You can’t use “NetworkIsPlayerActive” on server side.

You have to use :

So I’d essentially check for if GetPlayers() contains the id? Now I’ve attempted that however I still seem to be getting the “can not call nil value” result.

in this state you should print “value” and “name” to find what’s wrong

Here’s the issue with that, I’ve actually attempted to have these printed yet I get nothing, which leads me to believe there’s an issue with the AddEventHandler line itself, but I can’t imagine what.

can you copy/paste your code (partial if you want) ?

I’ve updated the code block above to reflect the new changes :slight_smile: Hope it helps!

So fortunately we’re now printing the correct information, huzzah! HOWEVER, I’m STILL being hit with issues regarding nil values, however the console appears to be pointing to:

if (string.match(NetworkPlayerGetName(id), name)) then

So I’m curious as to where the issue is here, as id is obviously just a value used in a loop, and name is thankfully returning the correct value. Could the issue be relevant to NetwordPlayerGetName? Is it a case where that can’t be used in server.lua either?

oh i didn’t take care about but if you still on server side you have to use :
if (string.match(GetPlayerName(id), name)) then

not NetworkPlayerGetName

How odd, it still continues to display the same error… like I can’t possibly think of anything else to try :confused:

Edit: Okay, I’m entirely lost as this error still persists when all I’m doing is printing the arguments, literally nothing else in the EventHandler.

AddEventHandler('eventName', function(name, value)

Well, are you sure are in the same ressource ? if yes, check your __ressource definition. Else check the resssource is referenced in yml.

Last option, you must take care about eventName because it’s case sensitve. (there for ask for your code)

In your ressource, do you have other events working fine ?

Have you tried doing this when you call the event? Just an idea.

TriggerServerEvent('eventName', source, value, name)