Exception during queued callback


#1

I got a custom event in my Lua script (server sided) and something is going wrong but I’m unsure what. The event looks something like this;

RegisterServerEvent ( "registerConnectedPlayer" );
AddEventHandler ( "registerConnectedPlayer", 
    function ( accountId, department )

This has, as you can see, 2 parameters. but whenever I call it like so in the client, I get a mismatch in the count of parameters:

TriggerServerEvent("registerConnectedPlayer", -1, getElementData ( -1, "account.id" ), getElementData ( -1, "account.department" ) );

If I add in another parameter, it’ll crash everything and say;

Game\GameServer.cs(958): Error: GameServer::Tick: Exception during queued callback: Index was outside the bounds of the array.

Not sure where this is coming from, but it’s weird. Parameter count is correct, nor am I doing anything with a callback. I think it’s deeper than the code I’ve written. Any help is greatly appreciated!

Restarting the script after this error is also impossible, I’m forced to restart the entire server due to the error:

Commands\ResourceCommands.cs(151): Error: Resource::Restart_f: Error restarting resource.

#2

Yea… You’re passing it three parameters when you’re calling the TriggerServerEvent


#3

the player who triggers the function, and 2 parameters. or am I this plain stupid and way too used to other systems, again?


#4

What? The server doesn’t take the player who triggers the event… Do you not read the documentation?

TriggerServerEvent is different to TriggerClientEvent.

Edit: Also, this thread belongs in the “Development” section of the forum, not “Technical Support”.


#5

Well that’s my bad, I think I can find a way to resolve it myself since it’s not related to the trigger. Thanks though, will remove the topic.


#6

Moved accordingly