• 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!

[Npc] Npc that gives blessings to each level a price

Knight God

Member
Joined
Oct 19, 2008
Messages
1,180
Reaction score
21
Good morning otland.net, well my order is as follows:
in real tibia, the blessings cost a certain price depending on your level, and good wishes to know if is possible for a single NPC sells the 5 blessings and the price goes up according to their level, for example:

Code:
Level	Each Bless (in gp)
1 to 30	2,000
31	2,200
32	2,400
33	2,600
34	2,800
35	3,000
36	3,200
37	3,400
38	3,600
39	3,800
40	4,000
41	4,200
42	4,400
43	4,600
44	4,800
45	5,000
46	5,200
47	5,400
48	5,600
49	5,800
50	6,000
51	6,200
52	6,400
53	6,600
54	6,800
55	7,000
56	7,200
57	7,400
58	7,600
59	7,800
60	8,000
61	8,200
62	8,400
63	8,600
64	8,800
65	9,000
66	9,200
67	9,400
68	9,600
69	9,800
70	10,000
71	10,200
72	10,400
73	10,600
74	10,800
75	11,000
76	11,200
77	11,400
78	11,600
79	11,800
80	12,000
81	12,200
82	12,400
83	12,600
84	12,800
85	13,000
86	13,200
87	13,400
88	13,600
89	13,800
90	14,000
91	14,200
92	14,400
93	14,600
94	14,800
95	15,000
96	15,200
97	15,400
98	15,600
99	15,800
100	16,000
101	16,200
102	16,400
103	16,600
104	16,800
105	17,000
106	17,200
107	17,400
108	17,600
109	17,800
110	18,000
111	18,200
112	18,400
113	18,600
114	18,800
115	19,000
116	19,200
117	19,400
118	19,600
119	19,800
120+	20,000
.
well, I hope it is possible and that can help me with this request is not urgent order, but I hope you can help me :/
Thanks in advance.^_^
 
This should be good enough

Bless.lua
Code:
--[[
	!---------------------------------!
	!---Created by Teh Maverick-------!
	!-------www.otland.net------------!
	!---------------------------------!
]]

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local talktopic, amount, playerLevel = {}, {}, {}
local str = ""

--Config
local highLevelPrice = 1 --(Real Tibia Price: 20000) price for players level 120+, per blessing
local lowLevelPrice = 1 --(Real Tibia Price: 2000) price for players level 30 and lower, per blessing
local pricePerLevel = 1 --(Real Tibia Price: 200) this price only applies to players between level 30 & 120, formula=((pricePerLevel*playerLevel)+lowLevelPrice)
--Text
local text = "Do you want to buy all five blessings for " --leave this unfinished (it will add the price to the end)
local thankyou = "You have bought all 5 of my blessings for " --leave this unfinished (it will add the price to the end)
local help = "I can give all of you my {blessings} for free. Blessings will protect you from losing items on death and reduce the amount of levels you lose when you die."
local already = "You already have my blessings."
local nomoney = "You don\'t have enough money for all five blessings."

function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid)			end
function onCreatureDisappear(cid) 			npcHandler:onCreatureDisappear(cid)			end
function onCreatureSay(cid, type, msg) 			npcHandler:onCreatureSay(cid, type, msg)		end
function onThink() 					npcHandler:onThink()					end

function greetCallback(cid)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	talktopic[talkUser], amount[talkUser], playerLevel[talkUser] = 0, 0, 0
    return true
end

function creatureSayCallback(cid, type, msg)

talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	if(not npcHandler:isFocused(cid)) then
		return false
	end
	
playerLevel[talkUser] = getPlayerLevel(cid)
amount[talkUser] = 0

	if (getPlayerBlessing(cid,1)
		and getPlayerBlessing(cid,2)
			and getPlayerBlessing(cid,3)
				and getPlayerBlessing(cid,4)
					and getPlayerBlessing(cid,5)) then
				npcHandler:say(already, cid)
				return false
	else
		if playerLevel[talkUser] < 30 then
		  amount[talkUser] = lowLevelPrice*5
		  str = "{"..amount[talkUser].."}gp?"
			elseif playerLevel[talkUser] > 30 and playerLevel[talkUser] < 120 then
				amount[talkUser] = (((playerLevel[talkUser]-30)*pricePerLevel)+lowLevelPrice)*5
				str = "{"..amount[talkUser].."}gp?"
					elseif playerLevel[talkUser] >= 120 then
						amount[talkUser] = highLevelPrice*5
						str = "{"..amount[talkUser].."}gp?"
		end
	end
	
	str = text..str
	
		if (msgcontains(msg, "help") or msgcontains(msg, "job")) then
			talktopic[talkUser] = 0
			npcHandler:say(help, cid)
	
		elseif talktopic[talkUser] == 0 and (msgcontains(msg, "yes") or msgcontains(msg, "blessings") or msgcontains(msg, "blessing")) then
			talktopic[talkUser] = 1
			npcHandler:say(str, cid)
			
		elseif talktopic[talkUser] == 1 and (msgcontains(msg, "yes") or msgcontains(msg, "ok")) then
			talktopic[talkUser] = 2
				if doPlayerRemoveMoney(cid, amount[talkUser]) then
					for i = 1,5 do
					doPlayerAddBlessing(cid,i)
					end
					npcHandler:say(thankyou.."{"..amount[talkUser].."}", cid)
				else
				  npcHandler:say(nomoney, cid)
				  return false
				end
		end
	return true
end

npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|. Do you want my {blessings}?")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Please visit again. You never know when you may need my blessings!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Please visit again |PLAYERNAME|")

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
THX :D repp++++

and may receive a discount for any mission or this will get some storage for a discount?
sorry for my bad english
 
Last edited:
is possible if you have a certain storage you receive a discount for each bless, or if you have a item in the backpack you have a discount ?
is possible?
 
is possible if you have a certain storage you receive a discount for each bless, or if you have a item in the backpack you have a discount ?
is possible?
 
how add?
PHP:
--[[
	!---------------------------------!
	!---Created by Teh Maverick-------!
	!-------www.otland.net------------!
	!---------------------------------!
]]

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local talktopic, amount, playerLevel = {}, {}, {}
local str = ""

--Config
local highLevelPrice = 25000 --(Real Tibia Price: 20000) price for players level 120+, per blessing
local lowLevelPrice = 2000 --(Real Tibia Price: 2000) price for players level 30 and lower, per blessing
local pricePerLevel = 200 --(Real Tibia Price: 200) this price only applies to players between level 30 & 120, formula=((pricePerLevel*playerLevel)+lowLevelPrice)
--Text
local text = "Do you want to buy all five blessings for " --leave this unfinished (it will add the price to the end)
local thankyou = "You have bought all 5 of my blessings for " --leave this unfinished (it will add the price to the end)
local help = "I can give all of you my {blessings} for free. Blessings will protect you from losing items on death and reduce the amount of levels you lose when you die."
local already = "You already have my blessings."
local nomoney = "You don\'t have enough money for all five blessings."

function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid)			end
function onCreatureDisappear(cid) 			npcHandler:onCreatureDisappear(cid)			end
function onCreatureSay(cid, type, msg) 			npcHandler:onCreatureSay(cid, type, msg)		end
function onThink() 					npcHandler:onThink()					end

function greetCallback(cid)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	talktopic[talkUser], amount[talkUser], playerLevel[talkUser] = 0, 0, 0
    return true
end

function creatureSayCallback(cid, type, msg)

talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	if(not npcHandler:isFocused(cid)) then
		return false
	end
	
playerLevel[talkUser] = getPlayerLevel(cid)
amount[talkUser] = 0

	if (getPlayerBlessing(cid,1)
		and getPlayerBlessing(cid,2)
			and getPlayerBlessing(cid,3)
				and getPlayerBlessing(cid,4)
					and getPlayerBlessing(cid,5)) then
				npcHandler:say(already, cid)
				return false
	else
		if playerLevel[talkUser] < 30 then
		  amount[talkUser] = lowLevelPrice*5
		  str = "{"..amount[talkUser].."}gp?"
			elseif playerLevel[talkUser] > 30 and playerLevel[talkUser] < 200 then
				amount[talkUser] = (((playerLevel[talkUser]-30)*pricePerLevel)+lowLevelPrice)*5
				str = "{"..amount[talkUser].."}gp?"
					elseif playerLevel[talkUser] >= 200 then
						amount[talkUser] = highLevelPrice*5
						str = "{"..amount[talkUser].."}gp?"
		end
	end
	
	str = text..str
	
		if (msgcontains(msg, "help") or msgcontains(msg, "job")) then
			talktopic[talkUser] = 0
			npcHandler:say(help, cid)
	
		elseif talktopic[talkUser] == 0 and (msgcontains(msg, "yes") or msgcontains(msg, "blessings") or msgcontains(msg, "blessing")) then
			talktopic[talkUser] = 1
			npcHandler:say(str, cid)
			
		elseif talktopic[talkUser] == 1 and (msgcontains(msg, "yes") or msgcontains(msg, "ok")) then
			talktopic[talkUser] = 2
				if doPlayerRemoveMoney(cid, amount[talkUser]) then
					for i = 1,5 do
					doPlayerAddBlessing(cid,i)
					end
					npcHandler:say(thankyou.."{"..amount[talkUser].."}", cid)
				else
				  npcHandler:say(nomoney, cid)
				  return false
				end
		end
	return true
end

npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|. Do you want my {blessings}?")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Please visit again. You never know when you may need my blessings!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Please visit again |PLAYERNAME|")

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local t = {}

local highLevelPrice = 25000 --(Real Tibia Price: 20000) price for players level 120+, per blessing
local lowLevelPrice = 2000 --(Real Tibia Price: 2000) price for players level 30 and lower, per blessing
local pricePerLevel = 200 --(Real Tibia Price: 200) this price only applies to players between level 30 & 120, formula=((pricePerLevel*playerLevel)+lowLevelPrice)

function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)             npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)             npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                     npcHandler:onThink()                    end

local getCost = function(cid)
	local l, s = getPlayerLevel(cid)
	if l <= 30 then
		s = lowLevelPrice * 5
	elseif l >= 200 then
		s = highLevelPrice * 5
	else
		s = (((l-30) * pricePerLevel) + lowLevelPrice) * 5
	end
[B][COLOR="red"]	if getCreatureStorage(cid, 123) == 1 then
		s = s * 0.5
	end[/COLOR][/B]
	return math.ceil(s)
end

function greetCallback(cid)
	t[cid] = nil
	return true
end

function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end

	local n
	if msgcontains(msg, 'help') or msgcontains(msg, 'job') then
		npcHandler:say('I can sell you all 5 of my blessings. They will protect you from losing items on death and reduce the amount experience you lose when you die.', cid)
	elseif msgcontains(msg, 'bless') then
		if getPlayerBlessing(cid, 1) and getPlayerBlessing(cid, 2) and getPlayerBlessing(cid, 3) and getPlayerBlessing(cid, 4) and getPlayerBlessing(cid, 5) then
			npcHandler:say('You already have my blessings.', cid)
		else
			npcHandler:say('Do you want to buy all 5 blessings for ' .. getCost(cid) .. ' gold?', cid)
			n = true
		end
	elseif t[cid] and msgcontains(msg, 'yes') then
		local p = getCost(cid)
		if doPlayerRemoveMoney(cid, p) then
			for i = 1, 5 do
				doPlayerAddBlessing(cid, i)
			end
			npcHandler:say('You have bought all 5 of my blessings for ' .. p .. ' gold.', cid)
		else
			npcHandler:say('You don\'t have enough money for all 5 blessings.', cid)
		end
	end
	t[cid] = n
	return true
end

npcHandler:setMessage(MESSAGE_GREET, 'Hello |PLAYERNAME|. Do you want my {blessings}?')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Please visit again. You never know when you may need my blessings!')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Please visit again |PLAYERNAME|')

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
thanks a query.
How much % discount offers you the npc?


s = s * 0.5 = 0,5%?

and if need add more %?

for example:

10% or 15, 20, 25, 39, 47, etc?
 
I have two more ideas:

1 ° That the script is by talkaction and required to use storage id 1111
2 ° that having storage ID 1112 has a 25% discount on talkaction.

is it possible?
 
Back
Top