Voting problem
#1

It's very radical in my mind, why isn't this working like it supposed to ?

pawn Код:
forward votedmode(playerid);
public votedmode(playerid)
{
    new map;
    for(new i; i < sizeof maps; i++)
    if(maps[map] < maps[i])
    map = i;
    print("Voted Mode Was Successfully Executed.");
    switch (map)
    {
    case 0: SendRconCommand("changemode wwx");
    case 1: SendRconCommand("changemode jailbreak");
    case 2: SendRconCommand("changemode mallmilitia");
    case 3: SendRconCommand("changemode holywarfare");
    case 4: SendRconCommand("changemode cstyles");
    case 5: SendRconCommand("changemode killemall");
    case 6: SendRconCommand("changemode factory");
    case 7: SendRconCommand("changemode elitefighter");
    case 8: SendRconCommand("changemode lssubway");
    case 9: SendRconCommand("changemode dspeeders");
    case 10: SendRconCommand("changemode mafiawar");
    case 11: SendRconCommand("changemode pirateisland");
    case 12: SendRconCommand("changemode boattheft");
    }
    return 1;
}
Reply
#2

try adding

pawn Код:
switch(random(12))
above switch (map)
Reply
#3

Quote:
Originally Posted by Kitten
Посмотреть сообщение
try adding

pawn Код:
switch(random(12))
above switch (map)
it's not random, it should execute by the number of votes which it doesn't seems to be. It worksbut like
it executes the first case and then it continues to do the same for all time. Remember I'm trying to find the biggest number out of all votes.
Reply
#4

so what ur saying like /map 1 /map 2 ?
Reply
#5

I don't think he is asking for commands, but for a + 1 / - 1 system.

You can easily create this by adding a global variable for a vote. i.e
pawn Код:
new Map1 = 0;
Then when someone does /vote 1 (vote for map 1), you can do Map1++; which will add a vote to the array.

Then set a timer maybe 25 seconds going down, and when the timer is done, check for the highest value in an array, and change the mode to that.
Reply
#6

Ok, it's in dialog process, like when player commands /vote then a dialog box pops up with all the maps, I've one global variable storing 27 maps and i've set timer to that function to find the highest number of votes for the server to execute the next map, instead it executes the first case instead of the largest amount of vote. Also I don't want +1 -1 system, I just want to find the biggest number in efficient way. so help?
Reply
#7

Quote:
Originally Posted by Hijolion
Посмотреть сообщение
It's very radical in my mind, why isn't this working like it supposed to ?
Try this:

pawn Код:
forward votedmode(playerid);
public votedmode(playerid)
{
    new mapWinner, mostVotes = -1;
    for(new i; i < sizeof maps; i++) {
        if(maps[i] > mostVotes) {
            mapWinner = i;
            mostVotes = maps[i];
        }
    }

    switch (mapWinner) {
        case 0: {
            SendRconCommand("changemode wwx");
        }
        case 1: {
            SendRconCommand("changemode jailbreak");
        }
        case 2: {
            SendRconCommand("changemode mallmilitia");
        }
        case 3: {
            SendRconCommand("changemode holywarfare");
        }
        case 4: {
            SendRconCommand("changemode cstyles");
        }
        case 5: {
            SendRconCommand("changemode killemall");
        }
        case 6: {
            SendRconCommand("changemode factory");
        }
        case 7: {
            SendRconCommand("changemode elitefighter");
        }
        case 8: {
            SendRconCommand("changemode lssubway");
        }
        case 9: {
            SendRconCommand("changemode dspeeders");
        }
        case 10: {
            SendRconCommand("changemode mafiawar");
        }
        case 11: {
            SendRconCommand("changemode pirateisland");
        }
        case 12: {
            SendRconCommand("changemode boattheft");
        }
    }
   
    print("Voted Mode Was Successfully Executed.");
   
    return 1;
}
Also we probably need to see more code that involves the maps array.
Reply
#8

Quote:
Originally Posted by samgreen
Посмотреть сообщение
Try this:

pawn Код:
forward votedmode(playerid);
public votedmode(playerid)
{
    new mapWinner, mostVotes = -1;
    for(new i; i < sizeof maps; i++) {
        if(maps[i] > mostVotes) {
            mapWinner = i;
            mostVotes = maps[i];
        }
    }

    switch (mapWinner) {
        case 0: {
            SendRconCommand("changemode wwx");
        }
        case 1: {
            SendRconCommand("changemode jailbreak");
        }
        case 2: {
            SendRconCommand("changemode mallmilitia");
        }
        case 3: {
            SendRconCommand("changemode holywarfare");
        }
        case 4: {
            SendRconCommand("changemode cstyles");
        }
        case 5: {
            SendRconCommand("changemode killemall");
        }
        case 6: {
            SendRconCommand("changemode factory");
        }
        case 7: {
            SendRconCommand("changemode elitefighter");
        }
        case 8: {
            SendRconCommand("changemode lssubway");
        }
        case 9: {
            SendRconCommand("changemode dspeeders");
        }
        case 10: {
            SendRconCommand("changemode mafiawar");
        }
        case 11: {
            SendRconCommand("changemode pirateisland");
        }
        case 12: {
            SendRconCommand("changemode boattheft");
        }
    }
   
    print("Voted Mode Was Successfully Executed.");
   
    return 1;
}
Also we probably need to see more code that involves the maps array.
That works, but when my timer calls the function, the mode changes to the first map. Is there way to ignore it?
Reply
#9

bump* help?
Reply
#10

Paste your 'maps' variable.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)