ID:1446793
 
mob/player/New()
spawn()
while(1)
sleep(10)
if(src.stamina<src.maxstamina && !src.intrainning)
src.stamina++
if(src.max_hp>=src.hp+10 && !src.intrainning)
src.hp+=10
else if(src.max_hp>src.hp && !src.intrainning)
src.hp=src.max_hp

..()
spawn()
while(1)
sleep(1000)
updateScoreboard(src)
..()

var/list/scoreboard = list()

proc

updateScoreboard(var/mob/player/M)
if(!M) return //if no reference to a player was passed in, abort
for(var/elem in scoreboard) //for every element in the scoreboard (every player listed)
if(scoreboard[elem] < ((M.nen_power * 10) + M.str)) //scoreboard is an associative list, with the names of players being associated with the value of these stats; so this line checks to see if this player's value is greater than an item on the scoreboard
var/pos = scoreboard.Find(elem) //if a lower score is found, grab its position in the list
if(scoreboard.Find(M.name))scoreboard -= M.name //if this player's name is already in the list, remove it
scoreboard.Insert(pos,M.name) //put the player's name in at the position found above (the score he is bumping down)
scoreboard[M.name] = ((M.nen_power * 10) + M.str) //set the associated value for the player's name to the value of his stats
return //stop looping through the list
else if(elem == M.name)return //We already have a higher value (this player is already on the scoreboard, with a higher score than current, so do nothing)
if(scoreboard.len > 10)return //if we get this far in the proc, it means that the player's score is lower than every other entry in the list, so he would need to go at the bottom; but don't add him if the scoreboard's length is 11 or more
scoreboard += M.name //if there's room at the bottom of the list (well, top actually, by index), add the player
scoreboard[M.name] = (M.nen_power) + M.str //and set the value to his stats

mob
player
verb
checkScores()
var/output = "<center>Highscores:<hr>"
for(var/i in scoreboard) //for every name in scoreboard
output+="[i]: [scoreboard[i]]<br>" //add "[name]: [name's score]<BR>" to output
output+="[scoreboard[i]]: [scoreboard[scoreboard[i]]]<br>"
src << browse(output,"window=Highscores;size=300x300")
The problem is when I click checkScores, there are no one's scores displaying. Nothing is displaying but "Highscores:". Please help.
Where are you adding to the scoreboard?
What are you talking about? This is all the code I have. It wasn't made by me though.
In response to TheDarkChakra
This code is never adding to the scoreboard. That's your problem.
Doesn't this do it:

scoreboard.Insert(pos,M.name)
?

What should I do?
In response to TheDarkChakra
The code that adds to your scoreboard occurs for every element in the scoreboard. Since the scoreboard is empty...
Okay how about I add a return at the end of the for loop and beneath the for loop add me to the scoreboard?
In response to TheDarkChakra
Assuming the code in the for() loop is correct, you shouldn't need to modify it for this solution since it's irrelevant when the scoreboard is empty.

All you need to do is handle the case when the scoreboard is empty. It'll only ever happen once, so it doesn't require as much effort as what the for() loop does.
I added
        if(!scoreboard.len)
scoreboard += M.name //if there's room at the bottom of the list (well, top actually, by index), add the player
scoreboard[M.name] = (M.nen_power) + M.str //and set the value to his stats
to the top of updatescoreboard proc but when I click checkScores it says list index out of bounds.
In response to TheDarkChakra
Are you forgetting that the entire runtime error is important and should always be posted?

No matter, I suspect it's pointing to your second output+= line in checkScores(). I don't know why you added that there, or why you changed “name” to “i”, but it's not necessary. The line above it already works.
okay i grayed out the second output and now the high scores works.