Skip to content

Commit

Permalink
Add a "Kick Player (by ckey)" verb for admins to use (#2124)
Browse files Browse the repository at this point in the history
* Add a "Kick Player (by ckey)" verb for admins to use

* Change the tgui alerts in the kick code to regular alerts
  • Loading branch information
LikeLakers2 authored Jun 3, 2024
1 parent 35f7b69 commit 26a8443
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 0 deletions.
16 changes: 16 additions & 0 deletions code/__HELPERS/~monkestation-helpers/clients.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/proc/kick_client(client/to_kick)
// Pretty much everything in this proc is copied straight from `code/modules/admin/topic.dm`,
// proc `/datum/admins/Topic()`, href `"boot2"`. If it breaks here, it was probably broken there
// too.
if(!check_rights(R_ADMIN))
return
if(!to_kick)
to_chat(usr, span_danger("Error: The client you specified has disappeared!"), confidential = TRUE)
return
if(!check_if_greater_rights_than(to_kick))
to_chat(usr, span_danger("Error: They have more rights than you do."), confidential = TRUE)
return
to_chat(to_kick, span_danger("You have been kicked from the server by [usr.client.holder.fakekey ? "an Administrator" : "[usr.client.key]"]."), confidential = TRUE)
log_admin("[key_name(usr)] kicked [key_name(to_kick)].")
message_admins(span_adminnotice("[key_name_admin(usr)] kicked [key_name_admin(to_kick)]."))
qdel(to_kick)
1 change: 1 addition & 0 deletions code/modules/admin/admin_verbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ GLOBAL_PROTECT(admin_verbs_admin)
/datum/admins/proc/view_all_circuits,
/datum/admins/proc/open_artifactpanel,
/datum/verbs/menu/Admin/verb/playerpanel, /* It isn't /datum/admin but it fits no less */
/datum/admins/proc/kick_player_by_ckey, //MONKESTATION ADDITION - kick a player by their ckey
// Client procs
/client/proc/admin_call_shuttle, /*allows us to call the emergency shuttle*/
/client/proc/admin_cancel_shuttle, /*allows us to cancel the emergency shuttle, sending it back to centcom*/
Expand Down
10 changes: 10 additions & 0 deletions code/modules/admin/topic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,28 @@
if(!check_if_greater_rights_than(M.client))
to_chat(usr, span_danger("Error: They have more rights than you do."), confidential = TRUE)
return
/* //MONKESTATION EDIT START - Change this tgui alert to a regular alert
if(tgui_alert(usr, "Kick [key_name(M)]?", "Confirm", list("Yes", "No")) != "Yes")
return
*/ //MONKESTATION EDIT ORIGINAL
if(alert(usr, "Kick [key_name(M)]?", "Confirm", "Yes", "No") != "Yes")
return
//MONKESTATION EDIT END
if(!M)
to_chat(usr, span_danger("Error: [M] no longer exists!"), confidential = TRUE)
return
if(!M.client)
to_chat(usr, span_danger("Error: [M] no longer has a client!"), confidential = TRUE)
return
//MONKESTATION EDIT START - Kicking players has been moved to a proc
/*
to_chat(M, span_danger("You have been kicked from the server by [usr.client.holder.fakekey ? "an Administrator" : "[usr.client.key]"]."), confidential = TRUE)
log_admin("[key_name(usr)] kicked [key_name(M)].")
message_admins(span_adminnotice("[key_name_admin(usr)] kicked [key_name_admin(M)]."))
qdel(M.client)
*/ //MONKESTATION EDIT ORIGINAL
kick_client(M.client)
//MONKESTATION EDIT END

else if(href_list["addmessage"])
if(!check_rights(R_ADMIN))
Expand Down
19 changes: 19 additions & 0 deletions monkestation/code/modules/admin/verbs/kick_player_by_ckey.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/datum/admins/proc/kick_player_by_ckey()
set name = "Kick Player (by ckey)"
set category = "Admin"

// Pretty much everything here except the client selection is copied straight from
// `code/modules/admin/topic.dm`, proc `/datum/admins/Topic()`, href `"boot2"`. If it breaks
// here, it was probably broken there too.
if(!check_rights(R_ADMIN))
return

var/client/to_kick = input(usr, "Select a ckey to kick.", "Select a ckey") as null|anything in sort_list(GLOB.clients)
if(!to_kick)
return

var/confirmation = alert(usr, "Kick [key_name(to_kick)]?", "Confirm", "Yes", "No")
if(confirmation != "Yes")
return

kick_client(to_kick)
2 changes: 2 additions & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@
#include "code\__HELPERS\~monkestation-helpers\announcements.dm"
#include "code\__HELPERS\~monkestation-helpers\antags.dm"
#include "code\__HELPERS\~monkestation-helpers\atoms.dm"
#include "code\__HELPERS\~monkestation-helpers\clients.dm"
#include "code\__HELPERS\~monkestation-helpers\icon_smoothing.dm"
#include "code\__HELPERS\~monkestation-helpers\roundend.dm"
#include "code\__HELPERS\~monkestation-helpers\time.dm"
Expand Down Expand Up @@ -5830,6 +5831,7 @@
#include "monkestation\code\modules\admin\smites\dagothstripsmite.dm"
#include "monkestation\code\modules\admin\smites\phobia_christian_minecraft.dm"
#include "monkestation\code\modules\admin\smites\where_are_your_fingers.dm"
#include "monkestation\code\modules\admin\verbs\kick_player_by_ckey.dm"
#include "monkestation\code\modules\aesthetics\airlock\airlock.dm"
#include "monkestation\code\modules\aesthetics\items\clothing.dm"
#include "monkestation\code\modules\aesthetics\mapping\tilecoloring.dm"
Expand Down

0 comments on commit 26a8443

Please sign in to comment.