• 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 NPCS - BLESSINGS - TWIST OF FATE!

ribeiiro02

New Member
Joined
May 21, 2014
Messages
44
Reaction score
1
Hello, i want to add in this code, sellings bless twist of fate, and "heal" its for sell all blessings in npcs temple. thanks!!

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

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

--Config
local highLevelPrice = 20000 --(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].."} gold coins?"
            elseif playerLevel[talkUser] > 30 and playerLevel[talkUser] < 120 then
                amount[talkUser] = (((playerLevel[talkUser]-30)*pricePerLevel)+lowLevelPrice)*5
                str = "{"..amount[talkUser].."} gold coins?"
                    elseif playerLevel[talkUser] >= 120 then
                        amount[talkUser] = highLevelPrice*5
                        str = "{"..amount[talkUser].."} gold coins?"
        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())
 
Try this one haha idk if twist of fate is 6.

I didn't understand the second thing u asked for, you mean you need to say "Heal" to buy the blessings?

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

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

--Config
local highLevelPrice = 20000 --(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 six blessings for " --leave this unfinished (it will add the price to the end)
local thankyou = "You have bought all 6 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 six 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)
                    and getPlayerBlessing(cid,6)) then
                npcHandler:say(already, cid)
                return false
    else
        if playerLevel[talkUser] < 30 then
          amount[talkUser] = lowLevelPrice*6
          str = "{"..amount[talkUser].."} gold coins?"
            elseif playerLevel[talkUser] > 30 and playerLevel[talkUser] < 120 then
                amount[talkUser] = (((playerLevel[talkUser]-30)*pricePerLevel)+lowLevelPrice)*6
                str = "{"..amount[talkUser].."} gold coins?"
                    elseif playerLevel[talkUser] >= 120 then
                        amount[talkUser] = highLevelPrice*6
                        str = "{"..amount[talkUser].."} gold coins?"
        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,6 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())

Edit: LOL I deleted half of the script without knowing it. Now should work (if not ur script is not working either xd)
 
Last edited:
no work.

Try this one haha idk if twist of fate is 6.

I didn't understand the second thing u asked for, you mean you need to say "Heal" to buy the blessings?

Code:
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)
            and getPlayerBlessing(cid,6)) then
                npcHandler:say(already, cid)
                return false
    else
        if playerLevel[talkUser] < 30 then
          amount[talkUser] = lowLevelPrice*6
          str = "{"..amount[talkUser].."} gold coins?"
            elseif playerLevel[talkUser] > 30 and playerLevel[talkUser] < 120 then
                amount[talkUser] = (((playerLevel[talkUser]-30)*pricePerLevel)+lowLevelPrice)*6
                str = "{"..amount[talkUser].."} gold coins?"
                    elseif playerLevel[talkUser] >= 120 then
                        amount[talkUser] = highLevelPrice*6
                        str = "{"..amount[talkUser].."} gold coins?"
        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,6 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())

I tabbed it right but here doesn't show correctly
 
no... erase the heal part!

only npc sellings twist of fate with all blessings.
which tfs are you using? 1.0?

this one works for 1.0 (blessings + heal)
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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 creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local player = Player(cid)

    if player:getLevel() < 30 then
        blessprize = 2000*6
    elseif player:getLevel() >= 30 and player:getLevel() <= 120 then
        blessprize = (((player:getLevel()-30)*200)+2000)*6
    elseif player:getLevel() > 120 then
        blessprize = 20000*6
    end


    if(msgcontains(msg, "blessing") or msgcontains(msg, "bless")) then
            npcHandler:say("Do you want to receive all blessings for "..blessprize.." gold?", cid)
            npcHandler.topic[cid] = 1
    end
    if(msgcontains(msg, "yes")) then
        if(npcHandler.topic[cid] == 1) then
            if player:hasBlessing(1) or player:hasBlessing(2) or player:hasBlessing(3) or player:hasBlessing(4) or player:hasBlessing(5) or player:hasBlessing(6) then
                npcHandler:say("You already have been blessed!", cid)
            else
                if player:removeMoney(blessprize) then
                    npcHandler:say("You have been blessed by all of six gods!, " .. player:getName() .. ".", cid)
                    player:addBlessing(1)
                    player:addBlessing(2)
                    player:addBlessing(3)
                    player:addBlessing(4)
                    player:addBlessing(5)
                    player:addBlessing(6)
                    player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
                    npcHandler.topic[cid] = 0
                else
                    npcHandler:say("Come back when you have enough money.", cid)
                    npcHandler.topic[cid] = 0
                end
            end
        end
    end
    if(msgcontains(msg, "no")) then
        if(npcHandler.topic[cid] == 1) then
            npcHandler:say("Then no.", cid)
            npcHandler.topic[cid] = 0
        end
    end
    if msgcontains(msg, "heal") then
        npcHandler:say("Do you need the healing now?", cid)
        npcHandler.topic[cid] = 2
    elseif(npcHandler.topic[cid] == 2) then
        if msgcontains(msg, "no") then
            npcHandler:say("As you wish.", cid)
            npcHandler.topic[cid] = 0
        elseif msgcontains(msg, "yes") then
            npcHandler:say("So be healed!", cid)
            doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
            doSendMagicEffect(getNpcPos(), CONST_ME_MAGIC_BLUE)
            npcHandler.topic[cid] = 0
        end
    end
    return true
end

npcHandler:setMessage(MESSAGE_GREET, "Greetings, fellow believer |PLAYERNAME|. I can offer you {blessings} or a free {heal}!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Always be on guard, |PLAYERNAME|!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "This ungraceful haste is most suspicious!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
which tfs are you using? 1.0?

this one works for 1.0 (blessings + heal)
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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 creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local player = Player(cid)

    if player:getLevel() < 30 then
        blessprize = 2000*6
    elseif player:getLevel() >= 30 and player:getLevel() <= 120 then
        blessprize = (((player:getLevel()-30)*200)+2000)*6
    elseif player:getLevel() > 120 then
        blessprize = 20000*6
    end


    if(msgcontains(msg, "blessing") or msgcontains(msg, "bless")) then
            npcHandler:say("Do you want to receive all blessings for "..blessprize.." gold?", cid)
            npcHandler.topic[cid] = 1
    end
    if(msgcontains(msg, "yes")) then
        if(npcHandler.topic[cid] == 1) then
            if player:hasBlessing(1) or player:hasBlessing(2) or player:hasBlessing(3) or player:hasBlessing(4) or player:hasBlessing(5) or player:hasBlessing(6) then
                npcHandler:say("You already have been blessed!", cid)
            else
                if player:removeMoney(blessprize) then
                    npcHandler:say("You have been blessed by all of six gods!, " .. player:getName() .. ".", cid)
                    player:addBlessing(1)
                    player:addBlessing(2)
                    player:addBlessing(3)
                    player:addBlessing(4)
                    player:addBlessing(5)
                    player:addBlessing(6)
                    player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
                    npcHandler.topic[cid] = 0
                else
                    npcHandler:say("Come back when you have enough money.", cid)
                    npcHandler.topic[cid] = 0
                end
            end
        end
    end
    if(msgcontains(msg, "no")) then
        if(npcHandler.topic[cid] == 1) then
            npcHandler:say("Then no.", cid)
            npcHandler.topic[cid] = 0
        end
    end
    if msgcontains(msg, "heal") then
        npcHandler:say("Do you need the healing now?", cid)
        npcHandler.topic[cid] = 2
    elseif(npcHandler.topic[cid] == 2) then
        if msgcontains(msg, "no") then
            npcHandler:say("As you wish.", cid)
            npcHandler.topic[cid] = 0
        elseif msgcontains(msg, "yes") then
            npcHandler:say("So be healed!", cid)
            doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
            doSendMagicEffect(getNpcPos(), CONST_ME_MAGIC_BLUE)
            npcHandler.topic[cid] = 0
        end
    end
    return true
end

npcHandler:setMessage(MESSAGE_GREET, "Greetings, fellow believer |PLAYERNAME|. I can offer you {blessings} or a free {heal}!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Always be on guard, |PLAYERNAME|!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "This ungraceful haste is most suspicious!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Code:
    if player:getLevel() < 30 then
        blessprize = 2000*6
    elseif player:getLevel() >= 30 and player:getLevel() <= 120 then
        blessprize = (((player:getLevel()-30)*200)+2000)*6
    elseif player:getLevel() > 120 then
        blessprize = 20000*6
    end

Remove that and replace it with the functions from global.
The names are:
Code:
function getBlessingsCost(level)
    if level <= 30 then
        return 2000
    elseif level >= 120 then
        return 20000
    else
        return ((level - 20) * 200)
    end
end

function getPvpBlessingCost(level)
    if level <= 30 then
        return 2000
    elseif level >= 270 then
        return 50000
    else
        return ((level - 20) * 200)
    end
end
 
Back
Top