ID:149037
 
here is the code

winner = max(num2text(p1c),num2text(p2c),num2text(p3c),num2text(p4c))
if(winner == num2text(p1c))
world << "GAME OVER the winner is [p1n]!!!"
if(winner == num2text(p2c))
world << "GAME OVER the winner is [p2n]!!!"
if(winner == num2text(p3c))
world << "GAME OVER the winner is [p3n]!!!"
if(winner == num2text(p4c))
world << "GAME OVER the winner is [p4n]!!!"

p*n are their names and p*c are their scores, everything compiles and runs fine but i have played the game 5 times with ppl and only 3 out of those 5 times did it say the right person won. Is there a way to improve this?
proc/show_winner()
var
mob/winner = null
high_score = 0
for(var/mob/M in world)
if(M.score > high_score)
high_score = M.score
winner = M
world << "[winner] wins the game with [high_score] points!"
You have written a proc that will announce the winner of the following contest:

Who among the players has a score which occurs latest in the alphabet?

max() is generally used with numbers, not text.
In response to ShadowSiientx
thanks i couldn't use it exactly like that since i am using global vars but it helped me by giving some ideas
In response to Skysaw
oh its because i thought max returns a string thats why i changed all of them to text