ID:161428
 
I want to learn how to make a grid that shows who is online, their inactivity time, and if they're AFK or Online.

Can someone help?
OK, I have figured it out almost. The problem is that inactivity time isn't moving...

mob/proc
UpdatePlayers()
for(var/mob/M in world)
if(M.online)
src << output("[M] / [M.client.inactivity/10] - [afkness]" ,"grid1")

mob/var
online = 0
afkness = "{Online}"
AFK = 0


mob/Login()
src << "Welcome."
src.online = 1
UpdatePlayers()


Why isn't it moving?
In response to Howey
cause u only update the grid when the player logs in?
In response to Falacy
No, the grid will update every time anyone uses anything.
You will need to make a grid and dynamically adjust the size depending on the amount of players online.

proc/updatePlayersGrid()
//first, we generate a list
var/list/players = new/list(0,0)
for(var/client/C)
players[C.key] = list(estimate_time(C.inactivity), (C.inactivity >= 300 ? "Away" : "Online"))

//next we update the grids
for(var/client/C)
winset(C,"playergrid", "cells=3x[players.len]")
for(var/i = 1 to players.len)
var
key = players[i]
activity = players[key][1]
status = players[key][2]
C << output(key, "playergrid:1,[i]")
C << output(activity, "playergrid:2,[i]")
C << output(status, "playergrid:3,[i]")

world/New()
spawn
while(1)
sleep(10)
updatePlayersGrid()
return ..()


The estimate_time() proc is located here.

Exercise #1: The code has been provided, but now you need to implement it. Make a skin file with the grid and alter the code to use this.
Exercise #2: Try making it so that you can right-click on a name to bring up options, such as "Send Private Message" and (for moderators) Kick.

-- Data
In response to Android Data
i thot grids automaticaly updated their size if you didnt give them a preset one?
In response to Android Data
Android Data wrote:
You will need to make a grid and dynamically adjust the size depending on the amount of players online.

> proc/updatePlayersGrid()
> //first, we generate a list
> var/list/players = new/list(0,0)
> for(var/client/C)
> players[C.key] = list(estimate_time(C.inactivity), (C.inactivity >= 300 ? "Away" : "Online"))
>
> //next we update the grids
> for(var/client/C)
> winset(C,"playergrid", "cells=3x[players.len]")
> for(var/i = 1 to players.len)
> var
> key = players[i]
> activity = players[key][1]
> status = players[key][2]
> C << output(key, "playergrid:1,[i]")
> C << output(activity, "playergrid:2,[i]")
> C << output(status, "playergrid:3,[i]")
>
> world/New()
> spawn
> while(1)
> sleep(10)
> updatePlayersGrid()
> return ..()
>

The estimate_time() proc is located here.

Exercise #1: The code has been provided, but now you need to implement it. Make a skin file with the grid and alter the code to use this.
Exercise #2: Try making it so that you can right-click on a name to bring up options, such as "Send Private Message" and (for moderators) Kick.

-- Data

WEll, I've got the Online, or Away to show up. The name wont though...
In response to Falacy
http://www.youtube.com/watch?v=FIeoEGFC_Mc

That's what happens for me now.