/* tws_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\_utility; #include common_scripts\utility; init() { if (GetDvar(#"zombiemode") != "1") return; scripts\sp\tws_common::ensure_config(); lock_init(); } lock_init() { level.lock_round = scripts\sp\tws_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"); }