@Doob You could do something fairly standard like this:
on_player_connect()
{
level endon( "end_game" ); //this kills the function when the game ends
while ( true ) //this indicates we will keep doing this forever in this case it will call on_player_spawned(); for every player that connects to your server
{
level waittill( "connected", player ); //this gets the player when they first connect
//this function below calls a function with the particular connected player in mind
player thread on_player_spawned(); //since this function we are calling is an infinite loop too it needs to be threaded
}
}
on_player_spawned()
{
level endon( "end_game" );
self endon( "disconnect" ); //we will kill the infinite loop if the player disconnects to tie up loose ends
while ( true )//this indicates it will do something for every time a player spawns in
{
self waittill( "spawned_player" ); //this is the event that occurs when the player first spawns in when a game starts and will also occur each time they spawn in from spectator
//call functions you want "self" which in this context is the player to do things with
//if you want to give perks every time a player spawns you would do it in this loop below the self waittill() line
}
}