Jump to content

[HELP]Rejoin dungeon after map index delete


Go to solution Solved by Syreldar,

Recommended Posts

First of all, sorry for my bad English.
Hi guys, I'm still a beginner in coding, so whether this script is good or not, I'm currently learning and I have a little problem.

When the server automatically destroys the dungeon map_index, I don't know how to create a new one and reconnect to the new one... (if this possible :D)

And if anyone has a solution for this crap: when kill_check.timer starts, because it's not the best, I'd appreciate it, I tried using unquie, but d.count_monster still didn't count the monsters.

quest azrael begin
	state start begin
		function get_settings()
			local settings = {}
			settings.map = 216
			settings.start_cord = {3617,12074}
			settings.item = 30012
			settings.warp_back = {5902,987,65}
			settings.ff_time = 5
			settings.jump_3 = {4444, 12281}
			settings.jump_4 = {3142, 12611}
			settings.jump_5 = {3917, 12923}
			settings.jump_6 = {4375, 12736}
			settings.jump_7 = {3146, 13185}
			settings.teki = {30103, 741, 223, 1}
			settings.runa = {30104,500, 726}
			settings.charon = {2597,1301, 708}
			settings.azrael = {2598,74, 1104}
			settings.tartaros = {2591}
			return settings
		end

		function sapwn_doors()
			local spawnd_1 = {
				{30111,566,117,5},
				{30112,562,311,5},
				{30118,663,434,7},
				{30119,881,434,7},
				{30116,743,390,3},
				{30119,612,251,1},
				{30113,654,211,5},
				{30111,707,338,7},
				{30112,775,336,7},
				{30117,733,294,3},
				{30113,694,271,1},
				{30115,942,141,5},
				{30116,942,245,5},
				{30117,942,321,5},
				{30115,763,64,7},
				{30118,643,116,3},
				{30114,900,167,1},
				{30114,850,293,5},
				{30113,715,164,7},
				{30114,817,162,7},
				{30111,802,277,1},
				{30112,800,241,1}
			}
			
			local get = azrael.get_settings()
			local map = get
			local lvl = d.getf("level")
			for i = 1, table.getn(spawnd_1) do
				local mob = spawnd_1[i][1]
				local x = spawnd_1[i][2]
				local y = spawnd_1[i][3]
				local p = spawnd_1[i][4]
				d.spawn_mob_dir(mob, x, y, p)
			end
		end
		
		function spawn_kovek()
			local kovek = {
				{8038,1366,150,1},
				{8038,1366,351,1},
				{8038,1234,365,1},
				{8038,1234,140,1},
				{8038,1150,135,1},
				{8038,1130,365,1},
				{8038,1135,253,1},
				{8038,1348,250,1}
			}
			
			for i = 1, table.getn(kovek) do
				local mob = kovek[i][1]
				local x = kovek[i][2]
				local y = kovek[i][3]
				local p = kovek[i][4]
				d.spawn_mob_dir(mob, x, y, p)
			end
		end
		
		function green_way()
			local get = azrael.get_settings()
			local pid_info = {}
			local ppid = {party.get_member_pids()}
			local item_vnum = get.item
		
			local all_ok = true
		
			for _, pid in ipairs(ppid) do
				q.begin_other_pc_block(pid)
				local name = pc.get_name()
				local count = pc.count_item(item_vnum)
				local lvl = pc.get_level()
				q.end_other_pc_block()
		
				local no_item = (count < 1) and 1 or 0
				local no_lvl = (lvl < 70) and 1 or 0
		
				if no_item == 1 or no_lvl == 1 then
					all_ok = false
				end
		
				table.insert(pid_info, {name, no_item, no_lvl})
			end
		
			for _, player in ipairs(pid_info) do
				local name = player[1]
				local no_item = player[2]
				local no_lvl = player[3]
		
				if no_item == 1 or no_lvl == 1 then
					local msg = name .. ": "
					if no_item == 1 then
						msg = msg .. "Nincs tárgy"
					end
					if no_lvl == 1 then
						if no_item == 1 then
							msg = msg .. ", "
						end
						msg = msg .. "Nincs szint"
					end
					say(msg)
				end
			end
			return all_ok
		end
		
		function clear_all()
			local get = azrael.get_settings()
			local cord = get.warp_back
			party.setf("azi_index",0)
			party.setf("in_azi",0)
			d.setf("level",0)
			if party.is_party() and pc.in_dungeon() then
				pc.warp(cord[1],cord[2],cord[3])
				d.exit()
				cleartimer("ff_check")
				party.setf("mob_kill",0)
				cleartimer("ff_leave")
			end
		end
		
		function skip_lvl()
			local level_t = {
				{2, "jumpto_3"},
				{3, "jumpto_4"},
				{4, "jumpto_5"},
				{5, "jumpto_6"},
				{6, "jumpto_7"}
			}
			
			if party.getf("skip_item") == 0 then
				local lvl = d.getf("level")
				say("Át szeretnéd lépni ezt a szintet?")
				say()
				local skip = select("Igen", "Nem")
				if skip == 1 then
					for i = 1, table.getn(level_t) do
						local currlvl = level_t[i][1]
						local timer_name = level_t[i][2]
						if currlvl == lvl then
							-- d.setf("level", currlvl + 1)
							timer(timer_name, 5)
							-- party.setf("skip_item", 1)
							break
						end
					end
					notice("Elhasználtatok egy belépőt.")
					notice("Ezért most tovább viszlek titeket egy szinttel Öt (5) másodpercen belül.")
				end
			else
				say("Ti már átugrottatok egy szintet.")
			end
		end

		when 30122.chat."Csatlakozás csoporthoz" with party.is_party() and (party.getf("in_azi") == 1) begin
			setskin(NOWINDOW)
			local get = azrael.get_settings()
			local cord = get.start_cord
			local map = party.getf("azi_index")
			local level = d.getf_from_map_index("level", map)
			chat(map)
			if map == 0 then
				setskin(NOWINDOW)
				chat("Hova-Hova? Nincs map öcsikesz")
				return
			else
				if level == 2 then
					pc.warp(cord[1]*100,cord[2]*100,map)
				elseif level == 3 then
					pc.warp(get.jump_3[1]*100,get.jump_3[2]*100,map)
				elseif level == 4 then
					pc.warp(get.jump_4[1]*100,get.jump_4[2]*100,map)
				elseif level == 5 then
					pc.warp(get.jump_5[1]*100,get.jump_5[2]*100,map)
				elseif level == 6 then
					pc.warp(get.jump_6[1]*100,get.jump_6[2]*100,map)
				elseif level == 7 then
					pc.warp(get.jump_7[1]*100,get.jump_7[2]*100,map)
				end
			end
		end
		
		when 30122.chat."Feladjuk" with party.is_party() and party.is_leader() and (party.getf("in_azi") == 1) begin
			say("Biztosan fel akarjátok adni?")
			local menu = select("Igen","Nem")
			if menu == 1 then
				azrael.clear_all()
			end
		end

		when 30122.chat."Azrael Útvesztője" with (party.getf("in_azi") == 0) begin
			if game.get_event_flag("azi_debug") == 0 then
				if party.is_party() and not party.is_leader() then
					say("Csak a csoport vezetővel állok szóba!")
					return
				end
				if not party.is_party() then
					say("Egyedül nem léphetsz be!")
					return
				end
			end
			
			local get = azrael.get_settings()
			local cord = get.start_cord
			say("Be szeretnél menni?")
			say()
			local a = select("Igen", "Nem")
			if a == 1 then
				if azrael.green_way() then
					-- d.new_jump_party(get.map, cord[1], cord[2])
					d.new_jump_party(get.map, get.start_cord[1], get.start_cord[2])
					d.setf("level", 2)
					azrael.sapwn_doors()
				end
			end
		end

		when 30319.use or 30320.use with pc.get_map_index() >= 2160000 and pc.in_dungeon() begin	
			azrael.skip_lvl()
		end

		when login with pc.get_map_index() >= 2160000 and pc.in_dungeon() begin
			if (party.getf("in_azi") == 0) then
				local get = azrael.get_settings()
				local tekilvl = get.teki
				local runa = get.runa
				if party.is_party() or party.is_leader() then
					d.spawn_mob_dir(tekilvl[1], tekilvl[2], tekilvl[3], tekilvl[4])
					d.spawn_mob_dir(runa[1], runa[2], runa[3], runa[4])
					party.setf("in_azi", 1)
					party.setf("azi_index", d.get_map_index())
					party.setf("mob_kill",0)
					loop_timer("kill_check", 1)
					notice("Találjátok meg a helyes utatat és törjétek össze az ajtókat.")
				end
			end
			loop_timer("ff_check", 5)
		end
		-- KILÉPÉS FELADÁS VÉGRAHJTÁS
		when ff_check.timer begin
			chat("nem adtuk fel még")
			if party.getf("in_azi") == 0 then
				notice("Úgy tűnik feladátok a harcot.")
				notice("Most vissza viszlek a bejárathoz 5 másodperc múlva.")
				cleartimer("ff_check")
				timer("ff_leave", 5)
			end
		end
		when ff_leave.timer begin
			azrael.clear_all()
		end
		-- KILÉPÉS FELADÁS VÉGRAHJTÁS
		
		-- TEKNŐS
		when 30103.chat."Tovább a következő szintre" with d.getf("level") == 3 begin
			setskin(NOWINDOW)
			loop_timer("kill_check", 1)
			party.setf("mob_kill",0)
			timer("jumpto_3",1)
		end
		-- TEKNŐS

		when kill_check.timer begin
			chat("kill check loop")
			local getkill = party.getf("mob_kill")
			local lvl = d.getf("level")
			if lvl == 2 then
				if getkill >= 11 then
					party.setf("mob_kill",0)
					chat("lvl 2")
					d.setf("level", 3)
					cleartimer("kill_check")
				end
			end
			if lvl == 3 then
				if getkill >= 7 then -- NÉGYES 4444444 A TELEPORTOS KKÖSZI
					chat("lvl 3")
					notice("Meg találtáok és elpusztítottátok az összes Megtorlás követ.")
					notice("Öt (5) másodpercen belül el viszlek a következő szintre.")
					timer("jumpto_4", 5)
					cleartimer("kill_check")
				end
			end
		end
		
		when kill with (d.getf("level") == 2) or (d.getf("level") == 3) begin
			local getkill = party.getf("mob_kill")
			party.setf("mob_kill",getkill + 1)
			chat(getkill)
		end
		
		--RÚNA HALOM VAGY MIA KURVA ANNYA
		when 30104.chat."Tovább a következő szintre" with d.getf("level") == 4 begin
			setskin(NOWINDOW)
			timer("jumpto_5",1)
		end
		--RÚNA HALOM VAGY MIA KURVA ANNYA
		
		-- TARTÁROS GECI
		when 2591.kill with pc.get_map_index() >= 2160000 and pc.in_dungeon() and d.getf("level") == 5 begin
			game.drop_item(30312, 1)
		end
		when 30312.use with pc.get_map_index() >= 2160000 and pc.in_dungeon() and d.getf("level") == 5 begin
			notice("Meg találátok és legyóztétek Tartaros-t")
			notice("Ennek bizonyítéka, hogy összetörtétek a Grimaszoló Totemet.")
			notice("Most tovább viszlek a következő szintre.")
			setskin(NOWINDOW)
			timer("jumpto_6",1)
		end
		-- TARTÁROS GECI
		
		-- CHARON
		when 2597.kill with pc.get_map_index() >= 2160000 and pc.in_dungeon() and d.getf("level") == 6 begin
			notice("Sikeresen meg öltétek a Charon-t")
			notice("Jutalmul elviszlek az Azrael trónjához.")
			timer("jumpto_7",1)
		end
		-- CHARON
		
		-- AZRAEL
		when 2598.kill with pc.get_map_index() >= 2160000 and pc.in_dungeon() and d.getf("level") == 7 begin
			notice("Szép munka! Sikeresen meg öltétek az Azraelt.")
			notice("Pár másodperc múlva ki viszlek a bejárathoz.")
		end
		-- AZRAEL
			
		when jumpto_3.timer begin
			azrael.spawn_kovek()
			party.setf("mob_kill",0)
			d.setf("level", 3)
			local get = azrael.get_settings()
			local cord = get.jump_3
			d.jump_all(cord[1],cord[2])
			notice("Keressétek meg és pusztítsátok el az összes Megtorlás követ!")
		end
		
		when jumpto_4.timer begin
			cleartimer("kill_check")
			d.setf("level", 4)
			local get = azrael.get_settings()
			local cord = get.jump_4
			d.jump_all(cord[1],cord[2])
			notice("Találjátok meg a helyes utat a portálokon keresztül.")
			notice("Majd vizsgáljátok meg közelebbről a Rúnahlmot.")
		end
		
		when jumpto_5.timer begin
			d.setf("level", 5)
			local get = azrael.get_settings()
			local cord = get.jump_5
			d.jump_all(cord[1],cord[2])
			notice("Találjátok meg a Tartaros-t, majd törjétek össze a grimaszoló totemet Jobb Kattintással.")
		end
		
		when jumpto_6.timer begin
			d.setf("level", 6)
			local get = azrael.get_settings()
			local cord = get.jump_6
			local charon = get.charon
			d.spawn_mob_dir(charon[1], charon[2], charon[3], charon[4])
			d.jump_all(cord[1],cord[2])
			notice("Öljétek meg a charont!")
		end
		
		when jumpto_7.timer begin
			d.setf("level", 7)
			local get = azrael.get_settings()
			local cord = get.jump_7
			local azrael = get.azrael
			d.spawn_mob_dir(azrael[1], azrael[2], azrael[3], azrael[4])
			d.jump_all(cord[1],cord[2])
			notice("Öljétek meg az Azraelt!")
		end
	end
end


 

Edited by FuveZeq
Link to comment
https://metin2.dev/topic/33735-helprejoin-dungeon-after-map-index-delete/
Share on other sites

  • Premium

If the dungeon is by solo you can recreate the instance "resuming" the step you were just using lua. For party it's not that easy if the whole group got kicked. 

So the common solution is to delay this event, responsable of the dungeon self-end:

EVENTFUNC(dungeon_dead_event)

 

  • Sad 1
  • 1 month later...

Honestly, I don't know... I'm not very good at lua programming, I don't know how to do the things I want to do. I have an idea how to do this, but only with the group leader...
So yeah, I think I need to do the solo side, then add the party side to the quest or idk..

I have another problem, if you could help me, that would be a great.
I don't know why, but when i try to use server_timer the server just crash..

there is how i try to use:

1.
when 101.kill begin
    server_timer("101kill", 5)
end

when 101kill.server_timer begin
    chat("5 sec delay after kill")
end

2.

when 101.kill begin
    local idx = pc.get_map_index()
    server_timer("101kill", 5, idx)
end

when 101kill.server_timer begin
    local arg = get_server_timer_arg()
    chat("5 sec delay after kill")
    clear_server_timer("101kill", arg)
end


3.

when 101.kill begin
    local idx = pc.get_map_index()
    server_timer("101kill", 5, idx)
end

when 101kill.server_timer begin
    local arg = get_server_timer_arg()
    if d.find(arg) then
        chat("5 sec delay after kill")
        clear_server_timer("101kill", arg)
    end
end


Jun 17 01:47:42 :: QUEST ScriptAnswer pid 1 answer 0
Jun 17 01:47:42 :: QUEST loading locale/germany/quest/object/101kill/server_timer/dnd.start : dndteszt [STATE] start
Jun 17 01:47:42 :: XXX AddServerTimer tstart 0 0x22459e80
Jun 17 01:47:47 :: XXX ServerTimer Call NPC 0x354d2014 vnum 4294967295 arg 0

if i use 2 or 3 method the arg changes to the map id but stil crash

Jun 17 01:47:47 :: XXX ServerTimer Call NPC 0x354d2014 vnum 4294967295 arg 3520001

Edited by FuveZeq
  • Honorable Member
  • Solution

"chat" is a function linked to a player's client instance.

Server timers have nothing to do with the player itself. Therefore you are calling an instance of an object outside of its normal scope. Crashing the server.

If you want to print something in your chat, you can use a simple timer, but not a server timer.

  • Good 1
  • Love 1

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.