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

Solved !bless with real price´s

danne3131

Active Member
Joined
Jun 26, 2008
Messages
390
Solutions
1
Reaction score
48
Ive got this fully working !bless for tfs 1.1 .. right now it costs 50k whatever level you are..

Ive wounder if anyone got the required Lua skill to make the bless price like real tibia, The higher level the more it will cost !
Code:
local bless = {1, 2, 3, 4, 5}
local cost = 50000 -- Cost in gp.

function onSay(cid, words, param)
     local player = Player(cid)
     for i = 1, table.maxn(bless) do
         if player:hasBlessing(bless[i]) then
             return player:sendCancelMessage("You already have all blessings.")
         end
     end

     if player:removeMoney(cost) then
         for i = 1, table.maxn(bless) do
             player:addBlessing(bless[i])
         end
         player:sendTextMessage(MESSAGE_INFO_DESCR, "You have bought all blessings.")
         player:say("You have bought all blessings.",  TALKTYPE_MONSTER_SAY)
         player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
     else
         player:sendCancelMessage("You don't have enough money.")
     end
     return true
end
Thanks in advance, Yours Daniel
 
Just use
Code:
if player:removeMoney(player:getLevel() * cost) then
like this?

Code:
local bless = {1, 2, 3, 4, 5}
local cost = 50000 -- Cost in gp.

function onSay(cid, words, param)
     local player = Player(cid)
     for i = 1, table.maxn(bless) do
         if player:hasBlessing(bless[i]) then
             return player:sendCancelMessage("You already have all blessings.")
         end
     end

     if player:removeMoney(player:getLevel() * cost) then
         for i = 1, table.maxn(bless) do
             player:addBlessing(bless[i])
         end
         player:sendTextMessage(MESSAGE_INFO_DESCR, "You have bought all blessings.")
         player:say("You have bought all blessings.",  TALKTYPE_MONSTER_SAY)
         player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
     else
         player:sendCancelMessage("You don't have enough money.")
     end
     return true
end

EDIT

Level 121 with 6 cc in the backpack getting ( You dont have enough money) :O
 
Change
Code:
player:removeMoney(player:getLevel() * cost)
to
Code:
player:removeMoney(getBlessingsCost(player:getLevel()) * 5)
 
What that code is doing
Code:
player:removeMoney(player:getLevel() * cost)
It will get character level and multiply it by the blessing cost.
So if you leave it like that this is what will happen:
So right now you have 50000 as price for bless.

Lets say a level 10 buys bless. He will have to pay 500,000 gps for all blessings, why?

Because the code is saying get player level and multiply it by the cost to get total cost. (10*50000)
 
Change
Code:
player:removeMoney(player:getLevel() * cost)
to
Code:
player:removeMoney(getBlessingsCost(player:getLevel()) * 5)
Still the same error, Not enough money.. Should local prize be the cost per bless, like 2000 gold ?
 
Code:
local totalBlessPrice = getBlessingsCost(player:getLevel()) * 5
if player:getBlessings() == 5 then
                npcHandler:say("You already have been blessed!", cid)
            elseif player:removeMoney(totalBlessPrice) then
                npcHandler:say("You have been blessed by all of five gods!, |PLAYERNAME|.", cid)
                for b = 1, 5 do
                    player:addBlessing(b)
                end
                player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
            else
                npcHandler:say("Come back when you have enough money.", cid)
            end

small piece of code for you to get some idea of what to do:

https://github.com/PrinterLUA/FORGOTTENSERVER-ORTS/blob/master/data/npc/scripts/Henricus.lua
 
Solved, Works with real prices!


Code:
local bless = {1, 2, 3, 4, 5}

function onSay(cid, words, param)
local player = Player(cid)
for i = 1, table.maxn(bless) do
if player:hasBlessing(bless[i]) then
return player:sendCancelMessage("You already have all blessings.")
end
end
local money = getBlessingsCost(player:getLevel()) * 5
if player:removeMoney(money) then
for i = 1, table.maxn(bless) do
player:addBlessing(bless[i])
end
player:sendTextMessage(MESSAGE_INFO_DESCR, "You have bought all blessings for "..money.."gp.")
player:say("You have bought all blessings.", TALKTYPE_MONSTER_SAY)
player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
else
player:sendCancelMessage("You don't have enough money.")
end
return true
end
end
 
Last edited:
Code:
local bless = {1, 2, 3, 4, 5}

function onSay(cid, words, param)
     local player = Player(cid)
     for i = 1, table.maxn(bless) do
         if player:hasBlessing(bless[i]) then
             return player:sendCancelMessage("You already have all blessings.")
         end
     end
     local money = getBlessingsCost(player:getLevel()) * 5
     if player:removeMoney(money) then
         for i = 1, table.maxn(bless) do
             player:addBlessing(bless[i])
         end
         player:sendTextMessage(MESSAGE_INFO_DESCR, "You have bought all blessings for "..money.."gp.")
         player:say("You have bought all blessings.",  TALKTYPE_MONSTER_SAY)
         player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
     else
         player:sendCancelMessage("You don't have enough money.")
     end
     return true
end
 
I wrote bless talkaction for my friend. It's related to this thread and this thread is first in google, so I post it here.

I don't know how 'real' it is, but:
level under 50 - free bless
from level 50 to 120 - 36k + 1.2k per level
from level 120 - 120k
TFS 1.1 code, not tested, but should be ok:
PHP:
-- 5 or 6 [twist of fate] ?
local totalBlessCount = 5

function onSay(player, words, param)
    if player:hasBlessing(1) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are already blessed.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
    else
        local playerBlessCost
        if player:getLevel() < 50 then
            -- under level 50 it's free
            playerBlessCost = 0
        else
            -- from level 50 cost 36k + 200 gold coins for each level
            -- limit to maximum 120k
            playerBlessCost = math.min(120000, 36000 + (player:getLevel() - 50) * 1200)
        end

        if player:removeMoney(playerBlessCost) then
            for blessId = 1, totalBlessCount do
                player:addBlessing(blessId)
            end

            player:sendCancelMessage("You received all blessings for " .. playerBlessCost .. " gold coins.")
            player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You do not have enough money. Bless on your level costs " .. playerBlessCost .. " gold coins.")
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
        end
    end

    return false
end
 
Back
Top