[How-to] Setting up C# and creating a basic resource

Has some one some more code snippets for more events? There is not a lot documentation yet.

I find this list of a few events but I don’t know how to use it :frowning:

I tried “onPlayerDied” on server side with this implementation in the constructor:

EventHandlers.Add("onPlayerDied", new Action<Player, string, Vector3, CallbackDelegate>(OnPlayerDied));

and this method:

private void OnPlayerDied([FromSource]Player player, string deathReason, Vector3 position, CallbackDelegate wtf)
{
    Debug.WriteLine("OnPlayerDied! " + player.Name + " reason = " + deathReason + " at position: " + position.ToString());
}

I’ve done a lot of suicides but nothing happens.

I also tried to implement the playerSpawned event on client side with this line in the constructor:

EventHandlers.Add("playerSpawned", new Action<Player>(OnPlayerSpawned));

and this method:

private void OnPlayerSpawned([FromSource]Player player)
{            
    Debug.WriteLine("OnPlayerSpawned!!! "+player.Name); //this creates an error :(
    Debug.WriteLine("OnPlayerSpawned!!!"); //this works :) you got the line "OnPlayerSpawned!!!" at your client console (F8)
}

So I think there is no parameter of type Player in the event? In the
lua docu I got no more help, I don’t understand nothing of it :wink:

Where can i find out what parameters are used in the events?