Skip to content

Commit

Permalink
Check Players adminverb + other admin verb fixes (#4030)
Browse files Browse the repository at this point in the history
* Check Players adminverb + other admin verb fixes

Check Players adminverb to quickly and precisely check how many connected clients of several categories: Connected Clients, Living Players, Dead Players, Ghost Players, Living Antags.

* Updates

* Update readme.md

* updated with comments etc

* Updates after review

I don't think I can check adjust_metacoins properly (or at least I can't figure out how to get it to work) so I have reverted to what it was before

* lucy ur so right

* changes after review

tested, still works, hopefully fixes merge conflict

* guh

* Changes after review

Requested changes are in, thanks for all your hard work looking at my code Lucy!
  • Loading branch information
Veth-s authored Nov 14, 2024
1 parent 8859ab0 commit 1c21ced
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 6 deletions.
1 change: 1 addition & 0 deletions code/modules/admin/admin_verbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ GLOBAL_PROTECT(admin_verbs_admin)
/client/proc/log_viewer_new,
/client/proc/request_more_opfor,
/client/proc/view_opfors,
/client/proc/check_players,
/client/proc/AdminVOX,
)
GLOBAL_LIST_INIT(admin_verbs_ban, list(/client/proc/unban_panel, /client/proc/ban_panel, /client/proc/stickybanpanel, /client/proc/library_control))
Expand Down
5 changes: 2 additions & 3 deletions monkestation/code/modules/admin/antag_tokens.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
set name = "Adjust Antag Tokens"
set desc = "You can modifiy a targets metacoin balance by adding or subtracting."

var/mob/chosen_player = tgui_input_list(src, "Choose a Player", "Player List", GLOB.player_list)
if(!chosen_player)
var/client/chosen_client = tgui_input_list(src, "Choose a Player", "Player List", GLOB.clients)
if(!chosen_client)
return

var/client/chosen_client = chosen_player.client
var/adjustment_amount = tgui_input_number(src, "How much should we adjust this users antag tokens by?", "Input Value", TRUE, 10, -10)
if(!adjustment_amount || !chosen_client)
return
Expand Down
5 changes: 2 additions & 3 deletions monkestation/code/modules/admin/event_tokens.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
set name = "Adjust Event Tokens"
set desc = "Adjust how many event tokens someone has."

var/mob/chosen_player = tgui_input_list(src, "Choose a Player", "Player List", GLOB.player_list)
if(!chosen_player)
var/client/chosen_client = tgui_input_list(src, "Choose a Player", "Player List", GLOB.clients)
if(!chosen_client)
return

var/client/chosen_client = chosen_player.client
var/adjustment_amount = tgui_input_number(src, "How much should we adjust this users tokens by?", "Input Value", TRUE)
if(!adjustment_amount || !chosen_client)
return
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/client/proc/check_players()
set name = "Check Players"
set category = "Admin.Game"
if(!check_rights(NONE)) // Rights check for admin access
message_admins("[key_name(src)] attempted to use CheckPlayers without sufficient rights.") //messages admins if rights check fails
return
var/datum/check_players/tgui = new
tgui.ui_interact(mob)
to_chat(src, span_interface("Player statistics displayed."), confidential = TRUE)
SSblackbox.record_feedback("tally", "admin_verb", 1, "Check Players") //Logging
message_admins("[key_name(src)] checked players.") //Logging

/datum/check_players/ui_data(mob/user) //Data required for the frontend
return list(
"total_clients" = length(GLOB.player_list),
"living_players" = length(GLOB.alive_player_list),
"dead_players" = length(GLOB.dead_player_list),
"observers" = length(GLOB.current_observers_list),
"living_antags" = length(GLOB.current_living_antags),
)

/datum/check_players //datum required for the tgui window

/datum/check_players/ui_close()
qdel(src)

/datum/check_players/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "PlayerStatistics")
ui.open()

/datum/check_players/ui_state(mob/user)
return GLOB.admin_state
27 changes: 27 additions & 0 deletions monkestation/code/modules/veth_misc_items/admin_fixes/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Title: <!--Title of your addition-->

<!-- uppercase, underscore_connected name of your module, that you use to mark files-->
MODULE ID: CHECKPLAYERS

### Description:
Changes admin verbs - Adjust Event/Antag/Monkecoin tokens from character name to ckey.
Adds Adminverb - Check Players for a quick and easy method to check currently connected clients of several categories - All clients, alive, dead, ghosts, living antags.

### Master file additions

- N/A
<!-- Any master file changes you've made to existing master files or if you've added a new master file. Please mark either as #NEW or #CHANGE -->

### Included files that are not contained in this module:

- N/A
<!-- Likewise, be it a non-modular file or a modular one that's not contained within the folder belonging to this specific module, it should be mentioned here -->
#NEW tgui/packages/tgui/interfaces/PlayerStatisticsUI.tsx
#CHANGE monkestation/code/modules/admin/antag_tokens.dm
#CHANGE monkestation/code/modules/admin/event_tokens.dm
#CHANGE monkestation/code/modules/store/admin/admin_coin_modification.dm
### Credits:

<!-- Here go the credits to you, dear coder, and in case of collaborative work or ports, credits to the original source of the code -->
<!-- Original Coders -->
Made by Veth
1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -8216,6 +8216,7 @@
#include "monkestation\code\modules\vehicles\mecha\mecha_actions.dm"
#include "monkestation\code\modules\vehicles\mecha\equipment\tools\other_tools.dm"
#include "monkestation\code\modules\vending\megaseed.dm"
#include "monkestation\code\modules\veth_misc_items\admin_fixes\check_players.dm"
#include "monkestation\code\modules\veth_misc_items\admin_vox\admin_vox.dm"
#include "monkestation\code\modules\veth_misc_items\canopics\canopics.dm"
#include "monkestation\code\modules\viking\viking_armour.dm"
Expand Down
66 changes: 66 additions & 0 deletions tgui/packages/tgui/interfaces/PlayerStatistics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { Section, LabeledList } from '../components';
import { Window } from '../layouts';
import { useBackend } from '../backend';
type Data = {
total_clients: number;
living_players: number;
dead_players: number;
observers: number;
living_antags: number;
};

export const PlayerStatistics = () => {
const {
data: {
total_clients,
living_players,
dead_players,
observers,
living_antags,
},
} = useBackend<Data>();

return (
<Window title="Player Statistics" width={400} height={180} theme="admin">
<Section title="Player Overview">
<LabeledList>
<LabeledList.Item
label="Total Clients"
labelColor="#4287f5"
color="#4287f5"
>
{total_clients}
</LabeledList.Item>
<LabeledList.Item
label="Living Players"
labelColor="#1d9123"
color="#1d9123"
>
{living_players}
</LabeledList.Item>
<LabeledList.Item
label="Dead Players"
labelColor="#666e66"
color="#666e66"
>
{dead_players}
</LabeledList.Item>
<LabeledList.Item
label="Observers"
labelColor="#34949e"
color="#34949e"
>
{observers}
</LabeledList.Item>
<LabeledList.Item
label="Living Antags"
labelColor="#bd2924"
color="#bd2924"
>
{living_antags}
</LabeledList.Item>
</LabeledList>
</Section>
</Window>
);
};

0 comments on commit 1c21ced

Please sign in to comment.