03-23-2011, 14:24
I have a problem with the code killingdyl. At the end of voting, the map restart (fast_restart) but does not change! Why?
Quote:MapVoteInit()
{
level.mapvote = [];
level.mapvote[0] = "mp_array";
level.mapvote[1] = "mp_cairo";
level.mapvote[2] = "mp_cosmodrome";
level.mapvote[3] = "mp_cracked";
level.mapvote[4] = "mp_crisis";
level.mapvote[5] = "mp_duga";
level.mapvote[6] = "mp_firingrange";
level.mapvote[7] = "mp_hanoi";
level.mapvote[8] = "mp_havoc";
level.mapvote[9] = "mp_mountain";
level.mapvote[10] = "mp_nuked";
level.mapvote[11] = "mp_radiation";
level.mapvote[12] = "mp_russianbase";
level.mapvote[13] = "mp_villa";
level.mapname = [];
level.mapname[0] = "Array";
level.mapname[1] = "Havana";
level.mapname[2] = "Launch";
level.mapname[3] = "Cracked";
level.mapname[4] = "Crisis";
level.mapname[5] = "Grid";
level.mapname[6] = "Firing Range";
level.mapname[7] = "Hanoi";
level.mapname[8] = "Jungle";
level.mapname[9] = "Summit";
level.mapname[10] = "Nuketown";
level.mapname[11] = "Radiation";
level.mapname[12] = "WMD";
level.mapname[13] = "Villa";
}
doMapVote()
{
level.zstate = "voting";
notifyVoting = spawnstruct();
notifyVoting.titleText = "Map Voting Time!";
notifyVoting.notifyText = "Vote for what the next map should be";
notifyVoting.notifyText2 = "Not Voting counts as same map";
notifyVoting.glowColor = (0.0, 0.6, 0.3);
current = getDvar("mapname");
level.mapnumber1 = randomInt(level.mapvote.size);
level.mapnumber2 = randomInt(level.mapvote.size);
level.mapnumber3 = randomInt(level.mapvote.size);
mapchoice1 = level.mapvote[level.mapnumber1];
mapchoice2 = level.mapvote[level.mapnumber2];
mapchoice3 = level.mapvote[level.mapnumber3];
level.choice1votes = 0;
level.choice2votes = 0;
level.choice3votes = 0;
level.keepmapvotes = 0;
while(mapchoice1 == mapchoice2 || mapchoice2 == mapchoice3 || mapchoice3 == mapchoice1 || mapchoice1 == current || mapchoice2 == current || mapchoice3 == current)
{
if(mapchoice1 == mapchoice2){
level.mapnumber1 = randomInt(level.mapvote.size);
level.mapnumber2 = randomInt(level.mapvote.size);
mapchoice1 = level.mapvote[level.mapnumber1];
mapchoice2 = level.mapvote[level.mapnumber2];
}
if(mapchoice2 == mapchoice3){
level.mapnumber2 = randomInt(level.mapvote.size);
level.mapnumber3 = randomInt(level.mapvote.size);
mapchoice2 = level.mapvote[level.mapnumber2];
mapchoice3 = level.mapvote[level.mapnumber3];
}
if(mapchoice3 == mapchoice1){
level.mapnumber1 = randomInt(level.mapvote.size);
level.mapnumber3 = randomInt(level.mapvote.size);
mapchoice1 = level.mapvote[level.mapnumber1];
mapchoice3 = level.mapvote[level.mapnumber3];
}
if(mapchoice1 == current){
level.mapnumber1 = randomInt(level.mapvote.size);
mapchoice1 = level.mapvote[level.mapnumber1];
}
if(mapchoice2 == current){
level.mapnumber2 = randomInt(level.mapvote.size);
mapchoice2 = level.mapvote[level.mapnumber2];
}
if(mapchoice3 == current){
level.mapnumber3 = randomInt(level.mapvote.size);
mapchoice3 = level.mapvote[level.mapnumber3];
}
}
wait 1;
player = undefined;
for(i=0;i<level.players.size;i++)
{
player = level.players[i];
level.players[i].menu = -1;
level.players[i].mapvoted = 0;
level.players[i].maxhealth = 99999;
level.players[i].health = level.players[i].maxhealth;
level.players[i].option1 setText("Press [{+smoke}] to vote for - " + level.mapname[level.mapnumber1]);
level.players[i].option2 setText("Press [{+melee}] to vote for - " + level.mapname[level.mapnumber2]);
level.players[i].option3 setText("Press [{+frag}] to vote for - " + level.mapname[level.mapnumber3]);
level.players[i] freezeControls(true);
level.players[i] thread maps\mp\gametypes\_hud_message::notifyMessage(notifyVoting);
}
level thread CountVotes();
level thread MapVoteTimer();
wait 20;
level notify("EndMapVote");
player = undefined;
for(i=0;i<level.players.size;i++)
{
player = level.players[i];
if(level.players[i].mapvoted == 0){
level.keepmapvotes++;
}
}
player = undefined;
for(i=0;i<level.players.size;i++)
{
player = level.players[i];
level.players[i].option1 setText(level.mapname[level.mapnumber1] + " - " + level.choice1votes);
level.players[i].option2 setText(level.mapname[level.mapnumber2] + " - " + level.choice2votes);
level.players[i].option3 setText(level.mapname[level.mapnumber3] + " - " + level.choice3votes);
}
level notify("MapVotingOver");
if(level.choice1votes > level.choice2votes && level.choice1votes > level.choice3votes && level.choice1votes > level.keepmapvotes){
level thread ChangeMapTimer(level.mapname[level.mapnumber1]);
wait 5;
setDvar("sv_mapRotation", level.mapvote[level.mapnumber1]);
setDvar("sv_mapRotationCurrent", level.mapvote[level.mapnumber1]);
exitlevel(false);
} else if(level.choice2votes > level.choice1votes && level.choice2votes > level.choice3votes && level.choice2votes > level.keepmapvotes){
level thread ChangeMapTimer(level.mapname[level.mapnumber2]);
wait 5;
setDvar("sv_mapRotation", level.mapvote[level.mapnumber2]);
setDvar("sv_mapRotationCurrent", level.mapvote[level.mapnumber2]);
exitlevel(false);
} else if(level.choice3votes > level.choice2votes && level.choice3votes > level.choice1votes && level.choice3votes > level.keepmapvotes){
level thread ChangeMapTimer(level.mapname[level.mapnumber3]);
wait 5;
setDvar("sv_mapRotation", level.mapvote[level.mapnumber3]);
setDvar("sv_mapRotationCurrent", level.mapvote[level.mapnumber3]);
exitlevel(false);
} else if(level.keepmapvotes > level.choice1votes && level.keepmapvotes > level.choice2votes && level.keepmapvotes > level.choice3votes){
wait 5;
player = undefined;
for(i=0;i<level.players.size;i++){
player = level.players[i];
level.players[i].menu = 0;
level.players[i] freezeControls(false);
level.players[i].maxhealth = 100;
level.players[i].health = player.maxhealth;
}
} else if(level.choice1votes == level.choice2votes){
if(cointoss()){
level thread ChangeMapTimer(level.mapname[level.mapnumber1]);
wait 5;
setDvar("sv_mapRotation", level.mapvote[level.mapnumber1]);
setDvar("sv_mapRotationCurrent", level.mapvote[level.mapnumber1]);
exitlevel(false);
} else {
level thread ChangeMapTimer(level.mapname[level.mapnumber2]);
wait 5;
setDvar("sv_mapRotation", level.mapvote[level.mapnumber2]);
setDvar("sv_mapRotationCurrent", level.mapvote[level.mapnumber2]);
exitlevel(false);
}
} else if(level.choice2votes == level.choice3votes){
if(cointoss()){
level thread ChangeMapTimer(level.mapname[level.mapnumber2]);
wait 5;
setDvar("sv_mapRotation", level.mapvote[level.mapnumber2]);
setDvar("sv_mapRotationCurrent", level.mapvote[level.mapnumber2]);
exitlevel(false);
} else {
level thread ChangeMapTimer(level.mapname[level.mapnumber3]);
wait 5;
setDvar("sv_mapRotation", level.mapvote[level.mapnumber3]);
setDvar("sv_mapRotationCurrent", level.mapvote[level.mapnumber3]);
exitlevel(false);
}
} else if(level.choice3votes == level.choice1votes){
if(cointoss()){
level thread ChangeMapTimer(level.mapname[level.mapnumber1]);
wait 5;
setDvar("sv_mapRotation", level.mapvote[level.mapnumber1]);
setDvar("sv_mapRotationCurrent", level.mapvote[level.mapnumber1]);
exitlevel(false);
} else {
level thread ChangeMapTimer(level.mapname[level.mapnumber3]);
wait 5;
setDvar("sv_mapRotation", level.mapvote[level.mapnumber3]);
setDvar("sv_mapRotationCurrent", level.mapvote[level.mapnumber3]);
exitlevel(false);
}
}
}