ID:165506
 
I want to make a ranking system for ingame ranks, but i am lost in how to make a list pop up showing all the players online at that moment.

Please Help.
This is how my game does it.
mob
verb
Who()
var/html="<title>[players.len] Player[players.len>=2 ?"s":""]</title><body bgcolor=#00000 text=#ff0000>"
for(var/mob/M in world)
if(!M.client)continue
else
html+="<a href=http://games.byond.com/people/[M.ckey]>[M]</a> <b>Level:<font color=blue> [M.level]</font>&nbsp;&nbsp;Admin: [(M.key in GMS) ?"<font color=blue> Yes</font>" : "<font color=blue> No</font>"] <b>Class:<font color=blue> [M.class]</font></b></body><br>"
usr<<browse(html,"window=popup;size=500x[player.len*85]")
In response to Xx Dark Wizard xX
Xx Dark Wizard xX wrote:
This is how my game does it.
> mob
> verb
> Who()
> var/html="<title>[players.len] Player[players.len>=2 ?"s":""]</title><body bgcolor=#00000 text=#ff0000>"
> for(var/mob/M in world)
> if(!M.client)continue
> else
> html+="<a href=http://games.byond.com/people/[M.ckey]>[M]</a> <b>Level:<font color=blue> [M.level]</font>&nbsp;&nbsp;Admin: [(M.key in GMS) ?"<font color=blue> Yes</font>" : "<font color=blue> No</font>"] <b>Class:<font color=blue> [M.class]</font></b></body><br>"
> usr<<browse(html,"window=popup;size=500x[player.len*85]")



That spread light on my day...
In response to Animay3
also you need a
mob
var
global// this means all mobs will share this variable.
players[0]

In response to Xx Dark Wizard xX
Xx Dark Wizard xX wrote:
also you need a
> mob
> var
> global// this means all mobs will share this variable.
> players[0]


k, I'm not really using it(since you helped me on my own), its just nice to know and i noted it.

oh and you shant put your variables for that game(i know which one i was just playing it) because somebody could hijack the html...and set their own variables, even screw your GM capabilities, or re-program the entire game, of course temporary..
In response to Xx Dark Wizard xX
Xx Dark Wizard xX wrote:
> mob
> var
> global// this means all mobs will share this variable.
> players[0]


No, the global "variable" is just "used to force treatment of the following variable of proc as global".

var/list/players[0] //a list of currently online players
Game
var/list/players[0] //a list of players in the current game
verb //note: all players in the game get these verbs
Global_Who()
usr<<"<b>Currently Online (entire server):</b>"
for(var/client/C in global.players) usr<<"\t [C in players?"(*)":""] [C.key]"
Who()
usr<<"<b>Currently Online (this game only):</b>"
for(var/client/C in players) usr<<"\t [C.key]"


In this example, there are two lists of "players": one list containing all the players in the server whom are currently logged in, and another containing a list of players in the current game (this game seems to be seperated with several games which can be played inside one game).
Because using "players" for the global who list would automatically refer to "src.players", you can use "global.players" to have it use the players list for the server instead of the game.

As far as I know, setting "global" within a variable declaration has no effect.
In response to Android Data
Android Data wrote:
As far as I know, setting "global" within a variable declaration has no effect.

Legend has it that reading the DM Reference will assist you to know ('global vars' entry).

Despite DarkWizard's way being right, it's not really the best way to do it. Why always keep a list in memory? And you're probably manipulating it on login and logout?
Anyway, my game uses (:P) :
#define AFK_TIME 300 //in seconds
Who()
var/players=0,AFKp=0
src << "<h2>{Players logged in:}<br>"
for(var/client/C)
players++
if(C.inactivity/10 > AFK_TIME) AFKp++
usr << "[C.mob.name] ([C.key]) [istype(C.mob,/mob/player)? "{Guild:[C.mob:guild]}" : ""][C.inactivity/10 > AFK_TIME ? "\red<b>AFK" : ""]"
src << "Total players logged in:<font color=blue><b>[players]</font></b>,out of them <font color=red><b>[AFKp]</font></b> are AFK"


Complete with AFK player detecting. OR shall I call it, "AFK system", xD lol.