ID:155280
 
What the heck was the guild chat set up?



mob/Crew_Recruiter// advanced member
verb
Recruit_Member(mob/M as mob in oview(1))
if(M.in_crew)
alert("[M] is ALREADY in another Crew!")
else if(M.crew_name==src.crew_name)
alert("[M] is ALREADY in your Crew!")
else
switch(alert(M,"Would you like to join [src.crew_name]?",,"Yes","No"))
if("Yes")
M.crew_name=src.crew_name
alert("[M] joined your crew.")
if("No")
alert("[M] refused your invitation.")

mob/Crew_Veteran
verb
Crew_Chat()//forgot :D
mob/Crew_Member//basic member
verb
Crew_Chat()//forgot :D


Edit: Basically asking how to set up a private chat between a group of people.
mob
verb
GuildChat(T as text) // Guild Chat verb, T is input text
for(var/mob/M in world) // Loop through all mobs
if(M.Guild == src.Guild) // If a person is of the same guild
M << "[src.name] Guild-Says: [T]"
In response to Lugia319
already solved it right after i posted but thanks xD
In response to Lugia319
You should probably not loop over everyone in the world every time someone chats. You'd be better off using a list that contains all of the people in the guild, then just output to that. You could either keep track of it with a global multi-dimensional list, or a simple list belonging to the players that gets updated as people join and leave the game. The first one is probably the least resource intensive as far as having to loop and keep track of data.

var/list/guild_members = list()
// We'll make this formatted like "Guild Name" = list()
// Where the embedded list contains references to the mobs in the guild.

mob
Loaded() // This is an example, you'd do the following after the player's info is loaded.
if(guild)
if(!guild_members[guild]) guild_members[guild] = list()
guild_members[guild] += src
Logout()
if(guild)
guild_members[guild] -= src
..()


This will keep track of guild members globally without storing much more than references to mobs. Now when you want to output something to everyone in a guild you just have to do something like:
var/list/members = guild_members[some_guild]
members << "This is some message to the guild."


Cuts down on looping a ton, just gotta be sure to properly add and remove people from the list. Deleting a player would automatically remove them from the list, so you don't always have to keep track of that instance -- but you should anyways.