See anything wrong with this?:
//Need to find a unique way of making a new guild.
//The guild variable is to see if they're in a guild yet
//or not, i'll add an if() statement for it when I decide
//Exactly how i'm going to create guilds.
mob/var/leader = 0
mob/var/guild = 0
var/list/Guilds = list()
guild_system
var
list/Guildmembers = list()
members = 0
leadername = ""
New()
..()
members +=1
Guildmembers.Add(src)
MakeLeader()
owner
verb
Transfer_Leadership(mob/M in Guildmembers)
set category = "Guild"
if(M == src)
src << "You cannot transfer leadership to yourself."
else
MakeNewLeader(M)
AnnounceNewLeader(M)
return
Invite_User_To_Guild(mob/M in world)
set category = "Guild"
if(M == src)
src << "You cannot invite yourself."
else
if(M.guild == 1)
src << "[M] is already in a guild."
else
Guildmembers.Add(M)
members+=1
M << "You are now a member of the guild."
M.guild = 1
verb
Teleport_To_Guildmate(mob/M in Guildmembers)
set category = "Guild"
if(M == usr)
usr << "You cannot teleport to yourself."
else
usr.loc = M.loc
M << "There's a flash. [usr] appears before your eyes."
proc/MakeLeader(mob/M in Guildmembers)
if(members == 1)
M.verbs+=typesof(/guild_system/owner/verb)
M << "You are the leader."
M.leader = 1
leadername = "[M]"
M.guild = 1
return
else
return
proc/MakeNewLeader(mob/M in Guildmembers)
M.leader = 1
leadername = "[M]"
return
proc/AnnounceNewLeader()
for(var/mob/M in Guildmembers)
M << "The new leader is [leadername]."
Also, What is YOUR opinion on Loading/Saving datums? What's the best way?
I see a few problems. I'll point them out as they appear.
mob/var/leader = 0
I wouldn't bother with an extra var just to flag if you are leader. Check your guild's leadername and see if it matches your name instead.
There is no need for a members var. You can just use Guildmembers.len to report how many members are in that list. I'd remove the var and any existing modifications to it, then use Guildmembers.len when you need to check the number of memebers.
src in this New() proc is the /guild_system instance that is being created. I don't think you want to add it to the Guildmembers list. You should pass the mob creating the guild into New() as an argument, then add that mob to the members list.
Your MakeLeader() proc needs an argument as you defined it. Pass the creating mob to it.
This defines owner as a subtype of /guid_system. Is that what you mean to do? The guild owner will not automatically get the verbs defined here. You need to add them to the mob in MakeLeader().
MakeNewLeader() is redundant and unnecassary. Remove the conditionals from in MakeLeader() and use it whenever leadership changes.
You sould also check to see if there is an existing leader, and if there is, remove his special leader options.
Again, these verbs do not become available to mobs in the guild unless you add them to the mob when the mob joins.
You could shorten AnnounceNewLeader() to this:
It will send the message to everyone in that list.
The saving is simple. Just send the datum to the save file like any other atom or variable. You could even save the guilds list in one line and it will automatically save all the guilds in the list.
However the way you did your member list will cause problems. You store the actual mobs in the member list, which means that when it's saved, it saves a copy of each mob. When the guild is loaded, those old mobs will be loaded as well, and the client will get sucked back into the old mob.
Make the guildmembers list a tmp var so that it is not saved. That will become a list of online guild members and you can use it for sending guild messages and such.
You will want a second list of members that you CAN save with the datum. Since you can't use the mob itself, just store the mob name. This will be the list that you use to see how many members you have with the list.len var.
When a player logs into the game, check their guild var. If it is set, check that guild's membername list to make sure the player is a member, then you can add the player's mob to the Guildmembers list to note that he is online and add the guild verbs to his verbs.