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

TFS 1.X+ buy only 1 bless errors in console

Felipe93

Ghost Member
Joined
Mar 21, 2015
Messages
1,990
Solutions
9
Reaction score
334
Location
Chile
Hello I'm having problem buying 1 bless i use tfs 8.0 downgraded by nekiro

Lua:
dofile('data/npc/lib/npcsystem/greeting.lua')

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

-- OTServ event handling functions
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

keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I am here to provide one of the five blessings."})
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "My name is Norf."})
keywordHandler:addKeyword({'time'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Now, it is |TIME|. Ask Gorn for a watch, if you need one."})
-- Spiritual Shielding
local blessKeyword = keywordHandler:addKeyword({'exspiritual'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Here in the whiteflower temple you may receive the blessing of spiritual shielding. But we must ask of you to sacrifice |BLESSCOST| gold. Are you still interested?'})
    blessKeyword:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, onlyFocus = true, text = 'So receive the shielding of your spirit, pilgrim.', cost = '|BLESSCOST|', bless = 1})
    blessKeyword:addChildKeyword({''}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Fine. You are free to decline my offer.', reset = true})
keywordHandler:addAliasKeyword({'shield'})


function creatureSayCallback(cid, type, msg)-- msg = string.lower(msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
local player = Player(cid)
   

if msgcontains(msg, 'bless') then
    npcHandler:say("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)
    talk_state = 0

elseif msgcontains(msg, 'spiritual') or msgcontains(msg, 'bless') then
    npcHandler:say("Here in the whiteflower temple you may receive all bless. But we must ask of you to sacrifice 100.000 gold. Are you still interested?", cid)
    talk_state = 1394


elseif talk_state == 1394 and msgcontains(msg, 'yes') then
    if doPlayerRemoveMoney(cid, 100000) == true then
        if doPlayerAddBless(cid, 1) == true then
        doPlayerAddBless(cid, 2)
        doPlayerAddBless(cid, 3)
        doPlayerAddBless(cid, 4)
        doPlayerAddBless(cid, 5)
        npcHandler:say("So receive full bless.", cid)
        doSendMagicEffect(getPlayerPosition(cid), 13)
        setPlayerStorageValue(cid, 50139, 1)
        talk_state = 0       
        else
        doPlayerAddMoney(cid, 100000)
        npcHandler:say("You already possess this blessing.", cid)
        talk_state = 0           
        end
    else
    npcHandler:say("Oh. You do not have enough money.", cid)
    talk_state = 0   
    end
    
elseif talk_state == 1394 and msgcontains(msg, '') then
    npcHandler:say("Ok. Suits me.", cid)
    talk_state = 0   
    
elseif msgcontains(msg, 'phoenix') then
    npcHandler:say("The spark of the phoenix is given by the dwarven priests of earth and fire in Kazordoon.", cid)
    talk_state = 0
    
elseif msgcontains(msg, 'embrace') then
    npcHandler:say("The druids north of Carlin will provide you with the embrace of tibia.", cid)
    talk_state = 0
    
elseif msgcontains(msg, 'suns') then
    npcHandler:say("You can ask for the blessing of the two suns in the suntower near Ab'Dendriel.", cid)
    talk_state = 0
    
elseif msgcontains(msg, 'wisdom') then
    npcHandler:say("Talk to the hermit Eremo on the isle of Cormaya about this blessing.", cid)
    talk_state = 0
    
elseif msgcontains(msg, 'spiritual') then
    npcHandler:say("You can ask for the blessing of spiritual shielding the whiteflower temple south of Thais.", cid)
    talk_state = 0
    
--end   
end

local player = Player(cid)
    local totalBlessPrice = getBlessingsCost(player:getLevel()) * 5 * 1.1
 
    if npcHandler.topic[cid] == 0 then
        if msgcontains(msg, "blessing") or msgcontains(msg, "bless") then
            local inquisitionComplete = true
            if inquisitionComplete then
                npcHandler:say("Do you want to receive the {common} blessings - which means all five available blessings - for " .. totalBlessPrice .. " (1.1% extra gold)?", cid)
                npcHandler.topic[cid] = 1
            else
                npcHandler:say("Fine. You are free to decline my offer.", cid)
                npcHandler.topic[cid] = 0
            end
        end
    elseif npcHandler.topic[cid] == 1 then
        if msgcontains(msg, "yes") then
            if player:getBlessings() == 5 then -- should probably check how many blessings in order to determine totalBlessPrice
                npcHandler:say("You already have been blessed!", cid)
            elseif player:removeMoney(totalBlessPrice) then
                npcHandler:say("You have been blessed by all of five gods!", cid)
                player:addBlessing(32) ----------- bit representation
                player:setStorageValue(PlayerStorageKeys.Blessings, 1)
                player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
            else
                npcHandler:say("Come back when you have enough money.", cid)
            end
        elseif msgcontains(msg, "no") then
            npcHandler:say("Then no.", cid)
        end
        npcHandler.topic[cid] = 0
    end
end


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

this is my npc lua it has multiple functions for example this part of the script where the npcs sells the 5 blessings work good
Code:
if msgcontains(msg, 'bless') then
    npcHandler:say("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)
    talk_state = 0

elseif msgcontains(msg, 'spiritual') or msgcontains(msg, 'bless') then
    npcHandler:say("Here in the whiteflower temple you may receive all bless. But we must ask of you to sacrifice 100.000 gold. Are you still interested?", cid)
    talk_state = 1394


elseif talk_state == 1394 and msgcontains(msg, 'yes') then
    if doPlayerRemoveMoney(cid, 100000) == true then
        if doPlayerAddBless(cid, 1) == true then
        doPlayerAddBless(cid, 2)
        doPlayerAddBless(cid, 3)
        doPlayerAddBless(cid, 4)
        doPlayerAddBless(cid, 5)
        npcHandler:say("So receive full bless.", cid)
        doSendMagicEffect(getPlayerPosition(cid), 13)
        setPlayerStorageValue(cid, 50139, 1)
        talk_state = 0       
        else
        doPlayerAddMoney(cid, 100000)
        npcHandler:say("You already possess this blessing.", cid)
        talk_state = 0           
        end
    else
    npcHandler:say("Oh. You do not have enough money.", cid)
    talk_state = 0   
    end
    
elseif talk_state == 1394 and msgcontains(msg, '') then
    npcHandler:say("Ok. Suits me.", cid)
    talk_state = 0

but if i want to buy 1 one bless i get errors in console
Code:
-- Spiritual Shielding
local blessKeyword = keywordHandler:addKeyword({'exspiritual'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Here in the whiteflower temple you may receive the blessing of spiritual shielding. But we must ask of you to sacrifice |BLESSCOST| gold. Are you still interested?'})
    blessKeyword:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, onlyFocus = true, text = 'So receive the shielding of your spirit, pilgrim.', cost = '|BLESSCOST|', bless = 1})
    blessKeyword:addChildKeyword({''}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Fine. You are free to decline my offer.', reset = true})
keywordHandler:addAliasKeyword({'shield'})

these are the errors
Code:
nil
nil

Lua Script Error: [Npc interface]
data/npc/scripts/Norf.lua:onCreatureSay
data/npc/lib/npc.lua:117: attempt to compare string with number
stack traceback:
        [C]: in function '__le'
        data/npc/lib/npc.lua:117: in function 'removeTotalMoney'
        data/npc/lib/npcsystem/modules.lua:167: in function 'callback'
        data/npc/lib/npcsystem/keywordhandler.lua:26: in function 'processMessage'
        data/npc/lib/npcsystem/keywordhandler.lua:151: in function 'processNodeMessage'
        data/npc/lib/npcsystem/keywordhandler.lua:119: in function 'processMessage'
        data/npc/lib/npcsystem/npchandler.lua:382: in function 'onCreatureSay'
        data/npc/scripts/Norf.lua:10: in function <data/npc/scripts/Norf.lua:10>
npc.lua from line 113
Code:
unction Player.removeTotalMoney(self, amount)   --agregado por npcs bancos othire 1.5
    local moneyCount = self:getMoney()
    local bankCount = self:getBankBalance()

    if amount <= moneyCount then
        self:removeMoney(amount)
        return true

    elseif amount <= (moneyCount + bankCount) then
        if moneyCount ~= 0 then
            self:removeMoney(moneyCount)
            local remains = amount - moneyCount
            self:setBankBalance(bankCount - remains)
            self:sendTextMessage(MESSAGE_INFO_DESCR, ("Paid %d from inventory and %d gold from bank account. Your account balance is now %d gold."):format(moneyCount, amount - moneyCount, self:getBankBalance()))
            return true
        else
            self:setBankBalance(bankCount - amount)
            self:sendTextMessage(MESSAGE_INFO_DESCR, ("Paid %d gold from bank account. Your account balance is now %d gold."):format(amount, self:getBankBalance()))
            return true
        end
    end
    return false
end

function Player.getTotalMoney(self)
    return self:getMoney() + self:getBankBalance()
end

function isValidMoney(money)
    return isNumber(money) and money > 0
end



also i've tried a new code in order to get the 5 blessings which is this and i get this error in console
Code:
local player = Player(cid)
    local totalBlessPrice = getBlessingsCost(player:getLevel()) * 5 * 1.1
 
    if npcHandler.topic[cid] == 0 then
        if msgcontains(msg, "xblessing") or msgcontains(msg, "xbless") then
            local inquisitionComplete = true
            if inquisitionComplete then
                npcHandler:say("Do you want to receive the {common} blessings - which means all five available blessings - for " .. totalBlessPrice .. " (1.1% extra gold)?", cid)
                npcHandler.topic[cid] = 1
            else
                npcHandler:say("Fine. You are free to decline my offer.", cid)
                npcHandler.topic[cid] = 0
            end
        end
    elseif npcHandler.topic[cid] == 1 then
        if msgcontains(msg, "yes") then
            if player:getBlessings() == 5 then -- should probably check how many blessings in order to determine totalBlessPrice
                npcHandler:say("You already have been blessed!", cid)
            elseif player:removeMoney(totalBlessPrice) then
                npcHandler:say("You have been blessed by all of five gods!", cid)
                player:addBlessing(32) ----------- bit representation
                player:setStorageValue(PlayerStorageKeys.Blessings, 1)
                player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
            else
                npcHandler:say("Come back when you have enough money.", cid)
            end
        elseif msgcontains(msg, "no") then
            npcHandler:say("Then no.", cid)
        end
        npcHandler.topic[cid] = 0
    end
end
the error
Code:
nil

Lua Script Error: [Npc interface]
data/npc/scripts/Norf.lua:onCreatureSay
C++ exception
 
up
I case someone looks this in the future i fixed the 5 bless npc code part by rediting like 4 lines of code here is it:
Lua:
local player = Player(cid)
    local totalBlessPrice = getBlessingsCost(player:getLevel()) * 5 * 1.1
    --for i = 1, 5 do
      -- if player:hasBlessing(i) then
        --   player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are alredy blessed!")
       --end
   -- end
 
    if npcHandler.topic[cid] == 0 then
        if msgcontains(msg, "xblessing") or msgcontains(msg, "xbless") then
            --local inquisitionComplete = true
           -- if inquisitionComplete then
           --if player:getLevel() >= 1 then
                npcHandler:say("Do you want to receive the {common} blessings - which means all five available blessings - for " .. totalBlessPrice .. " (1.1% extra gold)?", cid)
                npcHandler.topic[cid] = 1
            else
                npcHandler:say("Fine. You are free to decline my offer.", cid)
                npcHandler.topic[cid] = 0
          -- end
        end
    elseif npcHandler.topic[cid] == 1 then
        if msgcontains(msg, "yes") then
              for i = 1, 5 do
       if player:hasBlessing(i) then
            --if player:getBlessings() == 5 then -- should probably check how many blessings in order to determine totalBlessPrice
                npcHandler:say("You already have been blessed!", cid)
            elseif player:removeMoney(totalBlessPrice) then
                player:setStorageValue(PlayerStorageKeys.Blessings, 1)
                player:addBlessing(i) ----------- bit representation
                player:setStorageValue(50139)
                player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)

            else
                npcHandler:say("Come back when you have enough money.", cid)
            end
            end
        elseif msgcontains(msg, "no") then
            npcHandler:say("Then no.", cid)
        end
        npcHandler.topic[cid] = 0
    end
end

but still need to fix this one
Code:
-- Spiritual Shielding
local blessKeyword = keywordHandler:addKeyword({'exspiritual'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Here in the whiteflower temple you may receive the blessing of spiritual shielding. But we must ask of you to sacrifice |BLESSCOST| gold. Are you still interested?'})
    blessKeyword:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, onlyFocus = true, text = 'So receive the shielding of your spirit, pilgrim.', cost = '|BLESSCOST|', bless = 1})
    blessKeyword:addChildKeyword({''}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Fine. You are free to decline my offer.', reset = true})
keywordHandler:addAliasKeyword({'shield'})

this is the error
Code:
Lua Script Error: [Npc interface]
data/npc/scripts/Norf.lua:onCreatureSay
data/npc/lib/npc.lua:117: attempt to compare string with number
stack traceback:
        [C]: in function '__le'
        data/npc/lib/npc.lua:117: in function 'removeTotalMoney'
        data/npc/lib/npcsystem/modules.lua:167: in function 'callback'
        data/npc/lib/npcsystem/keywordhandler.lua:26: in function 'processMessage'
        data/npc/lib/npcsystem/keywordhandler.lua:151: in function 'processNodeMessage'
        data/npc/lib/npcsystem/keywordhandler.lua:119: in function 'processMessage'
        data/npc/lib/npcsystem/npchandler.lua:382: in function 'onCreatureSay'
        data/npc/scripts/Norf.lua:10: in function <data/npc/scripts/Norf.lua:10>
this issue is solved
 
Last edited:
Back
Top