ID:139908
 
Code:
mob
Login()
world<<"<font color = purple>[usr.name] has logged in."
usr<<"Welcome to Hogwarts: Reborn!"
usr.loc=locate(3,3,1)
icon='ICONS.dmi'
usr.icon_state="male"
usr.frozen=0
usr.mut=0
usr.overlays+="hair"
client.Load()
if(usr.key=="Colin1011")
usr.verbs += typesof(/mob/Admin/verb/)
usr<<"You are a GM."
usr.Year="Graduated"
usr.name="Professor Underman"
usr.TransLevel=100


Problem description:I got something else to work, and it broke this... anyone know why? The problem is that it doesn't make me a GM, basically.

1) You're using usr in Login(). Bad idea if you are making a multiplayer game, change it to src, as usr may not be directly defined with Login().

2) Do you have another Login() defined elsewhere? If so, be sure to call the parent procedure (..()).
Because you've changed mobs. So you're giving verbs to your old mob. Associate the verbs with clients, not mobs, and grant them in client/New().
mob
Login()
world<<"<font color = purple>[usr.name] has logged in."
src<<"Welcome to Hogwarts: Reborn!"
src.loc=locate(3,3,1)
icon='ICONS.dmi'
src.icon_state="male"
src.frozen=0
src.mut=0
src.overlays+="hair"
client.Load()
if(src.key=="Colin1011")
src.verbs += typesof(/mob/Admin/verb/)
src<<"You are a GM."
src.Year="Graduated"
src.name="Professor Underman"
src.TransLevel=100
else
if(src.key=="Revail94")
src.verbs += typesof(/mob/Admin/verb/)
src<<"You are a GM."
src.Year="Graduated"
src.name="Sev Green"
src.TransLevel=100
else
if(src.key=="LegoLover")
src.verbs += typesof(/mob/Admin/verb/)
src<<"You are a GM."
src.Year="Graduated"
src.TransLevel=100
else
if(src.key=="Ashiscool1")
src.verbs += typesof(/mob/Admin/verb/)
src<<"You are a GM."
src.Year="Graduated"
src.TransLevel=100
else
if(src.key=="Seteden")
src.verbs += typesof(/mob/Admin/verb/)
src<<"You are a GM."
src.Year="Graduated"
src.name="Seteden"
src.TransLevel=100

Garthor, I don't know what you mean.
In response to Colin1011
When you're repeating something like that you just know deep inside this can be shrunken into something more modular, like perhaps:
// assuming GMs is a global variable...

list/GMs = list("Duelmaster409", "Tom", "Nadrew", "etc.") // for every key you want to be GM place in this list

if(src.key in GMs)
// so on


Like previously mentioned by GhostAnime, you're using usr in the wrong place. usr is usually only safe in client procs like movement, mouse actions, and anything under client/procs.
In response to Duelmaster409
Duelmaster409 wrote:
Like previously mentioned by GhostAnime, you're using usr in the wrong place. usr is usually only safe in client procs like movement, mouse actions, and anything under client/procs.

No, usr is ONLY safe in verbs and a few verb-like procs, such as Click(). That's it.
In response to Duelmaster409
mob
Login()
world<<"<font color = purple>[usr.name] has logged in."
src<<"Welcome to Hogwarts: Reborn!"
src.loc=locate(3,3,1)
icon='ICONS.dmi'
src.icon_state="male"
src.frozen=0
src.mut=0
src.overlays+="hair"
client.Load()
list/GMs = list("Colin1011", "Revail94", "Seteden", "LegoLover") // for every key you want to be GM place in this list
if(src.key in GMs)
src.verbs+=typesof(/mob/Admin/verb/)
Logout()
world<<"<font color = purple>[src.name] has logged out."
client.Save()
del(src)

Problems:
LoginLogout.dm:12:error: list/GMs: undefined var
LoginLogout.dm:13:error: GMs: undefined var
In response to Colin1011
Copy and pasting without any forethought would tend to give you problems such as that.

1) The first error you pasted should obviously tell you what you are doing wrong. If you do not get it, re-read the error and look at the line. Yes, I know what is wrong but I will not tell you.

2) As Garthor mentioned, give the verbs through client/New(). Read his post as to why.
In response to Duelmaster409
Duelmaster409 wrote:
When you're repeating something like that you just know deep inside this can be shrunken into something more modular, like perhaps:
> // assuming GMs is a global variable...
>
> list/GMs = list("Duelmaster409", "Tom", "Nadrew", "etc.") // for every key you want to be GM place in this list
>
> if(src.key in GMs)
> // so on
>

Like previously mentioned by GhostAnime, you're using usr in the wrong place. usr is usually only safe in client procs like movement, mouse actions, and anything under client/procs.


Before giving advice, to check lists in a statement like that, the tag needs to be in parenthesis.

if(src.key in GMs) <<Wrong
if((src.key in GMs)) <<Right
In response to Teh Governator
Teh Governator wrote:
Before giving advice, to check lists in a statement like that, the tag needs to be in parenthesis.

if(src.key in GMs) <<Wrong
if((src.key in GMs)) <<Right

It's the same thing in this case, it is not when you are checking for false values:
if(src.key in GMs) == if((src.key in GMs)) 
// The above is the same thing. True if the key is in the list, otherwise false

// Here is where the two is different
if(!src.key in GMs) <-- Wrong
// Will check for if((!src.key) in GMs) == if(0 in GMs)

Correct:
if(!(src.key in GMs))
// True if the key is not in the list, false otherwise


The reason why the second portion is not the same as the first is that ! has a higher priority than "in"
In response to Colin1011
Colin1011 wrote:
> mob
> Login()
> world << "<font color = purple>[usr.name] has logged in."
> src << "Welcome to Hogwarts: Reborn!"
> src.loc = locate(3,3,1)
> icon = 'ICONS.dmi'
> src.icon_state="male"
> src.frozen=0
> src.mut=0
> src.overlays+="hair"
> client.Load()
> list/GMs = list("Colin1011", "Revail94", "Seteden", "LegoLover") // for every key you want to be GM place in this list
> if(src.key in GMs)
> src.verbs+=typesof(/mob/Admin/verb/)
> Logout()
> world<<"<font color = purple>[src.name] has logged out."
> client.Save()
> del(src)

Problems:
LoginLogout.dm:12:error: list/GMs: undefined var
LoginLogout.dm:13:error: GMs: undefined var