ID:270170
 
var/list/Guilds = newlist() //The list that all of the guilds will be going in.
mob
var
Guild = "" //variable holding the guilds name.
GuildTag = "" //variable holding the players rank in the guild.
InGuild = 0 //variable for if a player is in a guild or not 1 = yes 0 = no
GuildOfficer = 0 //variable for guild officer 1 = yes 0 = no.

verb
Create_Guild(msg as text)//Creates an input box for the user to input his/her guild name.
set category = "Guild" //The verb panel's name the guild commands are going in.
set name = "Guild: Create" //the name of the verb.
if(length(msg)<2) //if the length of the name of the guild is less than 2 then execute the next commands
alert("Guild name is too short.")// alerts the user his/her guild name is too short
return //stops the verb from going any further
if(findtext("",msg))//if the user didn't type anything at all
alert("You need to type something to make a guild.")//alerts the user he/she needs to actually type a name for their guild.
return //if the above is true it stops the verb from going any further.
if(findtext("GM",msg))//if the user didn't type anything at all
alert("You cannot create this Guild.")//alerts the user he/she needs to actually type a name for their guild.
return //if the above is true it stops the verb from going any further.
if(usr.InGuild == 0) // if the user is not in a guild
Guilds += "[msg]" // add the users guild to the list of guilds.
src << "You have successfully created the new guild [msg]</b>'." // let the user know he succesfully created a guild.
src.Guild = "[msg]" //sets the users guild to his/her guild name
src.GuildTag = "Guild Owner" //establishes that the user is the owner.
src.InGuild = 1 // the user is now in a guild.
src.GuildOfficer = 1 // the user is a guild officer
src.GuildCheck() // calls the guildcheck proc giving the user the commands he/she needs.
else// else if the user is in a guild then he can't make one.
alert("You are already in a guild")// alerts the user that he/she is already in a guild.
return//stops the command from executing anything else.

proc
GuildCheck()// name of the procedure were using to check for guild rank and supply the user with his/her commands.
if(src.GuildOfficer == 1) // if the user is an officer
src.verbs += typesof(/mob/GuildOfficerCommands/verb) //add all the guild officer commands
if(src.InGuild == 1) // if the user is in a guild
src.verbs += typesof(/mob/GuildCommands/verb) // add the necessary verbs

GuildCommands//Commands for players in a guild.
verb
GuildWho()
set category = "Guild"
set name = "Guild: Who"
src << "<font color = blue><b>Guild Members:</b></font>" //sends a blue message 'Guild Members:' to the user.
for(var/mob/M in world)//sets M as every mob in the world.
if(M.Guild == src.Guild) //checks if any M's guilds = the users guild.
if(M.InGuild == 0) //unless ovcoarse M isn't in a guild at all.
return()//returns nothing.
else// if M is then
src << "<font color = blue><b>{[M.GuildTag]}[M]</b></font>"//tells the user all of the M's in his guild.

GuildSay()
set category = "Guild"
set name = "Guild: Say"
var/msg = input("What would you like to say to the members in your guild?") as text //sets up an input box for the message the user wants to send to his guild members.
for(var/mob/M in world)//sets M as every mob in the world.
if(M.Guild == src.Guild)//if M is in the users guild then
if(M.InGuild == 0) // if by some chance GuildCheck got bugged and a user had the commands it wouldn't spam all the users not in a guild.
return()//Muahahaha
else
M << "<font color = blue><b>Guild Chat: ([usr.GuildTag])[src]: [msg]</b></font>" //in blue font everyone in the users guild will get the users message.

GuildLeave()
set category = "Guild"
set name = "Guild: Leave"
src << "You have left the guild [usr.Guild]"
src.InGuild = 0 //resets the users inguild variable making them no longer in a guild in normal people talk.
src.Guild = "" //resets their guild name back to nothing.
src.GuildTag = "None" //they no longer have a rank if they aren't in a guild.
src.GuildOfficer = 0 //their definitely not an officer
src.verbs -= /mob/GuildOfficerCommands/verb/Guild_Invite //takes away the users guild invite command
src.verbs -= /mob/GuildCommands/verb/GuildWho //takes away the users guild who command
src.verbs -= /mob/GuildCommands/verb/GuildSay //takes away the users guild say command
src.verbs -= /mob/GuildCommands/verb/GuildLeave //takes away the users guild leave command.

GuildOfficerCommands //commands for a guild officer
verb
Guild_Invite(mob/M in world)//invites a mob you select in the world.
set category = "Guild"
set name = "Guild: Invite"
if(M.InGuild == 0) // if the user isn't in a guild
if(src.GuildTag == "Owner"||src.GuildTag == "Officer"||src.GuildTag == "Recruiter" && src.InGuild == 1)
switch(alert(M,"[M] you have been invited to join the guild [usr.Guild] by [usr]","Guild Invitation","Yes","No"))// alerts M that he/she has been invited to join the users guild.
if("Yes")//if M selected yes.
M <<"You have joined the guild [src.Guild]"//tells M he is now in users guild.
M.Guild = src.Guild //M's guild is now the same as the users.
M.GuildTag = "Member" //M's rank is by default initiate
M.InGuild = 1 //M is in a guild
M.GuildCheck()// calls guild check to give him/her the guild commands.
for(var/mob/G in world)//G being all the mobs in the world
if(G.Guild == src.Guild) //if G is in the users guild
G << "[M] has joined the guild" // let everyone in the guild know that M just joined the guild.
if("No")// if M selects no
src << "[M] has declined your guild invite"// tells the user that M has declined the invite
return()//stops the verb from going any further
else//if the user somehow has the verb and isn't an ower/officer/recruiter then do nothing.
return()
else// if the user is in a guild then
alert("That player is already in a guild")//tells the user that the player is already in a guild
return()



well people... this it my guild code, and i want to know how i put a "member counter" to put the maximum members in a guild
Hmm. Seems like a demo or lib, so it isnt yours. Also, if you knew how to make that, adding a member limit should be easy.

Make a variable called guildLimit and guildLimitMax (or something like that(set guildLimitMax to what ever you want the max limit to be). Them, have it check guildLimitMax and add one to guildLimit when someone joins if it doesnt == guildLimitMax. If it =='s guildLimitMax fail and give an error. Remove one from guildLimit when someone leaves or is kicked.

The above is abit confising when read, but you should get the general idea on how todo this. I could give you code todo it, but it would be horrible and bug filled.
In response to Smoko
Smoko wrote:
Hmm. Seems like a demo or lib, so it isnt yours. Also, if you knew how to make that, adding a member limit should be easy.

Make a variable called guildLimit and guildLimitMax (or something like that(set guildLimitMax to what ever you want the max limit to be). Them, have it check guildLimitMax and add one to guildLimit when someone joins if it doesnt == guildLimitMax. If it =='s guildLimitMax fail and give an error. Remove one from guildLimit when someone leaves or is kicked.

The above is abit confising when read, but you should get the general idea on how todo this. I could give you code todo it, but it would be horrible and bug filled.

but the var is defined to whom?the guildmaster?

EDIT

now all ok, thanks
In response to Pharaoh Atem
Pharaoh Atem wrote:
Smoko wrote:
but the var is defined to whom?the guildmaster?
yea you didn't write the original code >.>
In response to Pharaoh Atem
I would reccomend you keeping a list of members for each guild and making a Guild datum thing, sort of like for chatrooms- each guild gets its own datum with its own member list, and you could just check the list's len var to see how many things are in it.