ID:140342
 
Code:
ADMIN
verb
Ban(mob/M as null|anything in players)
world << "<center>[M] was banned by [usr.key]!</center>"
banned += M
M.Logout()


Problem description:
I get a runtime error:
runtime error: Cannot execute null.Logout().
proc name: Ban (/ADMIN/verb/Ban)
usr: Hi1 (/mob)
src: Hi1 (/mob)
call stack:
Hi1 (/mob): Ban(null)


Then it says:
was banned by Hi1!

I'm guessing it's trying to ban "null"?
Thanks in advance to any help!

~Hi1

Yes. That is what happens when you select null out of the list. You need to check to see if M is null before doing anything.

You also shouldn't call Logout() directly. I suggest just deleting them. Or, perhaps more elegantly, their client.
In response to Garthor
Garthor wrote:
Yes. That is what happens when you select null out of the list. You need to check to see if M is null before doing anything.

You also shouldn't call Logout() directly. I suggest just deleting them. Or, perhaps more elegantly, their client.

Well, I got it to not give me the error, but now no list box pops-up...
In response to Hi1
If there is only one item, it will automatically choose that item. This may be your problem.
You could try adding a "Cancel" option to your list. I think it would go something like...
Ban(mob/M as null|anything in players+"Cancel")
if(M!="Cancel")
...
else
return
In response to Redslash
There's no reason to have a "Cancel" option if you're already getting a Cancel button from null|anything. The issue is that the players list is empty.
In response to Garthor
Ah, so is that what the null|anything did...
In response to Garthor
Well, this is how I'm adding players to the list:
// ADDING //
mob/Login()
players += src.client.mob

// REMOVING //
mob/Logout()
players -= src.client.mob


Then, I'm using this code for booting/banning:
ADMIN
verb
Boot(mob/M as null|anything in players)
if(!M)
return
if(M.client)
world << "<center><b>[M.key] was booted by [usr.key]!</b></center>"
M.Logout()
else
del(M)
Ban(mob/M as null|anything in players)
if(!M)
return
world << "<center>[M] was banned by [usr.key]!</center>"
banned += M
M.Logout()


I don't see what's wrong...
In response to Hi1
You should just be adding src to the players list, not src.client.mob. However, I can't really think of a situation where there would be a difference, unless you're calling Logout() directly (which you are).
In response to Garthor
Garthor wrote:
You should just be adding src to the players list, not src.client.mob. However, I can't really think of a situation where there would be a difference, unless you're calling Logout() directly (which you are).

I changed it to del(M) but it still doesn't work...
In response to Hi1
I noticed that your not using ..() to call the default in mob/Login()

Do you have another mob/Login() in the code that may be blocking this one?
In response to Pirion
No, that's just part of my Login() code. I do use ..().
In response to Hi1
I tested this and it worked perfectly...do you have anything much different to this?

var/list
players = new()
banned = new()

mob/Login()
..()
players += src
verbs+=typesof(/ADMIN/verb)

// REMOVING //
mob/Logout()
players -= src
..()

ADMIN
verb
Boot(mob/M as null|anything in players)
if(!M)
return
if(M.client)
world << "<center><b>[M.key] was booted by [usr.key]!</b></center>"
M.Logout()
else
del(M)
Ban(mob/M as null|anything in players)
if(!M)
return
world << "<center>[M] was banned by [usr.key]!</center>"
banned += M
M.Logout()

Like Ganthor said, src.client.mob, and src don't make much of a difference here.
In response to Pirion
Hmm, I made my list like:
var/players = list()

Would that make it not work??
In response to Hi1
No, that would not affect it.

The most likely explanation is that something is blocking that Login() from being called at all.
In response to Garthor
Login() is being called, because I'm having the windows maximize and a window show in the Login(), they're both happening...
In response to Hi1
Is it the same Login()?

Does the players list contain anything? Use a verb to check it.
In response to Garthor
I checked it, it contains "Hi1"...but the boot/ban verbs still don't show any list at all...
In response to Hi1
What you've been told to do in this thread works perfectly fine.

Post what you have, again.
In response to Garthor
My Login/Logout:
mob/Login()
..()
players += src
winset(src, "Main", "is-maximized=true")
if(src.key in banned)
src << "<font color=red><b>You're banned...</b></font>"
del(src)
if(src.key in admins)
src.verbs += typesof(/ADMIN/verb/)
winset(src, "admin_menu", "is-disabled=false")
src.loc=locate(5,3,1)
src << output({"
<center><b><u>Updates:</u></b></center><br><br>
<u>Version 0.5</u><br>
\tAdded this "Updates" Window, as well as "Guide", also fixed a bug dealing with Say.<br><br>
"}
, "Updates_Output")

mob/Logout()
players -= src
sleep(20)
del(usr)
if(playing)
Save()
else
return
..()


My ADMIN verbs:
var
admins=list("Hi1")
banned=list()
players=list()

ADMIN
verb
Announce(M as message)
world << "<center><b>[usr.key] Announces:</b></center>\n[M]"
Boot(mob/M as null|anything in world)
if(!M)
return
if(M.client)
world << "<center><b>[M.key] was booted by [usr.key]!</b></center>"
M.Logout()
else
del(M)
Ban(mob/M as null|anything in players)
if(!M)
return
world << "<center>[M] was banned by [usr.key]!</center>"
banned += M
M.Logout()
UnBan(mob/M in banned)
switch(alert("Really UnBan [M.key]?","Really?","Yes","No"))
if("Yes")
banned -= M.key
world << "<center>[usr.name] has unbanned [M.key]!</center>"
else
return
In response to Hi1
Your boot verb is using "in world" instead of "in players".

You also are using usr in Logout(), which again is very very very very very wrong. Oh, and if you change it to del(src) which it should be, then it's still wrong because nothing after that will get executed.
Page: 1 2