Forcing a map restart - (c) Rookie One :P
Posted: Sun Apr 10, 2005 7:06 pm
Hi,
I needed this done for a mod of mine. Figured it out, so I thought I can share it.
The only flaw is that it sometimes will leave g_allowvote set to 1 if the map restarts immediately after calling the vote, but that can be fixed by using a game variable and checking it at the beginning of the round.
I'm too lazy to post that code, too, though, so you'll have to do that on your own, I'm afraid. 
Hope it's of any use for someone...
Rookie One
I needed this done for a mod of mine. Figured it out, so I thought I can share it.
Code: Select all
// blah blah blah whatever stuff you've got here
thread force_map_restart
force_map_restart:
// first, cancel all votes that might be in progress
for (local.i = 1; local.i <= $player.size; local.i++)
$player[local.i] vote no
// now, pick the last player to call a vote (just in case it's a dedicated server, as $player[1] cannot call a vote in such situation)
for (local.i = $player.size; local.i > 0; local.i--)
{
if ($player[local.i] != NIL && $player[local.i] != NULL)
break
}
// g_allowvote workaround
local.allowvote = int(getcvar(g_allowvote))
setcvar "g_allowvote" 1
// call the restart map vote
$player[local.i] callvote restart map
setcvar "g_allowvote" local.allowvote
// force all players to vote for yes
for (local.i = 1; local.i <= $player.size; local.i++)
$player[local.i] vote yes
endHope it's of any use for someone...
Rookie One