]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'bones_was_here/jlhooks' into 'master'
authorterencehill <piuntn@gmail.com>
Sat, 9 Apr 2022 10:20:32 +0000 (10:20 +0000)
committerterencehill <piuntn@gmail.com>
Sat, 9 Apr 2022 10:20:32 +0000 (10:20 +0000)
Call a hook when the server player count changes to or from zero

See merge request xonotic/xonotic-data.pk3dir!1005

qcsrc/server/client.qc
xonotic-server.cfg

index a5f508851b00876304e486f92f9fcb9634d6f438..2c3bdc25ccf07e90931e1c0704cd09c44a0ffc71 100644 (file)
@@ -1194,6 +1194,9 @@ void ClientConnect(entity this)
 
        MUTATOR_CALLHOOK(ClientConnect, this);
 
+       if (player_count == 1)
+               localcmd("\nsv_hook_firstjoin\n");
+
        if (IS_REAL_CLIENT(this) && !IS_PLAYER(this) && !autocvar_g_campaign)
                CS(this).motd_actived_time = -1; // the welcome message is shown by the client
 }
@@ -1262,6 +1265,9 @@ void ClientDisconnect(entity this)
        player_powerups_remove_all(this); // stop powerup sound
 
        ONREMOVE(this);
+
+       if (player_count == 0)
+               localcmd("\nsv_hook_lastleave\n");
 }
 
 void ChatBubbleThink(entity this)
index 041ac633c9ef23b93dc314cd5f0637852b5cca5c..c9a22805c8de8eeb128a0d03017bdde9f725059d 100644 (file)
@@ -14,6 +14,10 @@ set sv_mapchange_delay 5 "delay by this many seconds after the match ends before
 set minplayers 0 "fill server with bots to reach this number of players in teamless games (if bot_number is not enough)"
 set minplayers_per_team 0 "fill server with bots to reach this number of players per team (if bot_number is not enough)"
 
+// executed when the first player joins or the last player leaves
+alias sv_hook_firstjoin
+alias sv_hook_lastleave
+
 // restart server if all players hit "ready"-button
 set sv_ready_restart_after_countdown 0 "reset players and map items after the countdown ended, instead of at the beginning of the countdown"