70 lines
1.5 KiB
Plaintext
70 lines
1.5 KiB
Plaintext
/*
|
|
tws_t6_lock.gsc — lobby g_password lock at milestone round. Existing players
|
|
are unaffected; g_password is only checked at connect. Cleared on
|
|
hud_game_over so the next lobby opens unlocked.
|
|
*/
|
|
|
|
#include maps\mp\_utility;
|
|
#include common_scripts\utility;
|
|
|
|
// T6 loader probes main and init; initialize only once.
|
|
main()
|
|
{
|
|
}
|
|
|
|
init()
|
|
{
|
|
scripts\zm\tws_t6_common::ensure_config();
|
|
|
|
lock_init();
|
|
}
|
|
|
|
lock_init()
|
|
{
|
|
level.lock_round = scripts\zm\tws_t6_common::int_dvar_or("tws_lock_round", 20);
|
|
level.lock_active = false;
|
|
|
|
// recover from a prior lobby that crashed before clearing
|
|
setDvar("g_password", "");
|
|
|
|
level thread lock_round_watcher();
|
|
level thread lock_cleanup_watcher();
|
|
}
|
|
|
|
lock_round_watcher()
|
|
{
|
|
level endon("hud_game_over");
|
|
|
|
for (;;)
|
|
{
|
|
level waittill("hud_round_changed");
|
|
|
|
if (level.lock_active)
|
|
continue;
|
|
|
|
if (!isDefined(level.round_number) || level.round_number < level.lock_round)
|
|
continue;
|
|
|
|
// random per activation so the password can't be inferred from source
|
|
password = "lock_" + getTime() + "_" + randomInt(1000000);
|
|
setDvar("g_password", password);
|
|
level.lock_active = true;
|
|
|
|
lock_announce();
|
|
}
|
|
}
|
|
|
|
lock_cleanup_watcher()
|
|
{
|
|
level waittill("hud_game_over");
|
|
setDvar("g_password", "");
|
|
level.lock_active = false;
|
|
}
|
|
|
|
lock_announce()
|
|
{
|
|
players = getPlayers();
|
|
for (i = 0; i < players.size; i++)
|
|
players[i] iPrintLnBold("^3Server locked");
|
|
}
|