From: terencehill Date: Sat, 9 Apr 2022 10:20:32 +0000 (+0000) Subject: Merge branch 'bones_was_here/jlhooks' into 'master' X-Git-Tag: xonotic-v0.8.5~93 X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=50ce40f7278957bcd42639ca3dcfbf55692aa298;hp=a4649ea0e37c5fcc186c5f315a97af7205e29760 Merge branch 'bones_was_here/jlhooks' into 'master' Call a hook when the server player count changes to or from zero See merge request xonotic/xonotic-data.pk3dir!1005 --- 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 041ac633c..c9a22805c 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"