I need some help...I want to make a chat command that only allows people with the chatchan = 1 to be able to c the world say...what would my proc look like? Heres my Chat_Switch...
mob
verb
Chat_Switch()
var/chat = input("Turn on or off?")in list("On","Off","Cancel")
switch(chat)
if("On")
usr.chatchan = 1
if("Off")
usr.chatchan = 0
else
return
Thanx,
Punkrock546
ID:177359
Sep 17 2002, 4:09 pm
|
|
Here's what I would do.
Following code is untested, but I think it should work. If it doesn't, it's my fault for not testing it beforehand. mob/verb WorldSay(msg as text) for(var/mob/M in world) if(M.chatchan == 1) M << "[usr]:[msg]" else continue |
In response to Malver
|
|
Of course, having a global list,
var/list/Players = list() Then upon login mob/Login() ..() Players += src And logout... mob/Logout() Players -= src ..() Then using for(var/mob/M in Players), it will be more efficient. |
In response to Garthor
|
|
For games with larger amounts of mobs, this is definitely true.
But, the point of focus was on how to make the chat channel, not on how to optimize it. |
It's as simple as that. All I did here was scroll through all of the mobs that have clients and have the chat channel on. Hope that helps. :)