ID:2250464
 
Hiya, I am coding an event in which a bunch of mobs appear and people in teams have to kill them. Who ever kills the most after the time is up wins. I was wondering if someone could help me determine how to make it so that the code auto tells the largest number. Right now I have it so that in the world chat it displays everyone's score. I just want it so that the proc auto determine who wins and gives them their reward. I was thinking like if(team1_kills>team2_kills&&team3_kills). Though I do not know if that is a smart move. Please help!
var/list/event_kills //define this somewhere. Your structure will vary.

//when the team joins the event:

event_kills[team] = 0

//when the score is incremented

++event_kills[team]

//when you need to figure out the winning team:

var/highest = 0, winning
for(var/team in event_kills) //loop over every team entered in the event.
if(event_kills[team]>highest) //if the event kills for the current team are higher than the highest team's
highest = event_kills[team] //record the new high score
winning = team //store the winning team id
if(winning) //if a winner was found.
world << "[winning] won the event with [highest] kills!" //output a message.