From: bones_was_here Date: Sat, 2 Apr 2022 07:40:46 +0000 (+1000) Subject: Call a hook when the server player count changes to or from zero X-Git-Tag: xonotic-v0.8.5~93^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4a5c944bcf23869abee009e57039ba96139967a6;p=xonotic%2Fxonotic-data.pk3dir.git Call a hook when the server player count changes to or from zero --- diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index a5f508851..2c3bdc25c 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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) diff --git a/xonotic-server.cfg b/xonotic-server.cfg index 0be38b303..6548b19e8 100644 --- a/xonotic-server.cfg +++ b/xonotic-server.cfg @@ -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"