Vote Next gamemode
#1

How is it possible to make a vote system the one that gets the highest vote changes the mode with

pawn Код:
SendRconCommand("changemode gamemodename");
I just need a example way to start not a whole code.
Reply
#2

Try setting a variable/enum with the maplist and use a format to change the gamemode with that rcon command.

I guess.
Reply
#3

Quote:
Originally Posted by pimpIV
Посмотреть сообщение
Try setting a variable/enum with the maplist and use a format to change the gamemode with that rcon command.

I guess.
Heres what I have made for you, I am sure this will work. I've explained important things below in the script.

pawn Код:
#define rVotes number //change the "number" to your required vote number. and put this at the top

new AllVotes; // global variable

new AlreadyVoted[MAX_PLAYERS]; // new var (not global) for player to check if he has voted already 1 vote per player

AlreadyVoted[playerid] = 0; //in OnPlayerConnect and OnPlayerDisconnected.

CMD:vote(playerid, params[])
{
    if(AlreadyVoted[playerid] == 0)
    {
        AllVotes++;
        SendClientMessage(playerid, -1, "You have voted for the gamemode to change.");
        AlreadyVoted[playerid] = 1;
        if(AllVotes == rVotes)
        {
            SendRconCommand("changemode gamemodename");
        }
    }
    else
    {
        SendClientMessage(playerid, -1, "You can't vote more then once");
    }
    return 1;
}

CMD:totalvotes(playerid, params[]) // to check how much votes.
{
    new string[128];
    format(string, sizeof(string), "There are %d votes for changing gamemode.", AllVotes);
    SendClientMessage(playerid, -1, string);
    return 1;
}

CMD:resetvotes(playerid, params[]) // to reset votes, only RCON admin can.
{
    if(IsPlayerAdmin(playerid))
    {
        SendClientMessage(playerid, -1,"You have just reset the votes.");
        for(new j=0;j<MAX_PLAYERS;j++) // loop for check, and if any player connected in the server has voted will be reset to 0 aswell so it won't bug the code.
        {
            if(IsPlayerConnected(j))
            {
                if(AlreadyVoted[j] == 1)
                {
                    AlreadyVoted[j] = 0;
                }
            }
        }
        AllVotes = 0;
    }
    else
    {
        SendClientMessage(playerid, -1, "You are not an admin to reset the votes.");
    }
    return 1;
}
Use this If you have any question you can ask below.

not tested though..

-FalconX
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)