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

TalkAction !bless for 0.2.4 cost varys on level

Saints Anathema

Old School Doleran
Joined
Feb 24, 2009
Messages
653
Reaction score
8
Location
BC,Canada
Tested and Working for 0.2.4

Credits go to Kio a player from my server, we upgraded and this isnt working for 0.4 so i thought id release it anyways ive never seen a variation of it like this on here so maybe someone can learn something from it

not doing this for rep, i didnt make it, im just sharing it

Code:
function onSay(cid, words, param) 
-- variables
local bless = {1, 2, 3, 4, 5}
local level = getPlayerLevel(cid)
local cost = 5000 -- Cost in gp.function onSay(cid, words, param)  
local totalCost = level * cost
-- script
 for i = 1, table.maxn(bless) do        
 if(getPlayerBlessing(cid, bless[i])) then            
 doPlayerSendCancel(cid, "You have already all blessings.")            
 return TRUE        
 end    
 end        
 if(doPlayerRemoveMoney(cid, totalCost) == TRUE) then       
  for i = 1, table.maxn(bless) do           
   doPlayerAddBlessing(cid, bless[i])        
   end        
   doPlayerSendCancel(cid, "You bought all blessing.")   
    else        
    doPlayerSendCancel(cid, "You don/'t have enough money.")    
    end   
     return TRUE
     end

and then ofcourse

Code:
<talkaction words="!bless" script="bless.lua"/>
 
you can find a global prices one easy on otland, when i have more time ill check what i have on my computer but the reason i posted this is the fact it varys the price on the level of the player
 
Better
Lua:
-- [( Made by LucasOlzon from otland.net )] --
function onSay(cid, words, param)
local fail = 0
 
	if getPlayerLevel(cid) < 31 then
		cost = 2000
	else
		cost = ((getPlayerLevel(cid) - 30) * 200) + 2000
	end
 
	if cost > 20000 then
		cost = 20000
	end
 
	for i = 1, 5 do
		if getPlayerBlessing(cid, i) then
			fail = fail + 1
		else
			if doPlayerRemoveMoney(cid, cost) == TRUE then
				doPlayerAddBlessing(cid, i)
				if i == 5 and not(fail == 5) then
					doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
				end
			else
doCreatureSay(cid, "You do not have enough money to buy all the blessings or cap/slot to get the rest of money!", TALKTYPE_ORANGE_1)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
				break
			end
		end
	end
	if fail == 5 then
		doPlayerSendCancel(cid, "You already have all the blessings!")
	end
return TRUE
end
 
Better
Lua:
-- [( Made by LucasOlzon from otland.net )] --
function onSay(cid, words, param)
local fail = 0
 
	if getPlayerLevel(cid) < 31 then
		cost = 2000
	else
		cost = ((getPlayerLevel(cid) - 30) * 200) + 2000
	end
 
	if cost > 20000 then
		cost = 20000
	end
 
	for i = 1, 5 do
		if getPlayerBlessing(cid, i) then
			fail = fail + 1
		else
			if doPlayerRemoveMoney(cid, cost) == TRUE then
				doPlayerAddBlessing(cid, i)
				if i == 5 and not(fail == 5) then
					doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
				end
			else
doCreatureSay(cid, "You do not have enough money to buy all the blessings or cap/slot to get the rest of money!", TALKTYPE_ORANGE_1)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
				break
			end
		end
	end
	if fail == 5 then
		doPlayerSendCancel(cid, "You already have all the blessings!")
	end
return TRUE
end


PHP:
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

the price goes up each level?
200 gold coins per level?
and another thing
is possible to use the talkaction
needed to have some storage?
 
I need the character to use the talkaction needed storage id: 1111
is for a mission and if possible take storage off having id: 1112
have 26% discount.
 
Didn't understand.
1. Need storage 1111 to get bless
2. ?

1. need storage 1111 to use command !bless.
2. if you have storage 1112, to use !bless, you get a discount, in this case would be 26% discount when using talkaction.
understand?
 
Test

Lua:
-- [( Made by LucasOlzon from otland.net )] --
function onSay(cid, words, param)
local fail = 0
 
	if getPlayerLevel(cid) < 31 getCreatureStorage(cid, 1111) > 0 then
		cost = 2000
	elseif getCreatureStorage(cid, 1111) > 0 then
		cost = ((getPlayerLevel(cid) - 30) * 200) + 2000
	end

        if getPlayerLevel(cid) >= 31 getCreatureStorage(cid, 1112) > 0 then
		cost = ((getPlayerLevel(cid) - 30) * 200) + (2000/100)*64
	end
 
	if cost > 20000 then
		cost = 20000
	end
 
	for i = 1, 5 do
		if getPlayerBlessing(cid, i) then
			fail = fail + 1
		else
			if doPlayerRemoveMoney(cid, cost) == TRUE then
				doPlayerAddBlessing(cid, i)
				if i == 5 and not(fail == 5) then
					doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
				end
			else
doCreatureSay(cid, "Something is wrong!", TALKTYPE_ORANGE_1)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
				break
			end
		end
	end
	if fail == 5 then
		doPlayerSendCancel(cid, "You already have all the blessings!")
	end
return TRUE
end
 
Last edited:
not working...

Code:
[30/06/2011 16:39:55] [Error - LuaScriptInterface::loadFile] data/talkactions/scripts/bless.lua:5: 'then' expected near 'getCreatureStorage'
[30/06/2011 16:39:55] [Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/bless.lua)
[30/06/2011 16:39:55] data/talkactions/scripts/bless.lua:5: 'then' expected near 'getCreatureStorage'
 
Sorry :D
Lua:
-- [( Made by LucasOlzon from otland.net )] --
function onSay(cid, words, param)
local fail = 0
 
	if getPlayerLevel(cid) < 31 and getCreatureStorage(cid, 1111) > 0 then
		cost = 2000
	elseif getCreatureStorage(cid, 1111) > 0 then
		cost = ((getPlayerLevel(cid) - 30) * 200) + 2000
	end
 
        if getPlayerLevel(cid) >= 31 and getCreatureStorage(cid, 1112) > 0 then
		cost = ((getPlayerLevel(cid) - 30) * 200) + (2000/100)*64
	end
 
	if cost > 20000 then
		cost = 20000
	end
 
	for i = 1, 5 do
		if getPlayerBlessing(cid, i) then
			fail = fail + 1
		else
			if doPlayerRemoveMoney(cid, cost) == TRUE then
				doPlayerAddBlessing(cid, i)
				if i == 5 and not(fail == 5) then
					doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
				end
			else
doCreatureSay(cid, "Something is wrong!", TALKTYPE_ORANGE_1)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
				break
			end
		end
	end
	if fail == 5 then
		doPlayerSendCancel(cid, "You already have all the blessings!")
	end
return TRUE
end
 
Try this one
Lua:
-- [( Made by LucasOlzon from otland.net )] --
function onSay(cid, words, param)
local fail = 0
 
	if getPlayerLevel(cid) < 31 and getCreatureStorage(cid, 1111) > 0 then
		cost = 2000
	elseif getCreatureStorage(cid, 1111) > 0 then
		cost = ((getPlayerLevel(cid) - 30) * 200) + 2000
	elseif getPlayerLevel(cid) >= 31 and getCreatureStorage(cid, 1112) > 0 then
		cost = ((getPlayerLevel(cid) - 30) * 200) + (2000/100)*64
	end
 
	if cost > 20000 then
		cost = 20000
	end
 
	for i = 1, 5 do
		if getPlayerBlessing(cid, i) then
			fail = fail + 1
		else
			if doPlayerRemoveMoney(cid, cost) == TRUE then
				doPlayerAddBlessing(cid, i)
				if i == 5 and not(fail == 5) then
					doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
				end
			else
doCreatureSay(cid, "Something is wrong!", TALKTYPE_ORANGE_1)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
				break
			end
		end
	end
	if fail == 5 then
		doPlayerSendCancel(cid, "You already have all the blessings!")
	end
return TRUE
end
 
Code:
[30/06/2011 18:45:51] [Error - TalkAction Interface] 
[30/06/2011 18:45:51] data/talkactions/scripts/bless.lua:onSay
[30/06/2011 18:45:51] Description: 
[30/06/2011 18:45:51] data/talkactions/scripts/bless.lua:13: attempt to compare number with nil
[30/06/2011 18:45:51] stack traceback:
[30/06/2011 18:45:51] 	data/talkactions/scripts/bless.lua:13: in function <data/talkactions/scripts/bless.lua:2>

:eek:
 
Working for me
Lua:
-- [( Made by LucasOlzon from otland.net )] --
function onSay(cid, words, param)
local fail = 0
 
	if getPlayerLevel(cid) < 31 and getCreatureStorage(cid, 1111) > 0 then
		cost = 2000
	elseif getPlayerLevel(cid) < 31 and getCreatureStorage(cid, 1111) > 0 then
		cost = ((getPlayerLevel(cid) - 30) * 200) + 2000
	elseif getPlayerLevel(cid) >= 31 and getCreatureStorage(cid, 1112) > 0 then
		cost = ((getPlayerLevel(cid) - 30) * 200) + (2000 / 100) * 64
	end
 
	if cost > 20000 then
		cost = 20000
	end
 
	for i = 1, 5 do
		if getPlayerBlessing(cid, i) then
			fail = fail + 1
		else
			if doPlayerRemoveMoney(cid, cost) == TRUE then
				doPlayerAddBlessing(cid, i)
				if i == 5 and not(fail == 5) then
					doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
				end
			else
				doCreatureSay(cid, "Something is wrong!", TALKTYPE_ORANGE_1)
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
				break
			end
		end
	end
	if fail == 5 then
		doPlayerSendCancel(cid, "You already have all the blessings!")
	end
return TRUE
end
 
Lua:
function onSay(cid, words, param)
	if getPlayerStorageValue(cid, 1111) == -1 then
		doPlayerSendCancel(cid, 'You can\'t use this command.')
		return TRUE
	end

	local t = {}
	for i = 1, 5 do
		if not getPlayerBlessing(cid, i) then
			table.insert(t, i)
		end
	end

	if #t == 0 then
		doPlayerSendCancel(cid, 'You already have all the blessings!')
		return TRUE
	end

	local lvl, cost = getPlayerLevel(cid)
	if lvl < 31 then
		cost = 2000
	elseif lvl > 119 then
		cost = 20000
	else
		cost = (lvl - 30) * 200 + 2000
	end

	if getPlayerStorageValue(cid, 1112) ~= -1 then
		cost = cost * 0.74
	end

	if doPlayerRemoveMoney(cid, cost) == TRUE then
		for i = 1, #t do
			doPlayerAddBlessing(cid, t[i])
		end
		doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_RED)
	else
		doPlayerSendCancel(cid, 'You need ' .. cost .. ' gold!')
	end

	return TRUE
end
 
Back
Top