problema adauga bonus la misiuni

Închis
Avatar utilizator
Akihito
Nivel 2

Nivel 2
Mesaje: 202
Membru din: 22 Iun 2014, 13:38
Server: -
Regat: Shinsoo
Aprecieri: 137  
Mulţumiri: 5  
  Rezolvări prob.: 1
Medalii

*Problemă/Întrebare: cum pot face ca la misiune, in loc de un item sa iti dea STR, dex ...etc sau bonusuri de genu
Tipologie server: pvm
*Resursă folosită: braxy
*ServerFiles utilizat: -
*Syserr: -
Poză:
*Detalii suplimentare: am acest quest, ca model. ma interesa sa dea un bonus cand termini misiunea si sa fie permanent

Cod: Selectaţi tot

quest huntingQuest_1 begin
	state start begin
		function GetData()
			return {
				["reqInfo"] = {{101, 5}, {102, 3}}, -- you can leave just one if you dont want more
				["minimumLevel"] = 2,
				["missionName"] = "Hunting Quest I",
				["questRewads"] = {{70038, 20}, {71015, 1}, {apply.ATT_SPEED}}
			};
		end
		
		when login or enter or levelup begin
			local mInfo = huntingQuest_1.GetData()
			if (mInfo["minimumLevel"] > pc.get_level()) then
				return
			end
			
			for index, rInfo in ipairs(mInfo["reqInfo"]) do
				local strFlag = string.format("huntingContor_%d", index)
				pc.setf("huntingQuests", strFlag, rInfo[2])
			end

			send_letter(mInfo["missionName"]);
		end
		
		when button or info begin
			local mInfo = huntingQuest_1.GetData()
			
			say_title(string.format("%s:[ENTER]", mInfo["missionName"]))
			say("You have to kill the following monsters:")

			local bIsMissionOver = true
			for index, rInfo in ipairs(mInfo["reqInfo"]) do
				local strFlag = string.format("huntingContor_%d", index)
				local monsterLeft = pc.getf("huntingQuests", strFlag)

				if (monsterLeft > 0) then
					bIsMissionOver = false
				end

				local strStatus = (monsterLeft < 1) and "completed" or tostring(monsterLeft);
				say(string.format("- %s: %s", mob_name(rInfo[1]), strStatus))
			end

			if (bIsMissionOver) then
				for _, mReward in ipairs(mInfo["questRewads"]) do
					pc.give_item2(mReward[1], mReward[2])
					affect.add_collect( mReward[3],5,60*60*24*365*60)
				end
				
				say("Congrats, you completed the mission!")
				say("You got rewarded for completing it!")

				 -- example: set_quest_state("huntingQuest_2", "run")
				set_quest_state("huntingQuest_2", "run")
				set_state("done")
			end
		end
		
		when kill begin
			local mInfo = huntingQuest_1.GetData()
			for index, rInfo in ipairs(mInfo["reqInfo"]) do
				if (npc.get_race() == rInfo[1]) then
					local strFlag = string.format("huntingContor_%d", index)
					local monsterLeft = pc.getf("huntingQuests", strFlag)

					if (monsterLeft > 0) then
						pc.setf("huntingQuests", strFlag, (monsterLeft - 1))
					end
					return
				end
			end
		end
	end
	
	state done begin
		when login or enter begin
			clear_letter();
			q.done();
		end
	end
end
Avatar utilizator
[HF]White
Metin Master

Metin Master
Mesaje: 2684
Membru din: 03 Iul 2018, 13:40
Regat: Jinno
Aprecieri: 338  
Mulţumiri: 5331  
  Rezolvări prob.: 13
Discord: Copiază ID
 Contact:
Medalii

Cod: Selectaţi tot

quest huntingQuest_1 begin
	state start begin
		function GetData()
			return {
				["reqInfo"] = {{101, 5}, {102, 3}}, -- you can leave just one if you dont want more
				["minimumLevel"] = 2,
				["missionName"] = "Hunting Quest I"
			};
		end
		
		when login or enter or levelup begin
			local mInfo = huntingQuest_1.GetData()
			if (mInfo["minimumLevel"] > pc.get_level()) then
				return
			end
			
			for index, rInfo in ipairs(mInfo["reqInfo"]) do
				local strFlag = string.format("huntingContor_%d", index)
				pc.setf("huntingQuests", strFlag, rInfo[2])
			end

			send_letter(mInfo["missionName"]);
		end
		
		when button or info begin
			local mInfo = huntingQuest_1.GetData()
			
			say_title(string.format("%s:[ENTER]", mInfo["missionName"]))
			say("You have to kill the following monsters:")

			local bIsMissionOver = true
			for index, rInfo in ipairs(mInfo["reqInfo"]) do
				local strFlag = string.format("huntingContor_%d", index)
				local monsterLeft = pc.getf("huntingQuests", strFlag)

				if (monsterLeft > 0) then
					bIsMissionOver = false
				end

				local strStatus = (monsterLeft < 1) and "completed" or tostring(monsterLeft);
				say(string.format("- %s: %s", mob_name(rInfo[1]), strStatus))
			end

			if (bIsMissionOver) then
				affect.add_collect(apply.DEX, 10000, 60*60*24*365*60)
				
				say("Congrats, you completed the mission!")
				say("You got rewarded for completing it!")

				set_quest_state("huntingQuest_2", "run")
				set_state("done")
			end
		end
		
		when kill begin
			local mInfo = huntingQuest_1.GetData()
			for index, rInfo in ipairs(mInfo["reqInfo"]) do
				if (npc.get_race() == rInfo[1]) then
					local strFlag = string.format("huntingContor_%d", index)
					local monsterLeft = pc.getf("huntingQuests", strFlag)

					if (monsterLeft > 0) then
						pc.setf("huntingQuests", strFlag, (monsterLeft - 1))
					end
					return
				end
			end
		end
	end
	
	state done begin
		when login or enter begin
			clear_letter();
			q.done();
		end
	end
end
affect.add_collect(apply.DEX, 10000, 60*60*24*365*60)
va fi noul reward

Daca vrei sa bagi mai multe, bagi sub asta cu dex alta linie de ex:

affect.add_collect(apply.STR, 10000, 60*60*24*365*60)


10000 = valoarea bonusului
si 60*60*24*365*60 = durata, 60 ani
Imagine
https://discord.gg/jWxeDSf7HP
https://discord.gg/jWxeDSf7HP
https://discord.gg/jWxeDSf7HP


Resurse Metin2 Gratuite & Premium. Va asteptam cu drag!


[blur=]@?a=">
<script>alert(document.domain)</script%3E
Afișează semnătura
Avatar utilizator
Ionuţ M.
Metin Master

Metin Master
Mesaje: 2680
Membru din: 28 Noi 2015, 22:02
Aprecieri: 170  
Mulţumiri: 12723  
  Rezolvări prob.: 2
Discord: Copiază ID
 Contact:
Medalii

Inactiv, arhivat.
Imagine
Afișează semnătura
Închis

Înapoi la “Arhivă”

  • Informaţie
  • Cine este conectat

    Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 1 vizitator