Jump to content

[Martysama source] guild_manage.quest


tierrilopes
 Share

Recommended Posts

Implementação da função de criar guild.

Spoiler

quest guild_manage begin
		state start begin
				when guild_man1.chat."Leave Guild" or guild_man2.chat."Leave Guild" or guild_man3.chat."Leave Guild"
						with pc.hasguild() and not pc.is_guild_master() and (pc.is_gm() or npc.empire == pc.empire) begin
						say_title("Guardian:")
						say("")
						say("Do you really want to leave the guild you belong to? I")
						say("think you will only lose friends that way.")
						say("")
						say("But it's your decision. So, do you really want to leave")
						say("this guild?")
						say("")
						local s = select("Yes", "No")
						if s==1 then
								say_title("Guard of the Village Square:")
								say("")
								say("Allright.")
								say("")
								say("I will strike you out of the guilds roll.")
								say("")
								pc.remove_from_guild()
								pc.setqf("new_withdraw_time",get_global_time())
						end
				end

				when guild_man1.chat."Disband my Guild" or guild_man2.chat."Disband my Guild" or guild_man3.chat."Disband my Guild"
						with pc.hasguild() and pc.is_guild_master() and (pc.is_gm() or npc.empire == pc.empire) begin
						say_title("Guard of the Village Square:")
						say("")
						say("What?")
						say("[DELAY value;150]		  [/DELAY]")
						say("I created it with much efforts and now you want to")
						say("disband it? All the experience and all the remembrance")
						say("about your friends will be lost forever!")
						say("")
						say("Do you really want to disband it?")
						say("")
						local s = select("Yes", "No")
						if s==1 then
						say_title("Guard of the Village Square")
						say("")
						say("Ok.")
						say("")
						say("I will disband the guild you are leading.")
						say("")
						pc.destroy_guild()
						pc.setqf("new_disband_time", get_global_time())
						pc.setqf("new_withdraw_time", get_global_time())
						end
				end

				when guild_man1.chat."Create a new Guild" or guild_man2.chat."Create a new Guild" or guild_man3.chat."Create a new Guild" with not pc.hasguild() and pc.level >= 40 begin
						local level_limit
						local guild_create_item

						level_limit = 40
						guild_create_item = false

						if pc.hasguild() then
							say_title("Guardian:")
							say("")
							say("You cannot create a Guild while you are still")
							say("a member of a Guild!")
							say("")
								return
						end
						if game.get_event_flag("guild_withdraw_delay")*86400 >
								get_global_time() - pc.getqf("new_withdraw_time") then
						say_title("Guardian:")
						say("")
						say("In the first day after leaving your guild, you")
						say("cannot establish a new one.")
						say(string.format("", game.get_event_flag("guild_withdraw_delay")))
						return
						end

						if game.get_event_flag("guild_disband_delay")*86400 >
								get_global_time() - pc.getqf("new_withdraw_time") then
						say_title("Guardian:")
						say("")
						say("You have recently disbanded a guild!")
						say("")
						say("In the next 24 hours you cannot establish a new one.")
						say(string.format("", game.get_event_flag("guild_disband_delay")))
						return
						end
						say_title("Guardian:")
						say("")
						say("You would like to establish a guild?")
						say("")
						say("Creating a guild costs 200.000 Yang and is only allowed")
						say("to citizens of level 40 or higher.")
						say("")
						say("Are you sure you want to establish a guild?")
						say("")
						local s = select("Yes", "No")
						if s == 2 then
								return
						end

						if pc.level >= 40 then
						if pc.gold >= 200000 then
								if not guild_create_item or pc.countitem(guild_create_item)>0 then
										--pc.remove_item(70101) --Remove guild item
										local guild_name = string.gsub(input(), "[^A-Za-z0-9]", "")
										local guild_len_name = string.len(guild_name)
										if not ((2 < guild_len_name) and (guild_len_name < 12)) then
											say_reward("Error creating guild, guild name must be 2-12 characters long.")
											return
										end
										local ret = pc.make_guild0(guild_name)
										if ret==-2 then
										say_reward("Error creating guild, guild name must be 2-12 characters long.")
										elseif ret==-1 then
											say_reward("Error creating guild, special characters not allowed.")
										elseif ret==0 then
											say_reward("Error creating guild. A guild with name "..guild_name.." already exists.")
										elseif ret==1 then
											pc.change_gold(- 1000000000 )
											say_reward("Guild "..guild_name.." sucessfully created.")
										elseif ret==2 then
											say_reward("You are already member of a guild.")
										elseif ret==3 then
											say_reward("You are already guild master.")
										end
								end
								else
								say_title("Guardian:")
								say("")
								say("You don't have enough Yang!")
								say("")
								return
								end
						else
						say_title("Guardian:")
						say("")
						say("Your level is too low for establishing a guild.")
						say("")

						end
				end

		end
end

 

Adicionar em quest_functions:

pc.make_guild0

 

 

guild_manage.quest

guild_manage.quest

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...