diff --git a/code/global.dm b/code/global.dm
index bfea4b640e9..944ff81d91c 100644
--- a/code/global.dm
+++ b/code/global.dm
@@ -1,3 +1,5 @@
+//List of ckeys that have de-adminned themselves during this round
+var/global/list/deadmins = list()
// List of types and how many instances of each type there are.
var/global/list/type_instances[0]
diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm
index 7b2f98c827f..244b2fadfe8 100644
--- a/code/modules/admin/admin_verbs.dm
+++ b/code/modules/admin/admin_verbs.dm
@@ -314,7 +314,8 @@ var/list/admin_verbs_mod = list(
/client/proc/cmd_admin_grantfullaccess,
/client/proc/kaboom,
/client/proc/splash,
- /client/proc/cmd_admin_areatest
+ /client/proc/cmd_admin_areatest,
+ /client/proc/readmin,
)
/client/proc/hide_most_verbs()//Allows you to keep some functionality while hiding some verbs
@@ -663,11 +664,12 @@ var/list/admin_verbs_mod = list(
set category = "Admin"
if(holder)
- if(alert("Confirm self-deadmin for the round? You can't re-admin yourself without someont promoting you.",,"Yes","No") == "Yes")
- log_admin("[src] deadmined themself.")
- message_admins("[src] deadmined themself.", 1)
- deadmin()
- src << "You are now a normal player."
+ log_admin("[src] deadminned themself.")
+ message_admins("[src] deadminned themself.")
+ deadmin()
+ verbs += /client/proc/readmin
+ deadmins += ckey
+ src << "You are now a normal player."
feedback_add_details("admin_verb","DAS") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/client/proc/toggle_log_hrefs()
@@ -831,3 +833,41 @@ var/list/admin_verbs_mod = list(
log_admin("[key_name(usr)] told everyone to man up and deal with it.")
message_admins("\blue [key_name_admin(usr)] told everyone to man up and deal with it.", 1)
+
+
+/client/proc/readmin()
+ set name = "Re-admin self"
+ set category = "Admin"
+ set desc = "Regain your admin powers."
+ var/datum/admins/D = admin_datums[ckey]
+ if(config.admin_legacy_system)
+ src << "Legacy admins is not supported yet"
+ return
+ else
+ if(!dbcon.IsConnected())
+ message_admins("Warning, mysql database is not connected.")
+ src << "Warning, mysql database is not connected."
+ return
+ if(D)
+ src << "You are already an admin."
+ verbs -= /client/proc/readmin
+ return
+ var/sql_ckey = sanitizeSQL(ckey)
+ var/DBQuery/query = dbcon.NewQuery("SELECT ckey, rank, level, flags FROM erro_admin WHERE ckey = [sql_ckey]")
+ query.Execute()
+ while(query.NextRow())
+ var/ckey = query.item[1]
+ var/rank = query.item[2]
+ if(rank == "Removed") continue //This person was de-adminned. They are only in the admin list for archive purposes.
+
+ var/rights = query.item[4]
+ if(istext(rights)) rights = text2num(rights)
+ D = new /datum/admins(rank, rights, ckey)
+
+ //find the client for a ckey if they are connected and associate them with the new admin datum
+ D.associate(directory[ckey])
+ message_admins("[src] re-adminned themselves.")
+ log_admin("[src] re-adminned themselves.")
+ feedback_add_details("admin_verb","RAS")
+ verbs -= /client/proc/readmin
+ return
\ No newline at end of file
diff --git a/code/modules/admin/holder2.dm b/code/modules/admin/holder2.dm
index c2a9803059d..b25cc1c27e4 100644
--- a/code/modules/admin/holder2.dm
+++ b/code/modules/admin/holder2.dm
@@ -30,6 +30,7 @@ var/list/admin_datums = list()
owner.holder = src
owner.add_admin_verbs() //TODO
admins |= C
+ owner.verbs -= /client/proc/readmin
/datum/admins/proc/disassociate()
if(owner)
diff --git a/code/modules/mob/login.dm b/code/modules/mob/login.dm
index abc666b881f..d0a417d43d5 100644
--- a/code/modules/mob/login.dm
+++ b/code/modules/mob/login.dm
@@ -56,5 +56,7 @@
var/mob/living/carbon/human/H = src
if(H.species && H.species.abilities)
H.verbs |= H.species.abilities
+ if(ckey in deadmins)
+ verbs += /client/proc/readmin
CallHook("Login", list("client" = src.client, "mob" = src))
\ No newline at end of file
diff --git a/code/modules/mob/new_player/login.dm b/code/modules/mob/new_player/login.dm
index 58d83622677..033e2726549 100644
--- a/code/modules/mob/new_player/login.dm
+++ b/code/modules/mob/new_player/login.dm
@@ -27,6 +27,8 @@
loc = pick(watch_locations)
*/
new_player_panel()
+ if(ckey in deadmins)
+ verbs += /client/proc/readmin
spawn(0)
if(client)
//If the changelog has changed, show it to them