[C#] TriggerServerEvent & RegisterEvent?

Hey again,

so basically I’m trying to trigger an event from client side to server side in C#.

I assumed I need to use TriggerServerEvent(“eventName”); but for some reason, it client side has some errors. Check img from console:

Also, I’ve seen that in Lua, people need to RegisterServerEvent, but there’s nothing like that in C#, only RegisterScript which I have no idea how to use, because RegisterScript takes parameter in type BaseScript and not string, so that’s probably not what I’m looking for.

Anyone successfuly managed to TriggerServerEvent in C#? Thanks

Client:

using CitizenFX.Core;

namespace client
{
    class Main : BaseScript 
    {
        public Main()
        {
			Debug.WriteLine("Aasasdljfnvaskrljdfgnbairlkethngsdljfbhaklsdfhjbgklasdhbgfklsadhbfbladsfmnlôsadjkf");
			TriggerServerEvent("playersLimit:playerActivated");
		}
    }
}

You can’t trigger events or call any natives in a constructor, try doing so on first tick.

Thanks a lot! Worked.

ps : i dunno why but i notice (at least for me) , most of time i use TriggerServerEvent wihout param it’s throw an execption , when you put just one param even an empty one like an empty string , the triggerServerEvent is working 100% of time.