Problema timer dungeon

Înainte de a posta o problemă, caută în acest forum și poate găsești rezolvare.
Închis
Avatar utilizator
radwcw32
Nivel 2

Nivel 2
Mesaje: 199
Membru din: 07 Iun 2014, 16:54
Regat: Jinno
Aprecieri: 170  
Mulţumiri: 5  
  Rezolvări prob.: 1
Discord: Copiază ID
Medalii

*Problemă/Întrebare: Salut! Am adaugat un quest pentru dungeon-ul Beran Setaou, merge ok,doar ca nu-mi afiseaza timpul de asteptare pentru a reintra in dungeon. Problema este la functia "get_time_remaining",dar nu-mi dau seama ce nu-i convine
Tipologie server:PVM
*Resursă folosită:

Cod: Selectaţi tot

quest dungeon_beran begin
	state __FUNC__ begin
		function settings()
			return
			{
				["dungeon_name"] = "dragon",
				["map_index"] = 207,

				["vnum_metin"] = 101,

				["vnum_boss"] = 102,
				["pos_boss"] = {207, 147}, -- local pos

				["pos_entry"] = {8432, 10669}, -- global pos
				-- ["pos_entry"] = {xBase + xLocal, yBase + yLocal}, -- pe viitor iti inlocuiesti tu sub forma asta (adica scazi 8111 - xBase din Setting.txt ca sa obtii xLocal)
				["cooldown"] = 60,

				["min_level"] = 75,
				["max_level"] = 110,

				["item_need"] = 30179,
				["item_need_count"] = 1,
			};
		end
		function d_set_warp_location() -- inapoi in map1
			local e = pc.get_empire()
			if e == 1 then
				d.set_warp_location(1, 652+4096, 592+8960) -- rosii
			elseif e == 2 then
				d.set_warp_location(21, 637, 646+1024) -- galbeni
			elseif e == 3 then
				d.set_warp_location(41, 381 + 9216, 644+2048) -- albastrii
			end
		end

		function get_stone_pos()
			local positions = { -- coordonate locale
				{188, 179},
				{176, 179},
				{176, 167},
				{188, 166}
			}

			return positions
		end
		function spawn_metin()
			local settings = dungeon_beran.settings()
			local positions, total = dungeon_beran.get_stone_pos()
			for i = 1, 4 do
				d.spawn_mob(settings["vnum_metin"], positions[i][1], positions[i][2])
			end

			d.setf(string.format("%s_stone_destroyed",settings["dungeon_name"]), 0)
		end
		function CanEnter()
			local settings = dungeon_beran.settings()
			local minLevel = settings["min_level"]
			local maxLevel = settings["max_level"]
			local cooldown = settings["cooldown"]
			local dungeonName = settings["dungeon_name"]
			local itemVnum = settings["item_need"]
			local itemCount = settings["item_need_count"]
			if pc.get_level() < minLevel then
				setdelay(0)
				say_npc()
				say_reward("Nu poti intra!")
				say(string.format("Doar cei experimentati pot intra, ai nevoie de nivelul %d",minLevel))
				return false
			end
			if pc.get_level() > maxLevel then
				setdelay(0)
				say_npc()
				say_reward("Nu poti intra!")
				say(string.format("Limita de nivel maxim depasita (Max.%d)",maxLevel))
				return false
			end
			if pc.count_item(itemVnum) < itemCount then
				setdelay(0)
				say_npc()
				say_reward("Nu poti intra!")
				say(string.format("Ai nevoie de %s x%d pentru a intra",item_name(itemVnum),itemCount))
				return false
			end
			local cooldown = pc.getf("dungeon", string.format("dungeon_cooldown_%s", dungeonName))
			if pc.get_gm_level() < 5 then
				if cooldown > 0 and cooldown > get_time() then
					setdelay(0)
					--say_npc("srthsr")
					say("Trebuie sa astepti pentru a putea face asta")
					say(string.format("Nu poti reintra atat de repede inapoi in dungeon,[ENTER]trebuie sa astepti %s.", get_time_remaining(cooldown - get_time())))
					return false
				end
			end
			return true
		end
	end
	state start begin
		when login with pc.in_dungeon(dungeon_beran.settings()["map_index"]) begin
			local level = d.getf("level")
			if level == 1 then
				notice("Nivelul 1: Distruge toate pietrele metin!")
				if pc.is_gm() and pc.get_gm_level() == 5 then
					chat(string.format("GM: Real Metin pos: x: %d    y: %d", d.getf("gm_info_pos_1"), d.getf("gm_info_pos_2")))
				end
			elseif level == 2 then
				notice(string.format("Nivelul 2: Ucide-l pe %s",dungeon_beran.settings()["vnum_boss"]))
			end
		end
		-- vnum_metin
		when 101.kill with pc.in_dungeon(dungeon_beran.settings()["map_index"]) and d.getf("level") == 1 begin
			local settings = dungeon_beran.settings()
			local blodyprost = d.getf(string.format("%s_stone_destroyed",settings["dungeon_name"])) + 1
			if blodyprost == 4 then
				d.setf("level",3)
				d.notice(string.format("%s va aparea in 2 secunde",mob_name(settings["vnum_boss"])))
				server_timer('boss_appear',2,d.get_map_index())
			end
			d.setf(string.format("%s_stone_destroyed",settings["dungeon_name"]), blodyprost)
		end
		when boss_appear.server_timer begin
			if d.select(get_server_timer_arg()) then
				local settings = dungeon_beran.settings()
				d.spawn_mob(settings["vnum_boss"], settings["pos_boss"][1], settings["pos_boss"][2])
			end
		end
		-- vnum_boss
		when 102.kill with pc.in_dungeon(dungeon_beran.settings()["map_index"]) begin
			dungeon_beran.d_set_warp_location()
			local settings = dungeon_beran.settings()

			local isParty = party.is_party()
			local leaderName = "[NoName]"
			if isParty then
				local pids = {party.get_member_pids()}
				local leaderPid = party.get_leader_pid()
				for i, pid in next, pids, nil do
					q.begin_other_pc_block(pid)
					if pid == leaderPid then
						leaderName = pc.get_name()
					end
					pc.setf("dungeon", string.format("dungeon_cooldown_%s",settings["dungeon_name"]), get_time() + settings["cooldown"])
					q.end_other_pc_block()
				end
			else
				pc.setf("dungeon", string.format("dungeon_cooldown_%s",settings["dungeon_name"]), get_time() + settings["cooldown"])
			end

			d.clear_regen()

			local runTime = get_time() - d.getf("dungeon_start_time")
			if isParty then
				notice_all(string.format("%s and his group have killed %s in %s", mob_name(settings["vnum_boss"]), leaderName, get_time_remaining(runTime)))
			else
				notice_all(string.format("%s has killed %s in %s", pc.get_name(), mob_name(settings["vnum_boss"]), get_time_remaining(runTime)))
			end
		end

		when 30121.chat."Ucide-l pe beran" begin
			say_title(mob_name(30121))

			local settings = dungeon_beran.settings()
			local myName = pc.get_name()
			local mapIndex = settings["map_index"]
			local posEntry = settings["pos_entry"]
			local cooldown = settings["cooldown"]
			local dungeonName = settings["dungeon_name"]
			local itemVnum = settings["item_need"]
			local itemCount = settings["item_need_count"]
			local minLevel = settings["min_level"]
			local maxLevel = settings["max_level"]
			if minLevel > 1 then
				say_reward(string.format("Limita de nivel minim: %d", minLevel))
			end
			if maxLevel > 1 then
				say_reward(string.format("Limita de nivel maxim: %d", maxLevel))
			end
			if itemVnum > 0 then
				say_reward(string.format("Pentru a intra ai nevoie de %s x%d", item_name(itemVnum),itemCount))
			end

			say("Vrei sa-l ucizi pe beran")

			local s

			if party.is_party() then
				if party.is_leader() == false then
					say_reward("[ENTER]Doar liderul grupului poate initia intrarea")
					return
				end

				s = select("Intra singur", "Intra cu grupul", "Nici nu ma gandesc.")
				if s == 3 then return end
				if not pc.can_warp() then
					setdelay(0)
					say_npc()
					say("Trebuie sa astepti 10 sec inainte de a te teleporta")
					return
				end
				if not dungeon_beran.CanEnter() then return end

				-- intra singur
				if s == 1 then
					pc.remove_item(itemVnum,itemCount)
					d.new_jump(mapIndex, posEntry[1]*100, posEntry[2]*100)
					d.setf("level",1)
					d.setf("dungeon_start_time", get_time())
					dungeon_beran.spawn_metin()
				-- intra cu grupul
				elseif s == 2 then
					local pids = {party.get_member_pids()}
					local notEnoughLevelMembers = {}
					local notEnoughLevelMaxMembers = {}
					local notEnoughKeysMembers = {}
					local cooldownMembers = {}
					local levelCheck = true
					local levelMaxCheck = true
					local keyCheck = true
					local cooldownCheck = true
					--say("test 1")
					for i, pid in next, pids, nil do
						q.begin_other_pc_block(pid)
						--say(string.format("pc level %s minlevel %s myname %s pc name %s",tostring(pc.get_level()),tostring(minLevel),tostring(myName),tostring(pc.get_name())))
						if pc.get_level() < minLevel and myName != pc.get_name() then
							table.insert(notEnoughLevelMembers, pc.get_name())
							notEnoughLevelMembers[pc.get_name()] = pc.get_level()
							levelCheck = false
						end
						--say("test 2")
						if pc.get_level() > maxLevel and myName != pc.get_name() then
							table.insert(notEnoughLevelMaxMembers, pc.get_name())
							notEnoughLevelMaxMembers[pc.get_name()] = pc.get_level()
							levelMaxCheck = false
						end
						if pc.count_item(itemVnum) < itemCount then
							table.insert(notEnoughKeysMembers, pc.get_name())
							keyCheck = false
						end
						--say("test 2")
						local cooldown = pc.getf("dungeon", string.format("dungeon_cooldown_%s", dungeonName))
						if cooldown > 0 and cooldown > get_time() then
							table.insert(cooldownMembers, {pc.get_name(), cooldown})
							cooldownCheck = false
						end
						q.end_other_pc_block()
					end

					if not levelCheck then
						setdelay(0)
						say_npc()
						say_reward(string.format("Urmatorii membrii ai grupului nu au lv. %d:",minLevel))
						for k, v in notEnoughLevelMembers do
							say("\t - "..v.." (lv."..notEnoughLevelMembers[v]..")")
						end
						return
					end
					--say("test 3")

					if not levelMaxCheck then
						setdelay(0)
						say_npc()
						say_reward(string.format("Urmatorii membrii ai grupului au nivelul prea mare. (Max.%d):",maxLevel))
						for k, v in notEnoughLevelMaxMembers do
							say("\t - "..v.." (lv."..notEnoughLevelMaxMembers[v]..")")
						end
						return
					end
					--say("test 4")

					if not keyCheck then
						setdelay(0)
						say_npc()
						say_reward(string.format("Urmatorii membrii ai grupului nu au %s x%d:",item_name(itemVnum),itemCount))
						for k, v in notEnoughKeysMembers do
							say("\t - "..v.."")
						end
						return
					end
					--say("test 5")

					if not cooldownCheck then
						setdelay(0)
						say_npc()
						say_reward("Urmatorii membrii trebuie sa astepte:")
						for k, v in cooldownMembers do
							say(string.format("\t - %s (%s)", v[1], get_time_remaining(v[2] - get_time())))
						end
						return
					else
						for i, pid in next, pids, nil do
							q.begin_other_pc_block(pid)
							pc.remove_item(itemVnum,itemCount)
							pc.setf("dungeon", string.format("dungeon_cooldown_%s",dungeonName), get_time() + cooldown)
							q.end_other_pc_block()
						end
					end
					--say("test 6")

					d.new_jump_party(mapIndex, posEntry[1], posEntry[2])
					d.setf("level",1)
					d.setf("dungeon_start_time", get_time())
					dungeon_beran.spawn_metin()
				end
				return
			end

			s = select("Intra", "Nici nu ma gandesc.")
			if s == 2 then return end
			if s == 1 then
				if not pc.can_warp() then
					setdelay(0)
					say_npc()
					say("Trebuie sa astepti 10 sec inainte de a te teleporta")
					return
				end
				if not dungeon_beran.CanEnter() then return end
				pc.remove_item(itemVnum,itemCount)
				d.new_jump(mapIndex, posEntry[1]*100, posEntry[2]*100)
				d.setf("level",1)
				d.setf("dungeon_start_time", get_time())
				dungeon_beran.spawn_metin()
			end
		end
	end
end
*ServerFiles utilizat: cel clean postat de Spyke
*Syserr:

Cod: Selectaţi tot

SYSERR: Feb 21 16:29:10 :: RunState: LUA_ERROR: [string "dungeon_beran"]:24: attempt to call global `get_time_remaining' (a nil value)
SYSERR: Feb 21 16:29:10 :: WriteRunningStateToSyserr: LUA_ERROR: quest dungeon_beran.start click
SYSERR: Feb 21 16:29:15 :: Entergame: !GetMovablePosition (name CHULISUJI 153600x1203200 map 73 changed to 241300x1275400)
SYSERR: Feb 21 16:29:25 :: RunState: LUA_ERROR: locale/romania/quest/object/state/dungeon_beran:69: attempt to call global `get_time_remaining' (a nil value)
SYSERR: Feb 21 16:29:25 :: WriteRunningStateToSyserr: LUA_ERROR: quest dungeon_beran.start click

Poză:
*Detalii suplimentare:
Avatar utilizator
radwcw32
Nivel 2

Nivel 2
Mesaje: 199
Membru din: 07 Iun 2014, 16:54
Regat: Jinno
Aprecieri: 170  
Mulţumiri: 5  
  Rezolvări prob.: 1
Discord: Copiază ID
Medalii

up
Avatar utilizator
radwcw32
Nivel 2

Nivel 2
Mesaje: 199
Membru din: 07 Iun 2014, 16:54
Regat: Jinno
Aprecieri: 170  
Mulţumiri: 5  
  Rezolvări prob.: 1
Discord: Copiază ID
Medalii

Up
Avatar utilizator
Fubuki.Atsuya
Nivel 9

Nivel 9
Mesaje: 1968
Membru din: 22 Iun 2015, 21:13
Server: OldLegion2
Regat: Shinsoo
Aprecieri: 455  
Mulţumiri: 815  
  Rezolvări prob.: 2
Discord: Copiază ID
Medalii

Încearcă ăsta :
quest Camera_de_cristal_by_demon begin
state start begin
		
	when 30123.chat."Spre Camera de Cristal" with pc.get_map_index() == 73 begin
		if get_time() > game.get_event_flag("Grotte_time") then
			game.set_event_flag("Grotte_zugang",0)
		end
  
---		if pc.is_gm() or pc.count_item(80041) >= 1 then
---			say_title(""..mob_name(30123).."")
---			say("Bun venit "..pc.get_name().."")
---			say("Nu ai nevoie nici de chei nici de parola")
---			say("esti GM poti intra cand vrei.")
---			wait()
---			pc.warp(843200, 1066900) 
---			return
---		end
  
		if 3600 > get_global_time() - pc . getqf ( "timp_asteptare" ) and not pc.is_gm() then 
			say ("Trebuie sa astepti 1 ora pentru a intra din nou [ENTER]in Camera de Cristal.") 
			return
		end
  
		if game.get_event_flag("Grotte_zugang") == 0 and pc.count_item(30179) < 5 then
			say_title(""..mob_name(30123).."")
			say_reward("Pentru a intra în templul lui Beran,")
			say_reward("ai nevoie de "..item_name(30179).."")
			say_item_vnum(30179)
			say_reward("Aceaste chei rasucite pica la Capitanul Setaou.")
			say_reward("Ai nevoie de 5x Cheie Rasucita pentru a intra.")
			return
		end
		
		if game.get_event_flag("Grotte_zugang") == 1 then
			say_title(""..mob_name(30123).."")
			pc.setqf("grotte_passworto", 078954687921)
		if pc.getqf("abgabe") == 1 then
			pc.setqf("abgabe",0)
			say("Ai cele 5x Chei Rasucite.")
			say("Te voi teleporta imediat în Camera de Cristal.")
			pc.setqf("erlaubt",1)
			wait()
			pc.warp(843200, 1066900) 
			return
		end
		say("Introdu codul ales de liderul grupului.")
		local passwort = tonumber(input(""))
		--pc.setqf("grotte_passworto", passwort) 
		if game.get_event_flag("Grotte_passwort") != passwort then
			say_title(""..mob_name(30123).."")
			say("Ai introdus un cod gresit.")
			return
		end
		if game.get_event_flag("Grotte_passwort") == passwort then
			say_title(""..mob_name(30123).."")
			say("Ai introdus codul corect.")
		if pc.count_item(30179) < 5 then
			say("Nu te pot teleporta deoarece nu ai")
			say(""..item_name(30179).."")
			say_item_vnum(30179)
			say("Ai nevoie de cele 5x Chei Rasucite.")
			return
		end
		say("Te voi teleporta imediat.")
		pc.setqf("erlaubt",1)
		wait()
		if pc.can_warp() then   
			pc.remove_item("30179",5) end
			pc.warp(843200, 1066900) 
		elseif passi != pc.getqf("grotte_passworto") then
			say_title(""..mob_name(30123).."")
			say("")
			return
		end
		end
		
		if game.get_event_flag("Grotte_zugang") == 0 and pc.count_item(30179) >= 5 then
			say_title(""..mob_name(30123).."")
			say("Detin în mine, ultima suflare a zeului dragon.")
			say("Aceasta suflare magica te poate ajuta sa mergi în")
			say("Camera de Cristal.")
				say("")
			say_reward("Ai nevoie de 5x Chei Rasucite pentru a te teleporta.")
			say_reward("Accepti?")
		local i = select("Da, teleporteaza-ma!", "Nu, Multumesc.")
		if 1 == i then
			say_title(""..mob_name(30123).."")
			say("Ai nevoie de un cod pentru tine si grupul tau.")
			say("Codul pe care îl vei introduce trebuie sa ")
			say("contina minim 2 cifre.")
		local passwort = tonumber(input(""))
		if passwort and passwort <= 999999999 and pc.count_item(30179)>=5 then
			game.set_event_flag("Grotte_zugang",1)
			game.set_event_flag("Grotte_passwort",passwort)
			local times = get_time() + 300 --Wartezeit
			game.set_event_flag("Grotte_time", times)
			say_title(""..mob_name(30123).."")
			pc.setqf("abgabe",1)
			say("Parola aleasa este: "..passwort.."")
			syschat("Parola aleasa este: "..passwort.."")
			pc.remove_item("30179",5)
		else 
			say_title(""..mob_name(30123).."")
			say("Parola este invalida. Incearca alt cod.")
		end
		end
		end
		end
	when login with pc.get_map_index() == 207 begin

			if pc.get_level() < 75 or pc.getqf("erlaubt") == 0 and pc.get_map_index() == 207 then
				chat("")
				warp_to_village()
			end
			
		notice_all("Dragonul Albastru s-a trezit!")
		notice_in_map("[Camera de Cristal] Bun venit în camera de cristal ! Începem prima sarcina a voastra.")
		notice_in_map("[Camera de Cristal] Spargeti toate metinele, si aflati care este metinul corect.")
		pc.set_warp_location(73 , 1825, 12207)
	end
	
	when 8021.kill with pc.get_map_index() == 207 begin
		timer("skipia_boss_goo", 10)
		notice_in_map("[Camera de Cristal] Ati spart piatra metin corecta!")
		notice_in_map("[Camera de Cristal] Îl veti întâlni pe Beran-Setaou acum. Sunteti pregatiti ?")
		d.kill_all()
	end
	
	when skipia_boss_goo.timer begin
		game.set_event_flag("Grotte_zugang",0)
		d.new_jump_all(207, 8436, 10669) 
		d.setf("grotte_boss", 1)
		d.spawn_mob(9012, 239, 173) 
	end
	
	when 8031.kill or 8032.kill or 8033.kill or 8034.kill with pc.in_dungeon() and d.getf("grotte_boss") == 2 begin
		local n =d.getf("count") + 1
		d.setf("count", n) 
		notice_in_map("[Camera de Cristal] Ati spart pâna acum "..n.." metine.")
		if n > 2 then
			local t = number(1,4)
			syschat("Beran-Setaou este foarte furios. Acesta cheama mai multe metine!")
		if 1 == t then
			d.regen_file("data/dungeon/skia_boss1.txt")
		elseif 2 == t then
			d.regen_file("data/dungeon/skia_boss2.txt")
		elseif 3 == t then
			d.regen_file("data/dungeon/skia_boss3.txt")
		else
			d.regen_file("data/dungeon/skia_boss4.txt")
		end
		end
	end
	when 2493.kill with pc.in_dungeon() and d.getf("grotte_boss") == 2 begin
		d.setf("grotte_boss", 3)
		notice_all("Cu o ultima suflare de speranta, grupul lui "..pc.get_name().." a reusit sa învinga Dragonul Albastru!")
		timer("skipia_boss_end", 60)
		d.spawn_mob(9012, 64, 142)
		syschat("Felicitari! In 60 de secunde vei fi teleportat automat la poarta Camerei de Cristal.")
		pc.setqf("timp_asteptare" , get_global_time())
		d.kill_all()
		d.clear_regen()
	end

	when login with pc.in_dungeon() and d.getf("grotte_boss") == 2 begin
		pc.set_warp_location(73 , 1825, 12207)
	end
	when login with pc.in_dungeon() and d.getf("grotte_boss") == 1 begin
		timer("skipia_boss_end", 3600)	
		d.set_regen_file("data/dungeon/skia_boss.txt")
		local t = number(1,4)
		if 1 == t then
			d.regen_file("data/dungeon/skia_boss1.txt")
			elseif 2 == t then
			d.regen_file("data/dungeon/skia_boss2.txt")
			elseif 3 == t then
			d.regen_file("data/dungeon/skia_boss3.txt")
			else
			d.regen_file("data/dungeon/skia_boss4.txt")
		end
		local o = number(1,4)
		if 1 == o then
			d.regen_file("data/dungeon/skia_boss5.txt")
			elseif 2 == o then
			d.regen_file("data/dungeon/skia_boss6.txt")
			elseif 3 == o then
			d.regen_file("data/dungeon/skia_boss7.txt")
			else
			d.regen_file("data/dungeon/skia_boss8.txt")
			end	
		d.setf("grotte_boss", 2)
		d.notice("[Camera de Cristal] Aveti la dispozitie 60 de minute sa îi capturati sufletul lui Beran.")
		d.setf("count", 0)
		pc.set_warp_location(73 , 1825, 12207)
		end

	when login with pc.in_dungeon() and d.getf("grotte_boss") == 3 begin -- begin
	--pc.warp(181700, 1220600)
	end
	when skipia_boss_end.timer begin
		d.exit_all()
		end
	when skipia_boss_ende.timer begin
		kill_all_in_map(207)
		game.set_event_flag("Grotte_zugang",0)
		d.setf("grotte_boss", 1)
		d.exit_all()
	end
	when login with pc.get_map_index() != 207 or not pc.in_dungeon() begin
	pc.setqf("erlaubt",0)
	end
	end
end  
Pentru acest mesaj, Fubuki.Atsuya for the post:
radwcw32
Avatar utilizator
MariusExygo
Fost Helper

Fost Helper
Mesaje: 2063
Membru din: 09 Mar 2014, 15:47
Server: WildFantasy
Regat: Jinno
Aprecieri: 156  
Mulţumiri: 226  
  Rezolvări prob.: 4
Discord: Copiază ID
 Contact:
Medalii

pai tu nu ai functia get_time_remaining in questlib.lua, ia-o pe asta ca e mai buna decat parnaile celelalte

Cod: Selectaţi tot

function get_time_remaining(seconds)
	if seconds == nil then seconds = 0 end

	if seconds <= 60 then
		return string.format("%ds", seconds)
	else
		local text = ""
		local minutes = math.floor(seconds / 60)
		seconds = math.mod(seconds, 60)

		if minutes <= 60 then
			text = string.format("%dm", minutes)
			if seconds > 0 then
				text = string.format("%s %ds", text, seconds)
			end
		else
			local hours = math.floor(minutes / 60)
			minutes = math.mod(minutes, 60)
			if hours <= 24 then
				text = string.format("%s %dh", text, hours)
				if minutes > 0 then
					text = string.format("%s %dm", text, minutes)
				end
				if seconds > 0 then
					text = string.format("%s %ds", text, seconds)
				end
			else
				local days = math.floor(hours / 24)
				hours = math.mod(hours, 24)

				text = string.format("%s %dd", text, days)
				if hours > 0 then
					text = string.format("%s %dh", text, hours)
				end
				if minutes > 0 then
					text = string.format("%s %dm", text, minutes)
				end
				if seconds > 0 then
					text = string.format("%s %ds", text, seconds)
				end
			end
		end
		return text
	end
end
Pentru acest mesaj, MariusExygo a primit 2 (de) mulţumiri
radwcw32 • Marian [Desmond]
Afișează semnătura
Avatar utilizator
radwcw32
Nivel 2

Nivel 2
Mesaje: 199
Membru din: 07 Iun 2014, 16:54
Regat: Jinno
Aprecieri: 170  
Mulţumiri: 5  
  Rezolvări prob.: 1
Discord: Copiază ID
Medalii

MariusExygo scrie: ↑24 Feb 2023, 12:38 pai tu nu ai functia get_time_remaining in questlib.lua, ia-o pe asta ca e mai buna decat parnaile celelalte

Cod: Selectaţi tot

function get_time_remaining(seconds)
	if seconds == nil then seconds = 0 end

	if seconds <= 60 then
		return string.format("%ds", seconds)
	else
		local text = ""
		local minutes = math.floor(seconds / 60)
		seconds = math.mod(seconds, 60)

		if minutes <= 60 then
			text = string.format("%dm", minutes)
			if seconds > 0 then
				text = string.format("%s %ds", text, seconds)
			end
		else
			local hours = math.floor(minutes / 60)
			minutes = math.mod(minutes, 60)
			if hours <= 24 then
				text = string.format("%s %dh", text, hours)
				if minutes > 0 then
					text = string.format("%s %dm", text, minutes)
				end
				if seconds > 0 then
					text = string.format("%s %ds", text, seconds)
				end
			else
				local days = math.floor(hours / 24)
				hours = math.mod(hours, 24)

				text = string.format("%s %dd", text, days)
				if hours > 0 then
					text = string.format("%s %dh", text, hours)
				end
				if minutes > 0 then
					text = string.format("%s %dm", text, minutes)
				end
				if seconds > 0 then
					text = string.format("%s %ds", text, seconds)
				end
			end
		end
		return text
	end
end
Asta era,mersi mult
Rezolvat,se poate inchide!
Închis
Răspunsuri
1
Vizualizări
267
Răspunsuri
6
Vizualizări
157
Răspunsuri
2
Vizualizări
312

Înapoi la “Probleme rezolvate”

  • Informaţie
  • Cine este conectat

    Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 75 vizitatori