Map voting
#1

Hi, I was recently scripting a map voting system for my gamemode, I have a timer which starts every five minutes, if the round is started, it ends the round with the reason time over, if the round is not started, it starts a round.

Alright, this is how the map voting should go, I show them a dialog where they should press on a map name, and right after they press, there should be something which sets the map to the highest map with votes.


Some of my code:

pawn Код:
public RoundStatus(playerid)
{
    if(roundStarted == 1)
    {
        foreach(Player, i)
        {
            SendClientMessageToAll( -1, "The round has been ended, reason: TIME UP!");
            SetPlayerColor(i, COLOR_HUMAN);
            SetSpawnInfo(i, TEAM_HUMANS, 26, -2260.7219, 686.1232 , 49.2969, 0, 10, 1, 23, 200, 25, 200);
            SpawnPlayer(i);
        }
    }
    if(roundStarted != 1)
    {
        foreach(Player, i)
        {
            ShowPlayerDialog(i, DIALOG_VOTE, DIALOG_STYLE_LIST, "Map Vote", "zmp_zombified  \n zmp_cb \n zmp_dillimore \n zmp_funland \n zmp_grove \n zmp_lsbeach \n zmp_lshood \n zmp_mjcastillo \n zmp_outpost \n zmp_piertrip \n zmp_stormdrain \n zmp_swamp \n zmp_theships \n zmp_town \n zmp_unity \n zmp_workfare \n zmp_zombierave \n", "Vote", "Cancel" );
        }
    }
    return 1;
}
Reply
#2

Bump.
Reply
#3

I have thought about this: for example I have two maps Zombified and Unity.
so, I will be defining two variables, zombifiedvotes and unityvotes, when a player clicks on them in the dialog, I will add
pawn Код:
zombifiedvotes ++;
or
pawn Код:
unityvotes ++;
And ofcourse I will set the variables to zero when the vote ends, but the question now is, how would I get which map has the highest vote?
Reply
#4

e.g:

pawn Код:
if(zombifiedvotes > unityvotes)
{
    // more votes
}

if(zombifiedvotes >= unityvotes)
{
    // equal or more than unity votes
}

if(zombifiedvotes == unityvotes)
{
    // same amount of votes
}

if(zombifiedvotes < unityvotes)
{
    // less than unityvotes
}

if(zombifiedvotes <= unityvotes)
{
    // less or equal to
}
Simple math functions should work if there are only two variables.
Reply
#5

Quote:
Originally Posted by Abagail
Посмотреть сообщение
e.g:

pawn Код:
if(zombifiedvotes > unityvotes)
{
    // more votes
}

if(zombifiedvotes >= unityvotes)
{
    // equal or more than unity votes
}

if(zombifiedvotes == unityvotes)
{
    // same amount of votes
}

if(zombifiedvotes < unityvotes)
{
    // less than unityvotes
}

if(zombifiedvotes <= unityvotes)
{
    // less or equal to
}
Simple math functions should work if there are only two variables.
There will be a way more.
Reply
#6

Maybe something dynamic? Like loading all the current maps from a MySQL database then putting then into an array?
Reply
#7

Quote:
Originally Posted by Luis-
Посмотреть сообщение
Maybe something dynamic? Like loading all the current maps from a MySQL database then putting then into an array?
I thought of this, but I think this will way be much harder than the current way.
Reply
#8

But it'd be more easier in the long run, so you are able to add more maps with ease.
Reply
#9

Quote:
Originally Posted by Luis-
Посмотреть сообщение
But it'd be more easier in the long run, so you are able to add more maps with ease.
Alright, can you show an example of how to do it?
Reply
#10

Bump.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)