Upload files

This commit is contained in:
SandPoot
2022-02-15 22:16:07 -03:00
parent 289a3902b1
commit c42aa2c30a
5 changed files with 193 additions and 6 deletions

View File

@@ -140,3 +140,6 @@ GLOBAL_VAR_INIT(cmp_field, "name")
/proc/cmp_typepaths_asc(A, B) /proc/cmp_typepaths_asc(A, B)
return sorttext("[B]","[A]") return sorttext("[B]","[A]")
/proc/cmp_playtime(list/A, list/B)
return A["playtime"] - B["playtime"]

View File

@@ -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, "<span class='notice'>Player not found.</span>")
return
var/client/C = usr.client
if(!isobserver(usr) && !C.admin_ghost())
return
var/mob/dead/observer/A = C.mob
A.ManualFollow(target)

View File

@@ -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. /client/proc/cmd_admin_check_player_exp() //Allows admins to determine who the newer players are.
set category = "Admin" set category = "Admin"
set name = "Player Playtime" set name = "Player Playtime"
if(!check_rights(R_ADMIN)) if(!check_rights(R_ADMIN))
return return
@@ -1564,12 +1565,7 @@ Traitors and the like can also be revived with the previous role mostly intact.
to_chat(usr, "<span class='warning'>Tracking is disabled in the server configuration file.</span>") to_chat(usr, "<span class='warning'>Tracking is disabled in the server configuration file.</span>")
return return
var/list/msg = list() new /datum/player_playtime(usr)
msg += "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><title>Playtime Report</title></head><body>Playtime:<BR><UL>"
for(var/client/C in GLOB.clients)
msg += "<LI> - [key_name_admin(C)]: <A href='?_src_=holder;[HrefToken()];getplaytimewindow=[REF(C.mob)]'>" + C.get_exp_living() + "</a></LI>"
msg += "</UL></BODY></HTML>"
src << browse(msg.Join(), "window=Player_playtime_check")
/obj/effect/temp_visual/fireball /obj/effect/temp_visual/fireball
icon = 'icons/obj/wizard.dmi' icon = 'icons/obj/wizard.dmi'

View File

@@ -1472,6 +1472,7 @@
#include "code\modules\admin\outfits.dm" #include "code\modules\admin\outfits.dm"
#include "code\modules\admin\permissionedit.dm" #include "code\modules\admin\permissionedit.dm"
#include "code\modules\admin\player_panel.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\sound_emitter.dm"
#include "code\modules\admin\sql_message_system.dm" #include "code\modules\admin\sql_message_system.dm"
#include "code\modules\admin\stickyban.dm" #include "code\modules\admin\stickyban.dm"

View File

@@ -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 (
<Window
title="Player Playtimes"
width={600}
height={700}
resizable>
<Window.Content scrollable>
<Section>
<Table>
<Table.Row>
<Table.Cell>
<center>
<Icon name="clock" />
</center>
</Table.Cell>
<Table.Cell>
<center>
Ckey
</center>
</Table.Cell>
<Table.Cell>
<center>
Real Name
</center>
</Table.Cell>
<Table.Cell>
<center>
Actions
</center>
</Table.Cell>
</Table.Row>
{clients.map(client => (
<Table.Row key={client.name} class="Table__row candystripe">
<Table.Cell>
<center>
<Button
content={client.playtime_hours}
color="transparent"
tooltip="View playtime for this player"
tooltipPosition="bottom"
onClick={() => act('view_playtime', {
ckey: client.ckey,
})} />
</center>
</Table.Cell>
<Table.Cell>
<center>
{!!client.new_account
&& (
<Tooltip content={client.new_account}>
<Icon name="sparkles" />
</Tooltip>
)} {client.ckey}
</center>
</Table.Cell>
<Table.Cell>
<center>
{!!client.observer
&& (
<Tooltip content="This player is observing">
<Icon name="ghost" />
</Tooltip>
)} {client.name}
</center>
</Table.Cell>
<Table.Cell>
<center>
<Button
content={<b>PM</b>}
color="transparent"
tooltip="Send a private message to this player"
tooltipPosition="bottom"
onClick={() => act('admin_pm', {
ckey: client.ckey,
})} />
<Button
icon="user"
color="transparent"
tooltip="Open player panel"
tooltipPosition="bottom"
onClick={() => act('player_panel', {
ckey: client.ckey,
})} />
<Button
icon="terminal"
color="transparent"
tooltip="View Variables"
tooltipPosition="bottom"
onClick={() => act('view_variables', {
ckey: client.ckey,
})} />
<Button
icon="ghost"
color="transparent"
tooltip="Admin-follow"
tooltipPosition="bottom"
onClick={() => act('observe', {
ckey: client.ckey,
})} />
</center>
</Table.Cell>
<br />
</Table.Row>
))}
</Table>
</Section>
</Window.Content>
</Window>
);
};