• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

czy ten skrypt zadziała poprawnie i czy wgl sensowanie go napisałem?

The_Hide

Banned User
Joined
Dec 11, 2012
Messages
389
Reaction score
10
Siema, zrobiłem sobie w LIB pliczek i nazwałem go sobie BLESSINGS.lua, a w nim napisałem to:

LUA:
BLESSINGS = {
	regular_blessings = {
		lvl_range = {min = 20, max = 120},
		minimum_cost_for_each_blessing = 2000,
		maximum_cost_for_each_blessing = 20000,
		},
	twist_of_fate = {
		lvl_range = {min = 20, max = 270},
		minimum_cost_for_twist_of_fate_bless = 2000,
		maximum_cost_for_twist_of_fate_bless = 50000,
		},
	config = {
		ID_of_twist_of_fate_blessing = 6,
		twist_of_fate_enabled = false, -- true/false  zaleznie czy chcemy by pvp bless byl mozliwy do kupienia na naszym servie 
		to_buy_twist_of_fate_need_to_have_minimum_blessings = true,  -- true/false czy do kupienia pvp blessa trzeba miec przynajmniej X regularnych blessow kupionych
		number_of_minimum_blessings_to_buy_twist_of_fate = 1, -- ile blessow regularnych trzeba miec kupionych by kupic pvp blessa 
		},
	blessing_names = {
		[1] = {name = "Wisdom of Solitude"},
		[2] = {name = "Spark of the Phoenix"},
		[3] = {name = "Fire of the Suns"},
		[4] = {name = "Spiritual Shielding"},
		[5] = {name = "Embrace of Tibia"},
		[6] = {name = "Twist of Fate"},
		},
	}

function BLESSINGS_getHowManyBlessingsPlayerHave(cid)
	count = 0
	for i=1,6 do
		if getPlayerBlessing(cid, i) == TRUE then
			count = count + 1
		end
	end
	return count
end

function BLESSING_getBlessingName(bless_id)
	nazwa = BLESSINGS.blessing_names[bless_id].name
	return nazwa
end

function BLESSINGS_blessCostFormula(cid)
	cost = ((getPlayerLevel(cid) - 30) * 200) + 2000
	return cost
end

function BLESSINGS_getEachBlessCostForPlayer(cid)
	local wartosc = 0
	if getPlayerLevel(cid) <= BLESSINGS.regular_blessings.lvl_range.min then
		wartosc = BLESSINGS.regular_blessings.minimum_cost_for_each_blessing
	elseif getPlayerLevel(cid) >= BLESSINGS.regular_blessings.lvl_range.max then
		wartosc = BLESSINGS.regular_blessings.maximum_cost_for_each_blessing
	elseif getPlayerLevel(cid) > BLESSINGS.regular_blessings.lvl_range.min and getPlayerLevel(cid) < BLESSINGS.regular_blessings.lvl_range.max then
		wartosc = BLESSINGS_blessCostFormula(cid)
	end
	return wartosc
end

function BLESSINGS_getTwistOfFateBlessCostForPlayer(cid)
	local wartosc = 0
	if getPlayerLevel(cid) <= BLESSINGS.twist_of_fate.lvl_range.min then
		wartosc = BLESSINGS.twist_of_fate.minimum_cost_for_twist_of_fate_bless
	elseif getPlayerLevel(cid) >= BLESSINGS.regular_blessings.lvl_range.max then
		wartosc = BLESSINGS.twist_of_fate.maximum_cost_for_twist_of_fate_bless
	elseif getPlayerLevel(cid) > BLESSINGS.twist_of_fate.lvl_range.min and getPlayerLevel(cid) < BLESSINGS.twist_of_fate.lvl_range.max then
		wartosc = BLESSINGS_blessCostFormula(cid)
	end
	return wartosc
end

function BLESSINGS_canPlayerBuyTwistOfFateBlessing(cid)
	tbl = {odp = "", status = ""}
	if getPlayerBlessing(cid, BLESSINGS.config.ID_of_twist_of_fate_blessing) == TRUE then
		tbl.odp = "You allready have Twist of Fate blessing!"
		tbl.status = "FALSE"
		return tbl
	elseif not(BLESSINGS.config.twist_of_fate_enabled) then
		tbl.odp = "Twist of Fate blessing is disabled on this server. (Cannot be bought)"
		tbl.status = "FALSE"
		return tbl
	elseif (BLESSINGS.config.twist_of_fate_enabled) then
		if BLESSINGS.config.to_buy_twist_of_fate_need_to_have_minimum_one_bless then
			if BLESSINGS_getHowManyBlessingsPlayerHave(cid) < BLESSINGS.config.number_of_minimum_blessings_to_buy_twist_of_fate then
				tbl.odp = "Sorry, but to buy Twist of Fate blessing you need to buy minimum ".. BLESSINGS.config.number_of_minimum_blessings_to_buy_twist_of_fate .." regular blessings."
				tbl.status = "FALSE"
				return tbl
			else
				tbl.odp = ""
				tbl.status = "TRUE"
				return tbl
			end
		else
			tbl.odp = ""
			tbl.status = "TRUE"
			return tbl	
		end
	end
	return tbl
end

function BLESSINGS_canPlayerBuyThisBlessing(cid, bless_id)
	mesejdz = ""
	bless_name = BLESSING_getBlessingName(bless_id)
	if getPlayerBlessing(cid, bless_id) == TRUE then
		mesejdz = "You allready have '".. bless_name .."' blessing."
	end
	return mesejdz
end

function BLESSINGS_addPlayerAllBlessingsWhichTheyHaveNot(cid)
	for i = 1,5 do
		if getPlayerBlessing(cid, i) ~= TRUE then
			doPlayerAddBlessing(cid, i)
		end
	end
end

function BLESSINGS_buyingBlessingsInTemple(cid, msg)
	if (msgcontains(msg, 'bless') or msgcontains(msg, 'blessing') or msgcontains(msg, 'blessings')) then
		selfSay("There are five different blessings available in five sacred places. These blessings are: the {spiritual shielding}, the {spark of the phoenix}, the {embrace of tibia}, the {fire of the suns} and the {wisdom of solitude}. You have ".. BLESSINGS_getHowManyBlessingsPlayerHave(cid) .." out of 5 blessings. I can also provide you with {all} blessings at once.", cid)
	elseif msgcontains(msg, 'all') then
		if BLESSINGS_getHowManyBlessingsPlayerHave(cid) >= 5 then
			selfSay("You already possess all blessings.", cid)
			return true
		elseif BLESSINGS_getHowManyBlessingsPlayerHave(cid) < 5 then
			liczba_blessow_do_kupienia = (5 - BLESSINGS_getHowManyBlessingsPlayerHave(cid))
			cena = liczba_blessow_do_kupienia * BLESSINGS_getEachBlessCostForPlayer(cid)
			selfSay("Do you want to buy all blessings which you don't have for ".. cena .. "?", cid)
			talkState[talkUser] = 36200
		end
	elseif msgcontains(msg, 'yes') then
		if talkState[talkUser] == 36200 then
			liczba_blessow_do_kupienia = (5 - BLESSINGS_getHowManyBlessingsPlayerHave(cid))
			cena = liczba_blessow_do_kupienia * BLESSINGS_getEachBlessCostForPlayer(cid)
			if getPlayerMoney(cid) >= cena then
				doPlayerRemoveMoney(cid, cena)
				BLESSINGS_addPlayerAllBlessingsWhichTheyHaveNot(cid)
				selfSay("You have now all blessings.", cid)
				return true
			elseif getPlayerMoney(cid) < cena then
				selfSay("You don't have required number of money to buy all blessing which you don't have. (".. cena .." gp you need).", cid)
				return true
			end
		
		end
	end



end



Chyba wiecie o co chodzi. Zamierzałem zrobić by do blesserów (npców od blessów) łatwo i przyjemnie się potem dodawało jedną linijkę z blessami, narazie zrobiłem to tylko dla temple blesserów i narazie dla kupowania wszystkich blessów naraz, bądź tych blessów, których nie mamy, potem dokończe i zrobie by kupowalo sie tez pojedyncze blessy...

I teraz problem, czy to będzie dobrze działać jak dodam do npc'a tą jedną linijke:

function BLESSINGS_buyingBlessingsInTemple(cid, msg)

?

chcę to zrobić w taki sposób, mamy jakiegoś npc i on ma swoje dialogi:

LUA:
  if msgcontains(msg, 'bless') then
      selfSay("There are five different blessings available in five sacred places. These blessings are: the {spiritual} shielding, the spark of the {phoenix}, the {embrace} of Tibia, the fire of the {suns} and the wisdom of {solitude}.", cid)
    elseif msgcontains(msg, 'solitude') then
	  selfSay('Talk to the hermit Eremo on the isle of Cormaya about this blessing.', cid)
	elseif msgcontains(msg, 'phoenix') then
	  selfSay('The spark of the phoenix is given by the dwarven priests of earth and fire in Kazordoon.', cid)
	elseif msgcontains(msg, 'embrace') then
	  selfSay('The druids north of Carlin will provide you with the embrace of Tibia.', cid)
	elseif msgcontains(msg, 'suns') then
	  selfSay('You can ask for the blessing of the two suns in the suntower near Ab\'Dendriel.', cid)
	end

i tutaj dam tą funkcję


to czy będzie to działało? (nie mam teraz jak przetestować)

a drugie pytanie, najważniejsze, czy wgl dobrą drogę obrałem?
 
Back
Top