[HELP]Team Scores
#2

We need to create a function which gets the highest variable

pawn Код:
stock GetHighestVar(...) {
    new
        highest = 0, // lets pretend that the first is the highest, it is also the fallback if all got the same value
        i = (numargs() - 1); // starts at the end of the list to loop
    for( ; i != 0; --i) { // loops through all input variables
        if(getarg(highest) < getarg(i)) { // check if the current variable is bigger than the highest
            highest = i; // sets the highest to the current
        }
    }
    return highest; // return the highest
}
How to use

pawn Код:
switch(GetHighestVar(BallasScore, GroveScore, MafiaScore, VagosScore, AztecaScore)) {
    case 0: {} // BallasScore
    case 1: {} // GroveScore
    case 2: {} // MafiaScore
    case 3: {} // VagosScore
    case 4: {} // AztecaScore
}
But this gets pretty messed up if you need to put for each team their own code

I would suggest arrays with enums
Reply


Messages In This Thread
[HELP]Team Scores - by Tigerbeast11 - 15.08.2011, 15:17
AW: [HELP]Team Scores - by Nero_3D - 16.08.2011, 22:25
Re: [HELP]Team Scores - by Tigerbeast11 - 16.08.2011, 23:39

Forum Jump:


Users browsing this thread: 1 Guest(s)