ID:147878
 
As you might know, I have a command in my game that will block out text from certain users as long as they're in the blocked list. But, inevitably, I've come across a problem that requires BYOND's greatest to aid me.
        Block_User()
set desc = "Block or unblock a user's text."
var/list/whatever= new
var/howmanypeople=0
for(var/mob/K in world)
if(K.client)
whatever+=K
howmanypeople+=1
whatever+="Cancel"
whatever-=usr
howmanypeople+=1
if(howmanypeople <= 0)
return
else
var/mob/C=input ("Block or unblock a user?","Block/unblock user") in list("Block","Unblock","Cancel")
if(C == "Cancel")
return
if(C == "Block")
var/mob/T=input ("Who do you want to block?","Block user")in whatever
if(T=="Cancel")
return
if(T.Owner == 1)
usr << "<font color=green><b>You cannot block the owner's text."
return
if(T.MGM == 1)
usr << "<font color=green><b>You cannot block an MGM's text."
return
if(T.GM == 1)
usr << "<font color=green><b>You cannot block a GM's text."
return
if(T.Admin == 1)
usr << "<font color=green><b>You cannot block an admin's text."
return
else
if(findtext(usr.client.blocked,T) == 1)
usr << "<font color=green><b>[T] has already been added to the blocked list."
return
usr.client.blocked += T
usr << "<font color=green><b>Added [T] to the blocked list."
if(C == "Unblock")
var/mob/U=input ("Who do you want to unblock?","Unblock user") as null|anything in usr.client.blocked
if(!U) return
usr << "<font color=green><b>Removed [U] from the blocked list.</font></b>"
usr.client.blocked -= U

client
New()
..()
var/blocked = Import()
if(blocked)
var/savefile/Q = new(blocked)
Q >> blocked
return ..()
Del()
var/savefile/Q = new ("blocked.sav")
Q["blocked"] << blocked
usr.client.Export(Q)
..()

I don't get any runtime errors, and the savefile seems to be correctly exported to the player's PC, but when I try to unblock someone, nothing happens. Any help?
How far along the block does it get before it doesn't do what you want? Does it execute the code for the if(C=="Unblock")? Does it get past the if(!U)?

Also, you are using findtext to search for something in a list. I suggest you use if(T in usr.client.blocked) instead of if(findtext(usr.client.blocked,T)==1).
In response to Loduwijk (#1)
Canceling and using the "Block" option works just fine, but if I were to select "Unblock", it does nothing.
In response to Enigmaster2002 (#2)
I suspect that much, but I was asking if you knew which lines are executing and which are not, if it is indeed the desired lines not being executed.

Try adding some debug lines into it like so:
>               if(C == "Unblock")
world<<"begin"
> var/mob/U=input ("Who do you want to unblock?","Unblock user") as null|anything in usr.client.blocked
world<<U
> if(!U) return
world<<"!return"
> usr << "<font color=green><b>Removed [U] from the blocked list.</font></b>"
world<<"should be unblocked, but isn't"

Doing that, you should be able to get a pretty good idea of what line is causing the problem.
In response to Loduwijk (#3)
All I get is "Begin."
In response to Enigmaster2002 (#4)
Then you have found your problem. U is null and is most likely returning at your if(!U)return line. Is it even letting you choose the person you want to be unblocked? If you are not even getting the input to choose then I would assume your list is empty at that point.

[edit]
I just went back and reviewed the original post once again. I noticed that you did not say whether these were client-verbs or what, just that they were commands that get called. The player to input something at an input() defaults to the usr, so if the player is the src but not the usr, then make sure you change the input to input(src,other-stuff-here).

[edit again]
Also, you say that block works just fine. I would suggest you make sure that the savefile does in fact contain what you want it to. Also, make sure that it is inputting that data into the blocked list appropriately. You could check to make sure your list is not empty by sticking a for(var/i in blocked)src<<i in there.
client/Del() isn't necessarily usr-safe; that should be mob, not usr.

Lummox JR