#define SCOREBOARD_BASE Overall_Lvl // Change this to whatever\
variable you want to base your scoreboard on
#define MAX_RANKS 20 // MAX_RANKS is the number of maximum entries\
the scoreboard can have, change this at will as it will not break anything\
in the library.
var/scoreboard/A_SB = new // Creates our scoreboard datum.
world/New()
..()
sleep(1)
A_SB.load()
world/Del()
A_SB.save()
..()
scoreboard
var/list/ranks
proc
save()
var/savefile/F = new("scoreboard.sav")
F["ranks"] << ranks
return 1
load()
var/savefile/F = new("scoreboard.sav")
if(F["ranks"])
F["ranks"] >> ranks
return 1
return 0
proc/Update(var/mob/M in world)
if(!M||!M.client)return
if(!ranks) ranks = list()
if(M.key in ranks)
ranks[M.key] = M.SCOREBOARD_BASE
UpdateRanks(M.key)
else
if(ranks.len < MAX_RANKS)
ranks[M.key] = M.SCOREBOARD_BASE
else
var/Key = ranks[20]
var/BASE = ranks[Key]
if(BASE > M.SCOREBOARD_BASE) return
ranks[Key] = M.key
ranks[M.key] = M.SCOREBOARD_BASE
var/INDEX
proc/UpdateRanks(key)
for()
var/BASE = ranks[key]
INDEX = ranks.Find(key)
var/NEWINDEX = INDEX - 1
if(NEWINDEX>MAX_RANKS||NEWINDEX<=0) break
var/NEWBASE = ranks[ranks[NEWINDEX]]
if(NEWBASE > BASE)
ranks.Swap(INDEX,NEWINDEX)
else break
proc/Display(mob/M)
var/counter=1
var/html= {"<head><title>A_Scoreboard</title></head><body style=\"background-color:black;\"><center><table border=2>
<th colspan=\"3\"><font color=white>Scoreboard library created by Andre-g1</font color></th>
<tr><td style=\"background-color: #666666;\"><center><font color=white><b>#</b></font color></center></td>
<td style=\"background-color: #666666;\"><center><font color=white><b>Name</b></font color></center></td>
<td style=\"background-color: #666666;\"><center><font color=white><b>Level</b></font color></center></td></tr>""}
for(var/Key in ranks)
counter++
var/Value = ranks[Key]
html += "<tr>[counter%2 ? "<td style=\"background-color: #666666;\">" : "<td>"]<center><font color=white>[INDEX]</font color></center></td>[counter%2 ? "<td style=\"background-color: #666666;\">" : "<td>"]<center><font color=white>[M.name]([Key])</font color></center></td>[counter%2 ? "<td style=\"background-color: #666666;\">" : "<td>"]<center><font color=white>[Value]</font color></center></td></tr>"
html += "</table></center></p>"
M << browse(html,"window=A_Scoreboard;can_resize=0;can_minimize=0")
mob/verb
Displayy()
// for(var/mob/m in world)
A_SB.Display(src) // Display the scoreboard to the user.
Update()
A_SB.Update(src) // Update the scoreboard
Problem description: Hi byond developers, im having a problem with a scoreboard library.
1st of all after add the code and edit it as i needed to use my values and save the scores in a sav file. Now the problem is that when i use my update verb (i tryed to when used the update verb look for all online clients in world so it would add all them and not just the player who uses the scoreboard as the library does (idk what i did but dosnt look for the online clients so just adds the one who uses the code.
2nd problem is that on the scoreboard dosnt display the real player name, displays the name of the one who executes the verb and the indexes are the same for everyone.
3th problem is that the scoreboard idk why dosnt order the ranks so a lvl 50 is above a 70?.
I uploaded a pic if it can help in my description of my problem sry for bad english...
http://postimg.org/image/el11y7dmn/
So:
1. Create a Scoreboard List.
2. Update it adding players to it.
3. Order the players by higher to lower level.
4. Save/Load the list.