qwerty
25th November 2015, 17:34
Hey there,
I would like to share my nextmap vote system, you can freely use or modify it just use credit. You can watch a demo here:
https://www.youtube.com/watch?v=11bpcAUq87Q&hd=1
You can config a few paramter like selectable maps, time limit and so one, add these lines to your server's cfg.
set scr_nextmap "1"
set scr_nextmap_maps "mp_burgundy,mp_carentan,mp_dawnville,mp_toujane"
set scr_nextmap_time "90" //seconds
First thing first, you have to precache shaders and strings.
game["timeleft"] = &"Remaining time";
game["hintleft"] = &"<-- [{+attack}]";
game["hintright"] = &"[{toggleads}], [{+speed}] -->";
game["mp_breakout"] = &"Villers-Bocage^1(^7&&1^1)";
game["mp_brecourt"] = &"Brecourt^1(^7&&1^1)";
game["mp_burgundy"] = &"Burgundy^1(^7&&1^1)";
game["mp_carentan"] = &"Carentan^1(^7&&1^1)";
game["mp_dawnville"] = &"St. Mere Eglise^1(^7&&1^1)";
game["mp_decoy"] = &"El Alamein^1(^7&&1^1)";
game["mp_downtown"] = &"Moscow^1(^7&&1^1)";
game["mp_farmhouse"] = &"Beltot^1(^7&&1^1)";
game["mp_harbor"] = &"Rostov^1(^7&&1^1)";
game["mp_leningrad"] = &"Leningrad^1(^7&&1^1)";
game["mp_matmata"] = &"Matmata^1(^7&&1^1)";
game["mp_railyard"] = &"Stalingrad^1(^7&&1^1)";
game["mp_rhine"] = &"Wallendar^1(^7&&1^1)";
game["mp_toujane"] = &"Toujane^1(^7&&1^1)";
game["mp_trainstation"] = &"Caen^1(^7&&1^1)";
PreCacheString(game["timeleft"]);
PreCacheString(game["hintleft"]);
PreCacheString(game["hintright"]);
PreCacheString(game["mp_breakout"]);
PreCacheString(game["mp_brecourt"]);
PreCacheString(game["mp_burgundy"]);
PreCacheString(game["mp_carentan"]);
PreCacheString(game["mp_dawnville"]);
PreCacheString(game["mp_decoy"]);
PreCacheString(game["mp_downtown"]);
PreCacheString(game["mp_farmhouse"]);
PreCacheString(game["mp_harbor"]);
PreCacheString(game["mp_leningrad"]);
PreCacheString(game["mp_matmata"]);
PreCacheString(game["mp_railyard"]);
PreCacheString(game["mp_rhine"]);
PreCacheString(game["mp_toujane"]);
PreCacheString(game["mp_trainstation"]);
PrecacheShader("black");
PrecacheShader("white");
PrecacheShader("loadscreen_mp_breakout");
PrecacheShader("loadscreen_mp_brecourt");
PrecacheShader("loadscreen_mp_burgundy");
PrecacheShader("loadscreen_mp_carentan");
PrecacheShader("loadscreen_mp_dawnville");
PrecacheShader("loadscreen_mp_decoy");
PrecacheShader("loadscreen_mp_downtown");
PrecacheShader("loadscreen_mp_farmhouse");
PrecacheShader("loadscreen_mp_harbor");
PrecacheShader("loadscreen_mp_leningrad");
PrecacheShader("loadscreen_mp_matmata");
PrecacheShader("loadscreen_mp_railyard");
PrecacheShader("loadscreen_mp_rhine");
PrecacheShader("loadscreen_mp_toujane");
PrecacheShader("loadscreen_mp_trainstation");
I used it after the scorebord part in the gametype/endmap function, so firstly I need to hide the scoreboard for each player. I created a menu for it.
game["menu_clientcommand"] = "ClientCommand";
PrecacheMenu(game["menu_clientcommand"]);
So there is a menu file, called "ClientCommand.menu"
#include "ui_mp/menudef.h"
MenuDef
{
Name "ClientCommand"
Rect 0 0 1 1
Visible 0
Fullscreen 0
OnOpen
{
exec "vstr ClientCommand";
close ClientCommand;
}
}
Finally here is the full source
GetCurrenttMap(maps)
{
valid = false;
current = GetCvar("mapname");
for (i = 0; i < maps.size; i++)
{
if (maps[i] == current)
{
valid = true;
break;
}
}
if (!valid)
{
current = maps[0];
}
return current;
}
GetNextMap(maps, current)
{
id = 0;
if (!IsDefined(current))
{
current = GetCurrenttMap(maps);
}
for (i = 0; i < maps.size; i++)
{
if (maps[i] == current)
{
id = i;
break;
}
}
if (id == 0)
{
return maps[maps.size - 1];
}
else
{
return maps[id - 1];
}
}
GetPreviousMap(maps, current)
{
id = 0;
if (!IsDefined(current))
{
current = GetCurrenttMap(maps);
}
for (i = 0; i < maps.size; i++)
{
if (maps[i] == current)
{
id = i;
break;
}
}
if (id == maps.size - 1)
{
return maps[0];
}
else
{
return maps[id + 1];
}
}
NextMapVote()
{
self endon("disconnect");
self SetClientCvar("ClientCommand", "-scores");
self OpenMenu(game["menu_clientcommand"]);
self CloseMenu(game["menu_clientcommand"]);
wait level.frame;
self SetClientCvar("ClientCommand", "");
self CloseMenu();
self CloseInGameMenu();
self.nextmap = SpawnStruct();
self.nextmap.current = GetCurrenttMap();
level.nextmap[self.nextmap.current]++;
self.nextmap.linebackground = NewClientHudElem(self);
self.nextmap.linebackground.sort = 6;
self.nextmap.linebackground.horzAlign = "center";
self.nextmap.linebackground.vertAlign = "middle";
self.nextmap.linebackground.x = -427;
self.nextmap.linebackground.y = -127;
self.nextmap.linebackground.color = (1, 1, 1);
self.nextmap.linebackground.alpha = 0;
self.nextmap.linebackground SetShader("white", 854, 254);
self.nextmap.background = NewClientHudElem(self);
self.nextmap.background.sort = 7;
self.nextmap.background.horzAlign = "center";
self.nextmap.background.vertAlign = "middle";
self.nextmap.background.x = -427;
self.nextmap.background.y = -240;
self.nextmap.background.color = (0, 0, 0);
self.nextmap.background.alpha = 0;
self.nextmap.background SetShader("white", 854, 480);
self.nextmap.background FadeOverTime(1);
self.nextmap.background.alpha = 0.8;
self.nextmap.linebackground FadeOverTime(1);
self.nextmap.linebackground.alpha = 0.7;
wait 1;
self.nextmap.centerbackground = NewClientHudElem(self);
self.nextmap.centerbackground.sort = 8;
self.nextmap.centerbackground.horzAlign = "center";
self.nextmap.centerbackground.vertAlign = "middle";
self.nextmap.centerbackground.x = -224;
self.nextmap.centerbackground.y = -127;
self.nextmap.centerbackground.color = (1, 0, 0);
self.nextmap.centerbackground.alpha = 0;
self.nextmap.centerbackground SetShader("white", 448, 254);
self.nextmap.leftbackground = NewClientHudElem(self);
self.nextmap.leftbackground.sort = 8;
self.nextmap.leftbackground.horzAlign = "center";
self.nextmap.leftbackground.vertAlign = "middle";
self.nextmap.leftbackground.x = -765;
self.nextmap.leftbackground.y = -127;
self.nextmap.leftbackground.color = (1, 0, 0);
self.nextmap.leftbackground.alpha = 0;
self.nextmap.leftbackground SetShader("white", 448, 254);
self.nextmap.rightbackground = NewClientHudElem(self);
self.nextmap.rightbackground.sort = 8;
self.nextmap.rightbackground.horzAlign = "center";
self.nextmap.rightbackground.vertAlign = "middle";
self.nextmap.rightbackground.x = 318;
self.nextmap.rightbackground.y = -127;
self.nextmap.rightbackground.color = (1, 0, 0);
self.nextmap.rightbackground.alpha = 0;
self.nextmap.rightbackground SetShader("white", 448, 254);
self.nextmap.tempbackground = NewClientHudElem(self);
self.nextmap.tempbackground.sort = 8;
self.nextmap.tempbackground.horzAlign = "center";
self.nextmap.tempbackground.vertAlign = "middle";
self.nextmap.tempbackground.x = -872;
self.nextmap.tempbackground.y = -127;
self.nextmap.tempbackground.color = (1, 0, 0);
self.nextmap.tempbackground.alpha = 0;
self.nextmap.tempbackground SetShader("white", 448, 254);
self.nextmap.center = NewClientHudElem(self);
self.nextmap.center.sort = 10;
self.nextmap.center.horzAlign = "center";
self.nextmap.center.vertAlign = "middle";
self.nextmap.center.x = -222;
self.nextmap.center.y = -490;
self.nextmap.center SetShader("loadscreen_" + self.nextmap.current, 444, 250);
self.nextmap.center MoveOverTime(1);
self.nextmap.center.y = -125;
self.nextmap.left = NewClientHudElem(self);
self.nextmap.left.sort = 10;
self.nextmap.left.horzAlign = "center";
self.nextmap.left.vertAlign = "middle";
self.nextmap.left.x = -871;
self.nextmap.left.y = -125;
self.nextmap.left SetShader("loadscreen_" + GetPreviousMap(level.nextmap["maps"], self.nextmap.current), 444, 250);
self.nextmap.left MoveOverTime(1);
self.nextmap.left.x = -764;
self.nextmap.right = NewClientHudElem(self);
self.nextmap.right.sort = 10;
self.nextmap.right.horzAlign = "center";
self.nextmap.right.vertAlign = "middle";
self.nextmap.right.x = 427;
self.nextmap.right.y = -125;
self.nextmap.right SetShader("loadscreen_" + GetNextMap(level.nextmap["maps"], self.nextmap.current), 444, 250);
self.nextmap.right MoveOverTime(1);
self.nextmap.right.x = 320;
self.nextmap.temp = NewClientHudElem(self);
self.nextmap.temp.sort = 10;
self.nextmap.temp.horzAlign = "center";
self.nextmap.temp.vertAlign = "middle";
self.nextmap.temp.y = -125;
self.nextmap.timeleft = NewClientHudElem(self);
self.nextmap.timeleft.sort = 10;
self.nextmap.timeleft.horzAlign = "center";
self.nextmap.timeleft.vertAlign = "middle";
self.nextmap.timeleft.alignX = "center";
self.nextmap.timeleft.alignY = "middle";
self.nextmap.timeleft.x = 0;
self.nextmap.timeleft.y = -201.6;
self.nextmap.timeleft.font = "default";
self.nextmap.timeleft.fontScale = 2;
self.nextmap.timeleft.color = (1, 1, 1);
self.nextmap.timeleft.alpha = 0;
self.nextmap.timeleft SetText(game["timeleft"]);
self.nextmap.clock = NewClientHudElem(self);
self.nextmap.clock.sort = 10;
self.nextmap.clock.horzAlign = "center";
self.nextmap.clock.vertAlign = "middle";
self.nextmap.clock.alignX = "center";
self.nextmap.clock.alignY = "middle";
self.nextmap.clock.x = 0;
self.nextmap.clock.y = -182.5;
self.nextmap.clock.font = "default";
self.nextmap.clock.fontScale = 2;
self.nextmap.clock.color = (1, 0, 0);
self.nextmap.clock.alpha = 0;
self.nextmap.hintleft = NewClientHudElem(self);
self.nextmap.hintleft.sort = 10;
self.nextmap.hintleft.horzAlign = "center";
self.nextmap.hintleft.vertAlign = "middle";
self.nextmap.hintleft.alignX = "left";
self.nextmap.hintleft.alignY = "middle";
self.nextmap.hintleft.x = -320;
self.nextmap.hintleft.y = -163.3;
self.nextmap.hintleft.font = "default";
self.nextmap.hintleft.fontScale = 2;
self.nextmap.hintleft.color = (1, 1, 1);
self.nextmap.hintleft.alpha = 0;
self.nextmap.hintleft SetText(game["hintleft"]);
self.nextmap.hintright = NewClientHudElem(self);
self.nextmap.hintright.sort = 10;
self.nextmap.hintright.horzAlign = "center";
self.nextmap.hintright.vertAlign = "middle";
self.nextmap.hintright.alignX = "right";
self.nextmap.hintright.alignY = "middle";
self.nextmap.hintright.x = 320;
self.nextmap.hintright.y = -163.3;
self.nextmap.hintright.font = "default";
self.nextmap.hintright.fontScale = 2;
self.nextmap.hintright.color = (1, 1, 1);
self.nextmap.hintright.alpha = 0;
self.nextmap.hintright SetText(game["hintright"]);
self.nextmap.vote = NewClientHudElem(self);
self.nextmap.vote.sort = 10;
self.nextmap.vote.horzAlign = "center";
self.nextmap.vote.vertAlign = "middle";
self.nextmap.vote.alignX = "center";
self.nextmap.vote.alignY = "middle";
self.nextmap.vote.x = 0;
self.nextmap.vote.y = 182.5;
self.nextmap.vote.font = "default";
self.nextmap.vote.fontScale = 2;
self.nextmap.vote.color = (1, 1, 1);
self.nextmap.vote.alpha = 0;
self.nextmap.vote.label = game[self.nextmap.current];
self.nextmap.vote SetValue(level.nextmap[self.nextmap.current]);
wait 1;
self.nextmap.centerbackground FadeOverTime(1);
self.nextmap.centerbackground.alpha = 1;
self.nextmap.leftbackground FadeOverTime(1);
self.nextmap.leftbackground.alpha = 1;
self.nextmap.rightbackground FadeOverTime(1);
self.nextmap.rightbackground.alpha = 1;
self.nextmap.tempbackground FadeOverTime(1);
self.nextmap.tempbackground.alpha = 1;
self.nextmap.clock SetTenthsTimer(level.nextmap["time"]);
self.nextmap.clock FadeOverTime(1);
self.nextmap.clock.alpha = 1;
self.nextmap.timeleft FadeOverTime(1);
self.nextmap.timeleft.alpha = 1;
self.nextmap.hintleft FadeOverTime(1);
self.nextmap.hintleft.alpha = 1;
self.nextmap.hintright FadeOverTime(1);
self.nextmap.hintright.alpha = 1;
self.nextmap.vote FadeOverTime(1);
self.nextmap.vote.alpha = 1;
temp = NewClientHudElem(self);
attackbutton = false;
endtime = GetTime() + level.nextmap["time"] * 1000;
while (endtime > GetTime())
{
self.nextmap.vote SetValue(level.nextmap[self.nextmap.current]);
aimbutton1 = self AimButtonPressed();
wait level.frame;
aimbutton2 = self AimButtonPressed();
if (aimbutton1 != aimbutton2)
{
self PlayLocalSound("mouse_click");
level.nextmap[self.nextmap.current]--;
self.nextmap.current = GetPreviousMap(level.nextmap["maps"], self.nextmap.current);
level.nextmap[self.nextmap.current]++;
self.nextmap.vote FadeOverTime(0.5);
self.nextmap.vote.alpha = 0;
self.nextmap.temp.x = -871;
self.nextmap.tempbackground.x = -872;
self.nextmap.temp SetShader("loadscreen_" + GetPreviousMap(level.nextmap["maps"], self.nextmap.current), 444, 250);
self.nextmap.left MoveOverTime(1);
self.nextmap.left.x = -222;
self.nextmap.center MoveOverTime(1);
self.nextmap.center.x = 320;
self.nextmap.right MoveOverTime(107 / 444);
self.nextmap.right.x = 427;
self.nextmap.leftbackground MoveOverTime(1);
self.nextmap.leftbackground.x = -224;
self.nextmap.centerbackground MoveOverTime(1);
self.nextmap.centerbackground.x = 318;
self.nextmap.rightbackground MoveOverTime(107 / 444);
self.nextmap.rightbackground.x = 425;
wait 0.5;
self.nextmap.vote.label = game[self.nextmap.current];
self.nextmap.vote SetValue(level.nextmap[self.nextmap.current]);
self.nextmap.vote FadeOverTime(0.5);
self.nextmap.vote.alpha = 1;
wait (1 - 107 / 444) - 0.5;
self.nextmap.temp MoveOverTime(107 / 444);
self.nextmap.temp.x = -764;
self.nextmap.tempbackground MoveOverTime(107 / 444);
self.nextmap.tempbackground.x = -766;
wait 107 / 444;
temp = self.nextmap.right;
self.nextmap.right = self.nextmap.center;
self.nextmap.center = self.nextmap.left;
self.nextmap.left = self.nextmap.temp;
self.nextmap.temp = temp;
temp = self.nextmap.rightbackground;
self.nextmap.rightbackground = self.nextmap.centerbackground;
self.nextmap.centerbackground = self.nextmap.leftbackground;
self.nextmap.leftbackground = self.nextmap.tempbackground;
self.nextmap.tempbackground = temp;
}
else if (self AttackButtonPressed() && !attackbutton)
{
IPrintLnBold(self.nextmap.current);
attackbutton = true;
self PlayLocalSound("mouse_click");
level.nextmap[self.nextmap.current]--;
self.nextmap.current = GetNextMap(level.nextmap["maps"], self.nextmap.current);
level.nextmap[self.nextmap.current]++;
self.nextmap.vote FadeOverTime(0.5);
self.nextmap.vote.alpha = 0;
self.nextmap.temp.x = 427;
self.nextmap.tempbackground.x = 425;
self.nextmap.temp SetShader("loadscreen_" + GetNextMap(level.nextmap["maps"], self.nextmap.current), 444, 250);
self.nextmap.left MoveOverTime(107 / 444);
self.nextmap.left.x = -871;
self.nextmap.center MoveOverTime(1);
self.nextmap.center.x = -764;
self.nextmap.right MoveOverTime(1);
self.nextmap.right.x = -222;
self.nextmap.leftbackground MoveOverTime(107 / 444);
self.nextmap.leftbackground.x = -872;
self.nextmap.centerbackground MoveOverTime(1);
self.nextmap.centerbackground.x = -766;
self.nextmap.rightbackground MoveOverTime(1);
self.nextmap.rightbackground.x = -224;
wait 0.5;
self.nextmap.vote.label = game[self.nextmap.current];
self.nextmap.vote SetValue(level.nextmap[self.nextmap.current]);
self.nextmap.vote FadeOverTime(0.5);
self.nextmap.vote.alpha = 1;
wait (1 - 107 / 444) - 0.5;
self.nextmap.temp MoveOverTime(107 / 444);
self.nextmap.temp.x = 320;
self.nextmap.tempbackground MoveOverTime(107 / 444);
self.nextmap.tempbackground.x = 318;
wait 107 / 444;
temp = self.nextmap.left;
self.nextmap.left = self.nextmap.center;
self.nextmap.center = self.nextmap.right;
self.nextmap.right = self.nextmap.temp;
self.nextmap.temp = temp;
temp = self.nextmap.leftbackground;
self.nextmap.leftbackground = self.nextmap.centerbackground;
self.nextmap.centerbackground = self.nextmap.rightbackground;
self.nextmap.rightbackground = self.nextmap.tempbackground;
self.nextmap.tempbackground = temp;
}
else if (!self AttackButtonPressed() && attackbutton)
{
attackbutton = false;
}
}
self.nextmap.centerbackground FadeOverTime(1);
self.nextmap.centerbackground.alpha = 0;
self.nextmap.leftbackground FadeOverTime(1);
self.nextmap.leftbackground.alpha = 0;
self.nextmap.rightbackground FadeOverTime(1);
self.nextmap.rightbackground.alpha = 0;
self.nextmap.tempbackground FadeOverTime(1);
self.nextmap.tempbackground.alpha = 0;
self.nextmap.timeleft FadeOverTime(1);
self.nextmap.timeleft.alpha = 0;
self.nextmap.clock FadeOverTime(1);
self.nextmap.clock.alpha = 0;
self.nextmap.hintleft FadeOverTime(1);
self.nextmap.hintleft.alpha = 0;
self.nextmap.hintright FadeOverTime(1);
self.nextmap.hintright.alpha = 0;
self.nextmap.vote FadeOverTime(1);
self.nextmap.vote.alpha = 0;
wait 1;
self.nextmap.center MoveOverTime(1);
self.nextmap.center.y = 490;
self.nextmap.left MoveOverTime(1);
self.nextmap.left.x = -871;
self.nextmap.right MoveOverTime(1);
self.nextmap.right.x = 427;
wait 1;
self.nextmap.linebackground FadeOverTime(1);
self.nextmap.linebackground.alpha = 0;
self.nextmap.background FadeOverTime(1);
self.nextmap.background.alpha = 0;
wait 1;
self.nextmap.linebackground Destroy();
self.nextmap.background Destroy();
self.nextmap.centerbackground Destroy();
self.nextmap.leftbackground Destroy();
self.nextmap.rightbackground Destroy();
self.nextmap.tempbackground Destroy();
self.nextmap.left Destroy();
self.nextmap.right Destroy();
self.nextmap.temp Destroy();
self.nextmap.timeleft Destroy();
self.nextmap.clock Destroy();
self.nextmap.hintleft Destroy();
self.nextmap.hintright Destroy();
self.nextmap.vote Destroy();
temp Destroy();
level notify("nextmap_vote_completed");
level waittill("nextmap_vote_selected");
self.nextmap.center.sort = 10;
self.nextmap.center.x = -427;
self.nextmap.center.y = -720;
self.nextmap.center SetShader("loadscreen_" + level.nextmap["nextmap"], 854, 480);
self.nextmap.center MoveOverTime(3);
self.nextmap.center.y = -240;
}
UpdateNextMapVote()
{
count = 0;
players = GetEntArray("player", "classname");
for (i = 0; i < players.size; i++)
{
if (players[i] != self && IsDefined(self.nextmap))
{
count++;
break;
}
}
if (IsDefined(self.nextmap))
{
level.nextmap[self.nextmap.current]--;
if (count == 0)
{
level.nextmap[GetCvar("mapname")] = 65;
level notify("nextmap_vote_completed");
}
}
}
NextMapVoteSpawn()
{
self endon("disconnect");
if (game["state"] == "intermission")
{
while (!IsDefined(self.nextmap))
{
wait level.frame;
}
These are mod specific functions, basically it clears the gametype specific huds, so during the vote players have "clear" screen. If you want the same you have to create your own functions.
//[[level.pam_hud]]("kill_all");
//ClearTeamHud();
//KillExistingPlayerDisplay();
//self notify("end_monitor_movement");
return true;
}
return false;
}
In EndMap function you have to place the call logic, I use a fully modified zpam 2.07 so my SD.gsc/Endmap function is the following, the logis is between the /*START*/ and /*END*/ tags.
EndMap()
{
game["state"] = "intermission";
level notify("intermission");
if (IsDefined(level.bombmodel))
{
level.bombmodel StopLoopSound();
}
if (IsDefined(level.clock))
{
level.clock Destroy();
}
players = GetEntArray("player", "classname");
for(i = 0; i < players.size; i++)
{
players[i] CloseMenu();
players[i] CloseInGameMenu();
players[i] SpawnIntermission();
}
wait level.fps_multiplier * 5;
/*START*/
if (GetCvar("scr_nextmap") == "" || GetCvarInt("scr_nextmap") > 0)
{
level.nextmap = [];
if (GetCvar("scr_nextmap_maps") != "")
{
bugfix = GetCvar("scr_nextmap_maps");
level.nextmap["maps"] = StrTok(bugfix, ",");
}
else
{
level.nextmap["maps"] = StrTok("mp_breakout,mp_brecourt,mp_burgundy,mp_carentan,mp _dawnville,mp_decoy,mp_downtown,mp_farmhouse,mp_ha rbor,mp_leningrad,mp_matmata,mp_railyard,mp_rhine, mp_toujane,mp_trainstation", ",");
}
if (GetCvar("scr_nextmap_time") != "")
{
level.nextmap["time"] = GetCvarInt("scr_nextmap_time");
}
else
{
level.nextmap["time"] = 60;
}
for (i = 0; i < level.nextmap["maps"].size; i++)
{
level.nextmap[level.nextmap["maps"][i]] = 0;
}
players = GetEntArray("player", "classname");
count = 0;
for (i = 0; i < players.size; i++)
{
if (IsDefined(players[i].pers["team"]) && players[i].pers["team"] != "spectator")
{
players[i] Hide();
players[i].spawned = undefined;
players[i] SpawnPlayer();
players[i] FreezeControls(true);
players[i] DisableWeapon();
players[i] thread NextMapVote();
count++;
}
}
if (count != 0)
{
level waittill("nextmap_vote_completed");
count = level.nextmap[level.nextmap["maps"][0]];
for (i = 0; i < level.nextmap["maps"].size; i++)
{
if (level.nextmap[level.nextmap["maps"][i]] > count)
{
count = level.nextmap[level.nextmap["maps"][i]];
}
}
nextmaps = [];
for (i = 0; i < level.nextmap["maps"].size; i++)
{
if (level.nextmap[level.nextmap["maps"][i]] == count)
{
nextmaps[nextmaps.size] = level.nextmap["maps"][i];
}
}
level.nextmap["nextmap"] = nextmaps[RandomIntRange(0, nextmaps.size)];
wait 1;
level notify("nextmap_vote_selected");
wait 4;
Map(level.nextmap["nextmap"], false);
}
else
{
ExitLevel(false);
}
}
/*END*/
ExitLevel(false);
}
In Callback_PlayerDisconnect you have to call the UpdateNextMapVote function, so place it.
UpdateNextMapVote();
In Callback_PlayerConnect call the following OnPlayerSpawned function.
OnPlayerSpawned()
{
self endon("disconnect");
for(;;)
{
self waittill("spawned_player");
NextMapVoteSpawn();
}
}
I would like to share my nextmap vote system, you can freely use or modify it just use credit. You can watch a demo here:
https://www.youtube.com/watch?v=11bpcAUq87Q&hd=1
You can config a few paramter like selectable maps, time limit and so one, add these lines to your server's cfg.
set scr_nextmap "1"
set scr_nextmap_maps "mp_burgundy,mp_carentan,mp_dawnville,mp_toujane"
set scr_nextmap_time "90" //seconds
First thing first, you have to precache shaders and strings.
game["timeleft"] = &"Remaining time";
game["hintleft"] = &"<-- [{+attack}]";
game["hintright"] = &"[{toggleads}], [{+speed}] -->";
game["mp_breakout"] = &"Villers-Bocage^1(^7&&1^1)";
game["mp_brecourt"] = &"Brecourt^1(^7&&1^1)";
game["mp_burgundy"] = &"Burgundy^1(^7&&1^1)";
game["mp_carentan"] = &"Carentan^1(^7&&1^1)";
game["mp_dawnville"] = &"St. Mere Eglise^1(^7&&1^1)";
game["mp_decoy"] = &"El Alamein^1(^7&&1^1)";
game["mp_downtown"] = &"Moscow^1(^7&&1^1)";
game["mp_farmhouse"] = &"Beltot^1(^7&&1^1)";
game["mp_harbor"] = &"Rostov^1(^7&&1^1)";
game["mp_leningrad"] = &"Leningrad^1(^7&&1^1)";
game["mp_matmata"] = &"Matmata^1(^7&&1^1)";
game["mp_railyard"] = &"Stalingrad^1(^7&&1^1)";
game["mp_rhine"] = &"Wallendar^1(^7&&1^1)";
game["mp_toujane"] = &"Toujane^1(^7&&1^1)";
game["mp_trainstation"] = &"Caen^1(^7&&1^1)";
PreCacheString(game["timeleft"]);
PreCacheString(game["hintleft"]);
PreCacheString(game["hintright"]);
PreCacheString(game["mp_breakout"]);
PreCacheString(game["mp_brecourt"]);
PreCacheString(game["mp_burgundy"]);
PreCacheString(game["mp_carentan"]);
PreCacheString(game["mp_dawnville"]);
PreCacheString(game["mp_decoy"]);
PreCacheString(game["mp_downtown"]);
PreCacheString(game["mp_farmhouse"]);
PreCacheString(game["mp_harbor"]);
PreCacheString(game["mp_leningrad"]);
PreCacheString(game["mp_matmata"]);
PreCacheString(game["mp_railyard"]);
PreCacheString(game["mp_rhine"]);
PreCacheString(game["mp_toujane"]);
PreCacheString(game["mp_trainstation"]);
PrecacheShader("black");
PrecacheShader("white");
PrecacheShader("loadscreen_mp_breakout");
PrecacheShader("loadscreen_mp_brecourt");
PrecacheShader("loadscreen_mp_burgundy");
PrecacheShader("loadscreen_mp_carentan");
PrecacheShader("loadscreen_mp_dawnville");
PrecacheShader("loadscreen_mp_decoy");
PrecacheShader("loadscreen_mp_downtown");
PrecacheShader("loadscreen_mp_farmhouse");
PrecacheShader("loadscreen_mp_harbor");
PrecacheShader("loadscreen_mp_leningrad");
PrecacheShader("loadscreen_mp_matmata");
PrecacheShader("loadscreen_mp_railyard");
PrecacheShader("loadscreen_mp_rhine");
PrecacheShader("loadscreen_mp_toujane");
PrecacheShader("loadscreen_mp_trainstation");
I used it after the scorebord part in the gametype/endmap function, so firstly I need to hide the scoreboard for each player. I created a menu for it.
game["menu_clientcommand"] = "ClientCommand";
PrecacheMenu(game["menu_clientcommand"]);
So there is a menu file, called "ClientCommand.menu"
#include "ui_mp/menudef.h"
MenuDef
{
Name "ClientCommand"
Rect 0 0 1 1
Visible 0
Fullscreen 0
OnOpen
{
exec "vstr ClientCommand";
close ClientCommand;
}
}
Finally here is the full source
GetCurrenttMap(maps)
{
valid = false;
current = GetCvar("mapname");
for (i = 0; i < maps.size; i++)
{
if (maps[i] == current)
{
valid = true;
break;
}
}
if (!valid)
{
current = maps[0];
}
return current;
}
GetNextMap(maps, current)
{
id = 0;
if (!IsDefined(current))
{
current = GetCurrenttMap(maps);
}
for (i = 0; i < maps.size; i++)
{
if (maps[i] == current)
{
id = i;
break;
}
}
if (id == 0)
{
return maps[maps.size - 1];
}
else
{
return maps[id - 1];
}
}
GetPreviousMap(maps, current)
{
id = 0;
if (!IsDefined(current))
{
current = GetCurrenttMap(maps);
}
for (i = 0; i < maps.size; i++)
{
if (maps[i] == current)
{
id = i;
break;
}
}
if (id == maps.size - 1)
{
return maps[0];
}
else
{
return maps[id + 1];
}
}
NextMapVote()
{
self endon("disconnect");
self SetClientCvar("ClientCommand", "-scores");
self OpenMenu(game["menu_clientcommand"]);
self CloseMenu(game["menu_clientcommand"]);
wait level.frame;
self SetClientCvar("ClientCommand", "");
self CloseMenu();
self CloseInGameMenu();
self.nextmap = SpawnStruct();
self.nextmap.current = GetCurrenttMap();
level.nextmap[self.nextmap.current]++;
self.nextmap.linebackground = NewClientHudElem(self);
self.nextmap.linebackground.sort = 6;
self.nextmap.linebackground.horzAlign = "center";
self.nextmap.linebackground.vertAlign = "middle";
self.nextmap.linebackground.x = -427;
self.nextmap.linebackground.y = -127;
self.nextmap.linebackground.color = (1, 1, 1);
self.nextmap.linebackground.alpha = 0;
self.nextmap.linebackground SetShader("white", 854, 254);
self.nextmap.background = NewClientHudElem(self);
self.nextmap.background.sort = 7;
self.nextmap.background.horzAlign = "center";
self.nextmap.background.vertAlign = "middle";
self.nextmap.background.x = -427;
self.nextmap.background.y = -240;
self.nextmap.background.color = (0, 0, 0);
self.nextmap.background.alpha = 0;
self.nextmap.background SetShader("white", 854, 480);
self.nextmap.background FadeOverTime(1);
self.nextmap.background.alpha = 0.8;
self.nextmap.linebackground FadeOverTime(1);
self.nextmap.linebackground.alpha = 0.7;
wait 1;
self.nextmap.centerbackground = NewClientHudElem(self);
self.nextmap.centerbackground.sort = 8;
self.nextmap.centerbackground.horzAlign = "center";
self.nextmap.centerbackground.vertAlign = "middle";
self.nextmap.centerbackground.x = -224;
self.nextmap.centerbackground.y = -127;
self.nextmap.centerbackground.color = (1, 0, 0);
self.nextmap.centerbackground.alpha = 0;
self.nextmap.centerbackground SetShader("white", 448, 254);
self.nextmap.leftbackground = NewClientHudElem(self);
self.nextmap.leftbackground.sort = 8;
self.nextmap.leftbackground.horzAlign = "center";
self.nextmap.leftbackground.vertAlign = "middle";
self.nextmap.leftbackground.x = -765;
self.nextmap.leftbackground.y = -127;
self.nextmap.leftbackground.color = (1, 0, 0);
self.nextmap.leftbackground.alpha = 0;
self.nextmap.leftbackground SetShader("white", 448, 254);
self.nextmap.rightbackground = NewClientHudElem(self);
self.nextmap.rightbackground.sort = 8;
self.nextmap.rightbackground.horzAlign = "center";
self.nextmap.rightbackground.vertAlign = "middle";
self.nextmap.rightbackground.x = 318;
self.nextmap.rightbackground.y = -127;
self.nextmap.rightbackground.color = (1, 0, 0);
self.nextmap.rightbackground.alpha = 0;
self.nextmap.rightbackground SetShader("white", 448, 254);
self.nextmap.tempbackground = NewClientHudElem(self);
self.nextmap.tempbackground.sort = 8;
self.nextmap.tempbackground.horzAlign = "center";
self.nextmap.tempbackground.vertAlign = "middle";
self.nextmap.tempbackground.x = -872;
self.nextmap.tempbackground.y = -127;
self.nextmap.tempbackground.color = (1, 0, 0);
self.nextmap.tempbackground.alpha = 0;
self.nextmap.tempbackground SetShader("white", 448, 254);
self.nextmap.center = NewClientHudElem(self);
self.nextmap.center.sort = 10;
self.nextmap.center.horzAlign = "center";
self.nextmap.center.vertAlign = "middle";
self.nextmap.center.x = -222;
self.nextmap.center.y = -490;
self.nextmap.center SetShader("loadscreen_" + self.nextmap.current, 444, 250);
self.nextmap.center MoveOverTime(1);
self.nextmap.center.y = -125;
self.nextmap.left = NewClientHudElem(self);
self.nextmap.left.sort = 10;
self.nextmap.left.horzAlign = "center";
self.nextmap.left.vertAlign = "middle";
self.nextmap.left.x = -871;
self.nextmap.left.y = -125;
self.nextmap.left SetShader("loadscreen_" + GetPreviousMap(level.nextmap["maps"], self.nextmap.current), 444, 250);
self.nextmap.left MoveOverTime(1);
self.nextmap.left.x = -764;
self.nextmap.right = NewClientHudElem(self);
self.nextmap.right.sort = 10;
self.nextmap.right.horzAlign = "center";
self.nextmap.right.vertAlign = "middle";
self.nextmap.right.x = 427;
self.nextmap.right.y = -125;
self.nextmap.right SetShader("loadscreen_" + GetNextMap(level.nextmap["maps"], self.nextmap.current), 444, 250);
self.nextmap.right MoveOverTime(1);
self.nextmap.right.x = 320;
self.nextmap.temp = NewClientHudElem(self);
self.nextmap.temp.sort = 10;
self.nextmap.temp.horzAlign = "center";
self.nextmap.temp.vertAlign = "middle";
self.nextmap.temp.y = -125;
self.nextmap.timeleft = NewClientHudElem(self);
self.nextmap.timeleft.sort = 10;
self.nextmap.timeleft.horzAlign = "center";
self.nextmap.timeleft.vertAlign = "middle";
self.nextmap.timeleft.alignX = "center";
self.nextmap.timeleft.alignY = "middle";
self.nextmap.timeleft.x = 0;
self.nextmap.timeleft.y = -201.6;
self.nextmap.timeleft.font = "default";
self.nextmap.timeleft.fontScale = 2;
self.nextmap.timeleft.color = (1, 1, 1);
self.nextmap.timeleft.alpha = 0;
self.nextmap.timeleft SetText(game["timeleft"]);
self.nextmap.clock = NewClientHudElem(self);
self.nextmap.clock.sort = 10;
self.nextmap.clock.horzAlign = "center";
self.nextmap.clock.vertAlign = "middle";
self.nextmap.clock.alignX = "center";
self.nextmap.clock.alignY = "middle";
self.nextmap.clock.x = 0;
self.nextmap.clock.y = -182.5;
self.nextmap.clock.font = "default";
self.nextmap.clock.fontScale = 2;
self.nextmap.clock.color = (1, 0, 0);
self.nextmap.clock.alpha = 0;
self.nextmap.hintleft = NewClientHudElem(self);
self.nextmap.hintleft.sort = 10;
self.nextmap.hintleft.horzAlign = "center";
self.nextmap.hintleft.vertAlign = "middle";
self.nextmap.hintleft.alignX = "left";
self.nextmap.hintleft.alignY = "middle";
self.nextmap.hintleft.x = -320;
self.nextmap.hintleft.y = -163.3;
self.nextmap.hintleft.font = "default";
self.nextmap.hintleft.fontScale = 2;
self.nextmap.hintleft.color = (1, 1, 1);
self.nextmap.hintleft.alpha = 0;
self.nextmap.hintleft SetText(game["hintleft"]);
self.nextmap.hintright = NewClientHudElem(self);
self.nextmap.hintright.sort = 10;
self.nextmap.hintright.horzAlign = "center";
self.nextmap.hintright.vertAlign = "middle";
self.nextmap.hintright.alignX = "right";
self.nextmap.hintright.alignY = "middle";
self.nextmap.hintright.x = 320;
self.nextmap.hintright.y = -163.3;
self.nextmap.hintright.font = "default";
self.nextmap.hintright.fontScale = 2;
self.nextmap.hintright.color = (1, 1, 1);
self.nextmap.hintright.alpha = 0;
self.nextmap.hintright SetText(game["hintright"]);
self.nextmap.vote = NewClientHudElem(self);
self.nextmap.vote.sort = 10;
self.nextmap.vote.horzAlign = "center";
self.nextmap.vote.vertAlign = "middle";
self.nextmap.vote.alignX = "center";
self.nextmap.vote.alignY = "middle";
self.nextmap.vote.x = 0;
self.nextmap.vote.y = 182.5;
self.nextmap.vote.font = "default";
self.nextmap.vote.fontScale = 2;
self.nextmap.vote.color = (1, 1, 1);
self.nextmap.vote.alpha = 0;
self.nextmap.vote.label = game[self.nextmap.current];
self.nextmap.vote SetValue(level.nextmap[self.nextmap.current]);
wait 1;
self.nextmap.centerbackground FadeOverTime(1);
self.nextmap.centerbackground.alpha = 1;
self.nextmap.leftbackground FadeOverTime(1);
self.nextmap.leftbackground.alpha = 1;
self.nextmap.rightbackground FadeOverTime(1);
self.nextmap.rightbackground.alpha = 1;
self.nextmap.tempbackground FadeOverTime(1);
self.nextmap.tempbackground.alpha = 1;
self.nextmap.clock SetTenthsTimer(level.nextmap["time"]);
self.nextmap.clock FadeOverTime(1);
self.nextmap.clock.alpha = 1;
self.nextmap.timeleft FadeOverTime(1);
self.nextmap.timeleft.alpha = 1;
self.nextmap.hintleft FadeOverTime(1);
self.nextmap.hintleft.alpha = 1;
self.nextmap.hintright FadeOverTime(1);
self.nextmap.hintright.alpha = 1;
self.nextmap.vote FadeOverTime(1);
self.nextmap.vote.alpha = 1;
temp = NewClientHudElem(self);
attackbutton = false;
endtime = GetTime() + level.nextmap["time"] * 1000;
while (endtime > GetTime())
{
self.nextmap.vote SetValue(level.nextmap[self.nextmap.current]);
aimbutton1 = self AimButtonPressed();
wait level.frame;
aimbutton2 = self AimButtonPressed();
if (aimbutton1 != aimbutton2)
{
self PlayLocalSound("mouse_click");
level.nextmap[self.nextmap.current]--;
self.nextmap.current = GetPreviousMap(level.nextmap["maps"], self.nextmap.current);
level.nextmap[self.nextmap.current]++;
self.nextmap.vote FadeOverTime(0.5);
self.nextmap.vote.alpha = 0;
self.nextmap.temp.x = -871;
self.nextmap.tempbackground.x = -872;
self.nextmap.temp SetShader("loadscreen_" + GetPreviousMap(level.nextmap["maps"], self.nextmap.current), 444, 250);
self.nextmap.left MoveOverTime(1);
self.nextmap.left.x = -222;
self.nextmap.center MoveOverTime(1);
self.nextmap.center.x = 320;
self.nextmap.right MoveOverTime(107 / 444);
self.nextmap.right.x = 427;
self.nextmap.leftbackground MoveOverTime(1);
self.nextmap.leftbackground.x = -224;
self.nextmap.centerbackground MoveOverTime(1);
self.nextmap.centerbackground.x = 318;
self.nextmap.rightbackground MoveOverTime(107 / 444);
self.nextmap.rightbackground.x = 425;
wait 0.5;
self.nextmap.vote.label = game[self.nextmap.current];
self.nextmap.vote SetValue(level.nextmap[self.nextmap.current]);
self.nextmap.vote FadeOverTime(0.5);
self.nextmap.vote.alpha = 1;
wait (1 - 107 / 444) - 0.5;
self.nextmap.temp MoveOverTime(107 / 444);
self.nextmap.temp.x = -764;
self.nextmap.tempbackground MoveOverTime(107 / 444);
self.nextmap.tempbackground.x = -766;
wait 107 / 444;
temp = self.nextmap.right;
self.nextmap.right = self.nextmap.center;
self.nextmap.center = self.nextmap.left;
self.nextmap.left = self.nextmap.temp;
self.nextmap.temp = temp;
temp = self.nextmap.rightbackground;
self.nextmap.rightbackground = self.nextmap.centerbackground;
self.nextmap.centerbackground = self.nextmap.leftbackground;
self.nextmap.leftbackground = self.nextmap.tempbackground;
self.nextmap.tempbackground = temp;
}
else if (self AttackButtonPressed() && !attackbutton)
{
IPrintLnBold(self.nextmap.current);
attackbutton = true;
self PlayLocalSound("mouse_click");
level.nextmap[self.nextmap.current]--;
self.nextmap.current = GetNextMap(level.nextmap["maps"], self.nextmap.current);
level.nextmap[self.nextmap.current]++;
self.nextmap.vote FadeOverTime(0.5);
self.nextmap.vote.alpha = 0;
self.nextmap.temp.x = 427;
self.nextmap.tempbackground.x = 425;
self.nextmap.temp SetShader("loadscreen_" + GetNextMap(level.nextmap["maps"], self.nextmap.current), 444, 250);
self.nextmap.left MoveOverTime(107 / 444);
self.nextmap.left.x = -871;
self.nextmap.center MoveOverTime(1);
self.nextmap.center.x = -764;
self.nextmap.right MoveOverTime(1);
self.nextmap.right.x = -222;
self.nextmap.leftbackground MoveOverTime(107 / 444);
self.nextmap.leftbackground.x = -872;
self.nextmap.centerbackground MoveOverTime(1);
self.nextmap.centerbackground.x = -766;
self.nextmap.rightbackground MoveOverTime(1);
self.nextmap.rightbackground.x = -224;
wait 0.5;
self.nextmap.vote.label = game[self.nextmap.current];
self.nextmap.vote SetValue(level.nextmap[self.nextmap.current]);
self.nextmap.vote FadeOverTime(0.5);
self.nextmap.vote.alpha = 1;
wait (1 - 107 / 444) - 0.5;
self.nextmap.temp MoveOverTime(107 / 444);
self.nextmap.temp.x = 320;
self.nextmap.tempbackground MoveOverTime(107 / 444);
self.nextmap.tempbackground.x = 318;
wait 107 / 444;
temp = self.nextmap.left;
self.nextmap.left = self.nextmap.center;
self.nextmap.center = self.nextmap.right;
self.nextmap.right = self.nextmap.temp;
self.nextmap.temp = temp;
temp = self.nextmap.leftbackground;
self.nextmap.leftbackground = self.nextmap.centerbackground;
self.nextmap.centerbackground = self.nextmap.rightbackground;
self.nextmap.rightbackground = self.nextmap.tempbackground;
self.nextmap.tempbackground = temp;
}
else if (!self AttackButtonPressed() && attackbutton)
{
attackbutton = false;
}
}
self.nextmap.centerbackground FadeOverTime(1);
self.nextmap.centerbackground.alpha = 0;
self.nextmap.leftbackground FadeOverTime(1);
self.nextmap.leftbackground.alpha = 0;
self.nextmap.rightbackground FadeOverTime(1);
self.nextmap.rightbackground.alpha = 0;
self.nextmap.tempbackground FadeOverTime(1);
self.nextmap.tempbackground.alpha = 0;
self.nextmap.timeleft FadeOverTime(1);
self.nextmap.timeleft.alpha = 0;
self.nextmap.clock FadeOverTime(1);
self.nextmap.clock.alpha = 0;
self.nextmap.hintleft FadeOverTime(1);
self.nextmap.hintleft.alpha = 0;
self.nextmap.hintright FadeOverTime(1);
self.nextmap.hintright.alpha = 0;
self.nextmap.vote FadeOverTime(1);
self.nextmap.vote.alpha = 0;
wait 1;
self.nextmap.center MoveOverTime(1);
self.nextmap.center.y = 490;
self.nextmap.left MoveOverTime(1);
self.nextmap.left.x = -871;
self.nextmap.right MoveOverTime(1);
self.nextmap.right.x = 427;
wait 1;
self.nextmap.linebackground FadeOverTime(1);
self.nextmap.linebackground.alpha = 0;
self.nextmap.background FadeOverTime(1);
self.nextmap.background.alpha = 0;
wait 1;
self.nextmap.linebackground Destroy();
self.nextmap.background Destroy();
self.nextmap.centerbackground Destroy();
self.nextmap.leftbackground Destroy();
self.nextmap.rightbackground Destroy();
self.nextmap.tempbackground Destroy();
self.nextmap.left Destroy();
self.nextmap.right Destroy();
self.nextmap.temp Destroy();
self.nextmap.timeleft Destroy();
self.nextmap.clock Destroy();
self.nextmap.hintleft Destroy();
self.nextmap.hintright Destroy();
self.nextmap.vote Destroy();
temp Destroy();
level notify("nextmap_vote_completed");
level waittill("nextmap_vote_selected");
self.nextmap.center.sort = 10;
self.nextmap.center.x = -427;
self.nextmap.center.y = -720;
self.nextmap.center SetShader("loadscreen_" + level.nextmap["nextmap"], 854, 480);
self.nextmap.center MoveOverTime(3);
self.nextmap.center.y = -240;
}
UpdateNextMapVote()
{
count = 0;
players = GetEntArray("player", "classname");
for (i = 0; i < players.size; i++)
{
if (players[i] != self && IsDefined(self.nextmap))
{
count++;
break;
}
}
if (IsDefined(self.nextmap))
{
level.nextmap[self.nextmap.current]--;
if (count == 0)
{
level.nextmap[GetCvar("mapname")] = 65;
level notify("nextmap_vote_completed");
}
}
}
NextMapVoteSpawn()
{
self endon("disconnect");
if (game["state"] == "intermission")
{
while (!IsDefined(self.nextmap))
{
wait level.frame;
}
These are mod specific functions, basically it clears the gametype specific huds, so during the vote players have "clear" screen. If you want the same you have to create your own functions.
//[[level.pam_hud]]("kill_all");
//ClearTeamHud();
//KillExistingPlayerDisplay();
//self notify("end_monitor_movement");
return true;
}
return false;
}
In EndMap function you have to place the call logic, I use a fully modified zpam 2.07 so my SD.gsc/Endmap function is the following, the logis is between the /*START*/ and /*END*/ tags.
EndMap()
{
game["state"] = "intermission";
level notify("intermission");
if (IsDefined(level.bombmodel))
{
level.bombmodel StopLoopSound();
}
if (IsDefined(level.clock))
{
level.clock Destroy();
}
players = GetEntArray("player", "classname");
for(i = 0; i < players.size; i++)
{
players[i] CloseMenu();
players[i] CloseInGameMenu();
players[i] SpawnIntermission();
}
wait level.fps_multiplier * 5;
/*START*/
if (GetCvar("scr_nextmap") == "" || GetCvarInt("scr_nextmap") > 0)
{
level.nextmap = [];
if (GetCvar("scr_nextmap_maps") != "")
{
bugfix = GetCvar("scr_nextmap_maps");
level.nextmap["maps"] = StrTok(bugfix, ",");
}
else
{
level.nextmap["maps"] = StrTok("mp_breakout,mp_brecourt,mp_burgundy,mp_carentan,mp _dawnville,mp_decoy,mp_downtown,mp_farmhouse,mp_ha rbor,mp_leningrad,mp_matmata,mp_railyard,mp_rhine, mp_toujane,mp_trainstation", ",");
}
if (GetCvar("scr_nextmap_time") != "")
{
level.nextmap["time"] = GetCvarInt("scr_nextmap_time");
}
else
{
level.nextmap["time"] = 60;
}
for (i = 0; i < level.nextmap["maps"].size; i++)
{
level.nextmap[level.nextmap["maps"][i]] = 0;
}
players = GetEntArray("player", "classname");
count = 0;
for (i = 0; i < players.size; i++)
{
if (IsDefined(players[i].pers["team"]) && players[i].pers["team"] != "spectator")
{
players[i] Hide();
players[i].spawned = undefined;
players[i] SpawnPlayer();
players[i] FreezeControls(true);
players[i] DisableWeapon();
players[i] thread NextMapVote();
count++;
}
}
if (count != 0)
{
level waittill("nextmap_vote_completed");
count = level.nextmap[level.nextmap["maps"][0]];
for (i = 0; i < level.nextmap["maps"].size; i++)
{
if (level.nextmap[level.nextmap["maps"][i]] > count)
{
count = level.nextmap[level.nextmap["maps"][i]];
}
}
nextmaps = [];
for (i = 0; i < level.nextmap["maps"].size; i++)
{
if (level.nextmap[level.nextmap["maps"][i]] == count)
{
nextmaps[nextmaps.size] = level.nextmap["maps"][i];
}
}
level.nextmap["nextmap"] = nextmaps[RandomIntRange(0, nextmaps.size)];
wait 1;
level notify("nextmap_vote_selected");
wait 4;
Map(level.nextmap["nextmap"], false);
}
else
{
ExitLevel(false);
}
}
/*END*/
ExitLevel(false);
}
In Callback_PlayerDisconnect you have to call the UpdateNextMapVote function, so place it.
UpdateNextMapVote();
In Callback_PlayerConnect call the following OnPlayerSpawned function.
OnPlayerSpawned()
{
self endon("disconnect");
for(;;)
{
self waittill("spawned_player");
NextMapVoteSpawn();
}
}