ID:154226
 
Well I thought I had it planned out how I was going to do this but now that I've almost got it all coded the last part has me stumped. I wish to add in an ignore option for my players. Each person will have their own list. So they can add and remove people from it as they wish. All that happens when u add someone to a list is thier name gets added.

Now the trouble part, how could I go about blocking saw someone's world << "Text" from going to the person that has them ignored??

LJR
LordJR wrote:
Well I thought I had it planned out how I was going to do this but now that I've almost got it all coded the last part has me stumped. I wish to add in an ignore option for my players. Each person will have their own list. So they can add and remove people from it as they wish. All that happens when u add someone to a list is thier name gets added.

Now the trouble part, how could I go about blocking saw someone's world << "Text" from going to the person that has them ignored??

You can't block "world" itself. You'd need to actually make a proc that builds a list of people who are allowed to read it.

For example:

mob/proc/world()
var/list/L = list()
for(var/mob/M in world)
if(!M.ignore.Find(src.key))
L += M
return(L)


Now you can use

world() << "Text"

and everyone who is ignoring this user will see nothing. Neat, eh?
This should work:
mob/var/list/Blocked = list()
mob/verb
Add2Blocked(var/mob/M as mob in world)
Blocked.Add(M)
DelFromBlocked(var/mob/M in Blocked)
Blocked.Remove(M)
mob/verb/Chat(var/message = "")
for(var/mob/M in world - Blocked)
M << "[src.name]: [message]"
LordJR wrote:
Now the trouble part, how could I go about blocking saw someone's world << "Text" from going to the person that has them ignored??

You won't be able to use world << "Text". You'll have to write your own routine that loops through each player, determines if the player is ignoring the source of the text, and if not, display the text to the individual player.
proc/Output(message as text, reciever = world.contents, mob/sender = usr)
/* sender is sending message to every player in
reciever. world.contents is an extremely inefficient
list for this purpose. You should make a list of
connected players to speed up loops like this. */


if(ismob(reciever))
var/mob/M = reciever
if(sender in M.ignore_list) return
M << message

else if(istype(reciever,/list))
for(var/mob/M in reciever) // loop through all the mobs in the recive list
if(sender in M.ignore_list) continue // skip to the next mob
M << message

else // unrecognized reciever type
world.log << "Unrecognized reciever type in output(): [reciever] ([reciever.type])"


Here are some examples using the above Output() proc
</dm>
mob/verb
say(msg as text)
desc = "(message) Message everyone in view."
Output("[src] says: [msg]",view())

shout(msg as text)
desc = "(message) Message everyone in the world."
Output("[src] shouts:[msg]") // uses default values for the other two arguments

tell(mob/M, msg as text)
desc = "(target, message) Send a private message to one target."
Output("[src] tells you: [msg]", M)
src << "You tell [M]: [msg]"
</dm>