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.
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.
Essentially I’m triggering the server event using this:
TriggerServerEvent('eventName', value, name)
Plus RegisterNetEvent has been used and whatnot.
RegisterServerEvent("eventName")
AddEventHandler("eventName", function(value, name)
for id = 0, 64 do
if (string.match(NetworkPlayerGetName(id), name)) then
end
end
end)
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.
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.
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.
I’ve updated the code block above to reflect the new changes 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?