Felipe93
Ghost Member
Hello the blessings in my server are working ok if i get the five bless at once. but they wont work if i want to get them one by one(like in rl)
i've took this code from the ORTS and added it into my server which is tfs 1.5
the error is the following
this is my npc.lua
Solved! the issue was in modules i just replaced this
to this
i've took this code from the ORTS and added it into my server which is tfs 1.5
Lua:
-- 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'})
Code:
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>
this is my npc.lua
Code:
function Player.removeTotalMoney(self, amount) added to make bring me to function work
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
Post automatically merged:
Solved! the issue was in modules i just replaced this
Lua:
function StdModule.bless(cid, message, keywords, parameters, node)
local npcHandler = parameters.npcHandler
if npcHandler == nil then
error("StdModule.bless called without any npcHandler instance.")
end
if not npcHandler:isFocused(cid) or Game.getWorldType() == WORLD_TYPE_PVP_ENFORCED then
return false
end
local player = Player(cid)
if player:isPremium() or not parameters.premium then
if player:hasBlessing(parameters.bless) then
npcHandler:say("Gods have already blessed you with this blessing!", cid)
elseif not player:removeTotalMoney(parameters.cost) then
npcHandler:say("You don't have enough money for blessing.", cid)
else
player:addBlessing(parameters.bless)
npcHandler:say("You have been blessed by one of the five gods!", cid)
end
else
npcHandler:say("You need a premium account in order to be blessed.", cid)
end
npcHandler:resetNpc(cid)
return true
end
Code:
function StdModule.bless(cid, message, keywords, parameters, node)
local npcHandler = parameters.npcHandler
if npcHandler == nil then
error("StdModule.bless called without any npcHandler instance.")
end
if not npcHandler:isFocused(cid) then
return false
end
local player = Player(cid)
local parseInfo = {[TAG_BLESSCOST] = getBlessingsCost(player:getLevel()), [TAG_PVPBLESSCOST] = getPvpBlessingCost(player:getLevel())}
if player:hasBlessing(parameters.bless) then
npcHandler:say("You already possess this blessing.", cid)
elseif parameters.bless == 4 and player:getStorageValue(Storage.KawillBlessing) ~= 1 then
npcHandler:say("You need the blessing of the great geomancer first.", cid)
elseif parameters.bless == 6 and player:getBlessings() == 0 and not player:getItemById(2173, true) then
npcHandler:say("You don't have any of the other blessings nor an amulet of loss, so it wouldn't make sense to bestow this protection on you now. Remember that it can only protect you from the loss of those!", cid)
elseif not player:removeMoney(type(parameters.cost) == "string" and npcHandler:parseMessage(parameters.cost, parseInfo) or parameters.cost) then
npcHandler:say("Oh. You do not have enough money.", cid)
else
npcHandler:say(parameters.text or "You have been blessed by one of the five gods!", cid)
if parameters.bless == 4 then
player:setStorageValue(Storage.KawillBlessing, 0)
end
player:addBlessing(parameters.bless)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
end
Last edited: