ID:1277619
 
(See the best response by FIREking.)
Problem description:I can't make sense of this someone please assist


Code:verb/Add_Admin()
        add_admin()
set category = "Staff"
var/list/L = new
for(var/client/c)
if(!(c.key in admin) && !(c.key in owner))
L += c.mob
if(L.len)
var/mob/pl/x = input(usr,"","Add Admin") as null|anything in L
if(x && alert(usr,"","Add Admin","Yes","No") == "Yes")
if(!admin) admin = new
admin += x.key
x.verbs += typesof("/admin/verb")
save_admin()
else if(alert(usr,"There is no one online eligible to be given admin. Would you like to enter a key manually?","Add Admin","Yes","No") == "Yes")
var/k = input(usr,"","Add Admin") as null|text
if(k)
if(!admin) admin = new
admin += k
save_admin()
usr<<"You have added the key <i>[k]</i> to the admin list"


Code:proc/Save_Admin()
    save_admin()
if(fexists(admin_save))
fdel(admin_save)
var/savefile/s = new(admin_save)
s["admins"] << admin


Code:var/admin_save
var
list/owner = list("Spunky_Girl","Alex Ovide")
list/admin
ban_save = "saves/ban.rofl"
list/ban_key
list/ban_ip
list/ban_id
admin_save = "saves/admin.rofl"



I just started coding like 3days ago so please get all complex with your explanation
All i want to do is make a list of saved admins. Create a folder that holds all the names listed in one file or i guess you would say directory. My purpose of doing this is so that I can make a process that checks keys from logging in as Staff, guilds officials, figures, and etc.
Still need help ppl
Best response
I think you're really going out of your way to over complicate this...

Why don't you just change the mob to an admin mob inside client.New() after you've detected that the client who's logging in should be an admin, based on his key. Store the key values in a text file.
I'm not sure how to do simplify it. I'm going off of tuts and snippets. I've recently came back to the coding side of byond.
All that coding is mostly snippets to tuts that I've applied
That doesn't really seem like a good way to handle saving admins. Here's how I go about it:

var/list/admins = new/list()


Create a list for storing your online admins.

client
var
adminlvl = 0


Set up a variable for the client's admin level, if you have multiple levels. This can be changed to just be a boolean type setup for whether they have admin or not (1 or 0, I use it that way despite that it can go above 1)

client/Level1
verb


Set up different client types, and give them the verbs you want that type of admin to have. Set their admin level respectively.

        save_admins(var/client/m, var/lvl)
var/Filename = "Data/AdminFile.sav"
var/savefile/A = new(Filename)
A["[m.key]"] << lvl


Give that to clients, where m is the client you're saving, and lvl is their level of admin to save.
lol thinks guys I fixed it the other day. this it how I have it.
the only problem I'm having is removing the an admin from the list. for some reason members can relog and still have their admin abilities.

///////////////////
//VERBS FOR OWNER//
///////////////////

mob/Owner/verb/Promote_to_Staff(key_to_add as text)
set category = "Staff"
if(!key_to_add)
return
global.Owner += key_to_add
var/f = new/savefile("Owners list/Owners.sav")
f["Owner"] >> key
// world<<"[src] has been promoted to the ranks of an owner"


mob/Owner/verb/Remove_from_Staff(key_to_sub as text)
set category = "Staff"
if(!key_to_sub)
return
global.Owner -= input("Remove who from staff") in global.Owner
// global.Owner -= key_to_sub

mob/Owner/verb
Announce(message as message)
set category = "Staff"
set name = "Announce"
set desc = "(message) Announce something to all players logged in"
if (message)
for(var/client/C)
C.mob << "<hr><center><b>---<font color=purple>{Announcement From [src]}</font>---</b><br><b><font color=red>[message]</font></center><hr>"
else
usr<<"Even admins shouldnt spam."


mob/verb/say(msg as text)
view() << msg


this is my login setup

mob
Login()
usr.Move(locate(1,1,1))
if(global.OwnerCheck(src.key))
src << "You were found as an <b><font color=red>Administrator</font color></b>."
world << "<b><font color= red>[src.rank]</font color></b> Has logged in"
world << "<b><font color=gold>LWAB Announcement</font color>:</b><font color=blue> <b>[usr.key]</b></font color> has logged into the game."

if(src.staff_lv==5)
src.verbs+=typesof(/mob/Owner/verb/)
else
src.verbs-=typesof(/mob/Owner/verb/)
src.staff_lv=0
world << "<b><font color=gold>LWAB Announcement</font color></b>: <font color=blue>[usr.key]</font color> has logged into the game."


this is my proc

proc/OwnerCheck(key)
if(key in global.Owner)
usr.staff_lv=5
usr.rank="Owner"
return 1
return 0
proc/AdminCheck(key)
if(key in global.Admin)
usr.staff_lv=4
usr.rank="Admin"
return 1
return 0
proc/GMCheck(key)
if(key in global.GM)
usr.staff_lv=3
usr.rank="GM"
return 1
return 0
proc/EnforcerCheck(key)
if(key in global.Enforcer)
usr.staff_lv=2
usr.rank="Enforcer"
return 1
return 0
proc/ModeratorCheck(key)
if(key in global.Moderator)
usr.staff_lv=1
usr.rank="Moderator"
return 1
return 0


is this good? or is there a more simpler way?
my problem now is that I can't remove people form the list. I don't want to del the list and lose all the other name in the admin list, so how would I would around that?
It looks like you're giving two inputs when you try to remove a key. Either use the key_to_sub argument or get rid of it. If you get rid of it, try doing:
Input() as null | anything in global.Owners
Sorry for the lack of formatting, I'm on my phone.
no that's good. im going to trying reformating it in a different way. I'm still newish to this so I'm trying to make it as simple as possible so I can understand it.
In response to Alex Ovide
What ever happened to this post I explained to you about lists.

Kitsueki wrote:
        save_admins(var/client/m, var/lvl)
var/Filename = "Data/AdminFile.sav"
var/savefile/A = new(Filename)
A["[m.key]"] << lvl


That's not how you do it.
In response to Neimo
That is how I do it :)