Sandbox Logo

About Event System


public partial class MyClass
{
    public MyClass(){
        EventSystem.EventCommand.RegisterServerEvent<int, string>( "server:test_event", this.EventTest2 );
        EventSystem.EventCommand.RegisterGameEvent<int, string>( "game:test_event", this.EventTest );
    }

    public void EventTest(IClient client,int arg1, string arg2)
	{
		Log.Info( "eventExecuted" );
		Log.Info( arg1 );
		Log.Info( arg2 );
		//Call Server event with TriggerServerEvent
		EventSystem.EventCommand.TriggerServerEvent( "server:test_event", 1, "uno" );
	}


	public void EventTest2( IClient client, int arg1, string arg2 )
	{
		Log.Info( "eventExecuted" );
		Log.Info( arg1 );
		Log.Info( arg2 );
	}

}

//call Client Event with TriggerClientEvent
EventSystem.EventCommand.TriggerClientEvent( client, "game:test_event", 1,"uno");
You can put up to 6 arguments, I'm working on a version with websockets not necessarily useful but can be good for certain things.

You can declare your event on methods that are not static.

Event System

Created
7/29/2023
Updated
11/9/2023
In Collections
Referenced By
Dependencies
Reviews