ID:147541
 
This might be a Newbie thing...dunno. Either way, on my worldsay command I made a muted thing, so that if the guy is muted, he cant say anything. It was working until recently when I added a command for Worldsay-toggle, and ignore commands. Now, whenever someone is muted, it says to them that they are muted, meanwhile it still says the things the person wanted to say to others. It will tell him, "Your voice has been removed!" but to everyone else, it will still say, "STFU!" or whatever the guy wanted to say. How can I stop this. here's my code:
mob
verb
World_Say(msg as text)
for(var/mob/M in world)
if(!M.worldsay_toggle&&!(src in M.ignore))
if(M.muted == 1)
M << "Your voice has been removed!"
else if(usr.key == "Metroid")
M << "\icon[usr] <font color=aqua><b>[usr] wsays: [html_encode:(msg)]</font>"
else if(usr.Admin == 1)
M << "\icon[usr] <font color=lime><b>[usr] wsays: [html_encode:(msg)]</font>"
else
M << "\icon[usr] <font color=white><b>[usr] wsays: [html_encode:(msg)]</font>"


Anyone help please, and can you make sure that it includes some message to tell the other people instead of what the guy wanted to say? Any help will be appreciated.
I think it might be because on that last else, you didn't use else if(blahblah)
In response to Buzzyboy
because I cant, its for every other regular players.
You're actually checking if the person RECEIVING the message is muted, not the person SENDING the message. =)

So what's happening is this: When a muted player uses world say, it loops through everyone in the world (including him). With every player in the world, it does this:

- If this player (M) is muted, tell them that they're muted. (So the "you are muted" message is getting displayed to src, when the loop gets around to src so that M==src. I hope you followed that explanation. =) )

- Otherwise, if src (the sender of the message) is Metroid, display the message in your colour.

- Otherwise, if src is an admin, display the message in the admin colour.

- Otherwise, display it normally.

So to fix this, you need to check if src is muted, not if M is muted. And you should do that check before the loop, not during it, otherwise the muted player will get flooded with "Your voice has been removed!" - if there are 30 people who haven't got him ignored and are listening to world say, he'll get it 30 times every time he says something. Not good, unless you're sadistic and want to spam muted players. ;-)
In response to Crispy
Is there a way to make it say to everyone else, that the muted person tried saying stuff, but he has no voice, or whatever?
In response to Crispy
would this work?

mob
verb
World_Say(msg as text)
if(src.muted == 1)
src << "Your voice has been removed!"
world << "\icon[usr] <font color = white>[usr] tried saying something, but his voice was removed!</font>"
else
for(var/mob/M in world)
if(!M.worldsay_toggle&&!(src in M.ignore))
else if(usr.key == "Metroid")
M << "\icon[usr] <font color=aqua>
[usr] wsays: [html_encode:(msg)]</font>"
else if(usr.Admin == 1)
M << "\icon[usr] <font color=lime>[usr] wsays: [html_encode:(msg)]</font>"
else
M << "\icon[usr] <font color=white>
[usr] wsays: [html_encode:(msg)]</font>"
In response to Metroid
Metroid wrote:
would this work?

mob
verb
World_Say(msg as text)
if(src.muted == 1)
src << "Your voice has been removed!"
world << "\icon[usr] <font color = white>[usr] tried saying something, but his voice was removed!</font>"
else
for(var/mob/M in world)
if(!M.worldsay_toggle&&!(src in M.ignore))
else if(usr.key == "Metroid")
M << "\icon[usr] <font color=aqua>
[usr] wsays: [html_encode:(msg)]</font>"
else if(usr.Admin == 1)
M << "\icon[usr] <font color=lime>[usr] wsays: [html_encode:(msg)]</font>"
else
M << "\icon[usr] <font color=white>
[usr] wsays: [html_encode:(msg)]</font>"

Probably, im not too sure what your actually trying to accomplish, BUT the person that is muted will still be able to spam with the message "tried saying something, but his voice was removed!" constantly, I advise to remove that message.