16.08.2011, 22:25
We need to create a function which gets the highest variable
How to use
But this gets pretty messed up if you need to put for each team their own code
I would suggest arrays with enums
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
}
pawn Код:
switch(GetHighestVar(BallasScore, GroveScore, MafiaScore, VagosScore, AztecaScore)) {
case 0: {} // BallasScore
case 1: {} // GroveScore
case 2: {} // MafiaScore
case 3: {} // VagosScore
case 4: {} // AztecaScore
}
I would suggest arrays with enums