SendRconCommand("changemode gamemodename");
Try setting a variable/enum with the maplist and use a format to change the gamemode with that rcon command.
I guess. |
#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;
}