diff --git a/code/__HELPERS/cmp.dm b/code/__HELPERS/cmp.dm index 4ee622961a..2fbf087288 100644 --- a/code/__HELPERS/cmp.dm +++ b/code/__HELPERS/cmp.dm @@ -140,3 +140,6 @@ GLOBAL_VAR_INIT(cmp_field, "name") /proc/cmp_typepaths_asc(A, B) return sorttext("[B]","[A]") + +/proc/cmp_playtime(list/A, list/B) + return A["playtime"] - B["playtime"] diff --git a/code/modules/admin/playtimes.dm b/code/modules/admin/playtimes.dm new file mode 100644 index 0000000000..7cf24d9746 --- /dev/null +++ b/code/modules/admin/playtimes.dm @@ -0,0 +1,68 @@ +/datum/player_playtime/New(mob/viewer) + ui_interact(viewer) + +/datum/player_playtime/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "PlayerPlaytimes", "Player Playtimes") + ui.open() + +/datum/player_playtime/ui_state(mob/user) + return GLOB.admin_state + +/datum/player_playtime/ui_data(mob/user) + var/list/data = list() + + var/list/clients = list() + for(var/client/C in GLOB.clients) + var/list/client = list() + + client["ckey"] = C.ckey + client["playtime"] = C.get_exp_living(TRUE) + client["playtime_hours"] = C.get_exp_living() + + var/mob/M = C.mob + client["observer"] = isobserver(M) + client["ingame"] = !isnewplayer(M) + client["name"] = M.real_name + var/nnpa = CONFIG_GET(number/notify_new_player_age) + if(nnpa >= 0) + if(C.account_age >= 0 && (C.account_age < CONFIG_GET(number/notify_new_player_age))) + client["new_account"] = "New BYOND account [C.account_age] day[(C.account_age==1?"":"s")] old, created on [C.account_join_date]" + + clients += list(client) + + clients = sortList(clients, /proc/cmp_playtime) + data["clients"] = clients + return data + +/datum/player_playtime/ui_act(action, params) + if(..()) + return + + switch(action) + if("view_playtime") + var/mob/target = get_mob_by_ckey(params["ckey"]) + usr.client.holder.cmd_show_exp_panel(target.client) + if("admin_pm") + usr.client.cmd_admin_pm(params["ckey"]) + if("player_panel") + var/mob/target = get_mob_by_ckey(params["ckey"]) + usr.client.holder.show_player_panel(target) + if("view_variables") + var/mob/target = get_mob_by_ckey(params["ckey"]) + usr.client.debug_variables(target) + if("observe") + if(!isobserver(usr) && !check_rights(R_ADMIN)) + return + + var/mob/target = get_mob_by_key(params["ckey"]) + if(!target) + to_chat(usr, "Player not found.") + return + + var/client/C = usr.client + if(!isobserver(usr) && !C.admin_ghost()) + return + var/mob/dead/observer/A = C.mob + A.ManualFollow(target) diff --git a/code/modules/admin/verbs/randomverbs.dm b/code/modules/admin/verbs/randomverbs.dm index a0a1da9584..9e201ec360 100644 --- a/code/modules/admin/verbs/randomverbs.dm +++ b/code/modules/admin/verbs/randomverbs.dm @@ -1557,6 +1557,7 @@ Traitors and the like can also be revived with the previous role mostly intact. /client/proc/cmd_admin_check_player_exp() //Allows admins to determine who the newer players are. set category = "Admin" set name = "Player Playtime" + if(!check_rights(R_ADMIN)) return @@ -1564,12 +1565,7 @@ Traitors and the like can also be revived with the previous role mostly intact. to_chat(usr, "Tracking is disabled in the server configuration file.") return - var/list/msg = list() - msg += "Playtime ReportPlaytime:
" - src << browse(msg.Join(), "window=Player_playtime_check") + new /datum/player_playtime(usr) /obj/effect/temp_visual/fireball icon = 'icons/obj/wizard.dmi' diff --git a/tgstation.dme b/tgstation.dme index 4328158bfc..533962c9d9 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -1472,6 +1472,7 @@ #include "code\modules\admin\outfits.dm" #include "code\modules\admin\permissionedit.dm" #include "code\modules\admin\player_panel.dm" +#include "code\modules\admin\playtimes.dm" #include "code\modules\admin\sound_emitter.dm" #include "code\modules\admin\sql_message_system.dm" #include "code\modules\admin\stickyban.dm" diff --git a/tgui/packages/tgui/interfaces/PlayerPlaytimes.js b/tgui/packages/tgui/interfaces/PlayerPlaytimes.js new file mode 100644 index 0000000000..aaa3e0cc98 --- /dev/null +++ b/tgui/packages/tgui/interfaces/PlayerPlaytimes.js @@ -0,0 +1,119 @@ +import { useBackend } from '../backend'; +import { Button, Icon, Section, Table, Tooltip } from '../components'; +import { Window } from '../layouts'; + +export const PlayerPlaytimes = (props, context) => { + const { act, data } = useBackend(context); + const { + clients, + } = data; + return ( + + +
+ + + +
+ +
+
+ +
+ Ckey +
+
+ +
+ Real Name +
+
+ +
+ Actions +
+
+
+ {clients.map(client => ( + + +
+
+
+ +
+ {!!client.new_account + && ( + + + + )} {client.ckey} +
+
+ +
+ {!!client.observer + && ( + + + + )} {client.name} +
+
+ +
+
+
+
+
+ ))} +
+
+
+
+ ); +};