[HELP]Team Scores
#1

I have created 5 vars:
pawn Код:
new BallasScore;
new GroveScore;
new MafiaScore;
new VagosScore;
new AztecaScore;
But I want to find out which of the variables has the greatest value at the end of a round. And what if 2 teams both have the highest score... I think I would need to use loops, but I don't understand loops. I have tried Wiki but it's too confusing.
Reply
#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
#3

I have looked at the wiki, but I don't understand how I would use the enums and arrays together to return the team with the highest score...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)