Shiris undrin
Well-Known Member
- Joined
- Jun 10, 2010
- Messages
- 74
- Solutions
- 1
- Reaction score
- 64
Hello community, I need help because I couldn't solve this error, when trying to transfer money from one character to another, nothing happens and these errors appear in the distro. TFS [1.2]
Sorry, the scripts are too big so I marked 3 lines of the error and put the 2 files below.
I found the solution, in data/global.lua add, case anyone has the same error.
Sorry, the scripts are too big so I marked 3 lines of the error and put the 2 files below.
Eva.lua
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local count = {}
local transfer = {}
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 -- Line 10 --
function onThink() npcHandler:onThink() end
local voices = { {text = 'Don\'t forget to deposit your money here in the Tibian Bank before you head out for adventure.'} }
if VoiceModule then
npcHandler:addModule(VoiceModule:new(voices))
end
--------------------------------guild bank-----------------------------------------------
elseif msgcontains(msg, 'transfer') then
if (Player.getExhaustion(player, 494934) > 0) then
npcHandler:say('You need to wait a time before try transfer.', cid)
npcHandler.topic[cid] = 0
return false
end
npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
npcHandler.topic[cid] = 11
elseif npcHandler.topic[cid] == 11 then
count[cid] = getMoneyCount(msg)
if player:getBankBalance() < count[cid] then
npcHandler:say('There is not enough gold on your account.', cid)
npcHandler.topic[cid] = 0
return true
end
if isValidMoney(count[cid]) then
npcHandler:say('Who would you like transfer ' .. count[cid] .. ' gold to?', cid)
npcHandler.topic[cid] = 12
else
npcHandler:say('There is not enough gold on your account.', cid)
npcHandler.topic[cid] = 0
end
elseif npcHandler.topic[cid] == 12 then
transfer[cid] = msg
if player:getName() == transfer[cid] then
npcHandler:say('Fill in this field with person who receives your gold!', cid)
npcHandler.topic[cid] = 0
return true
end
if playerExists(transfer[cid]) then
local arrayDenied = {"accountmanager", "rooksample", "druidsample", "sorcerersample", "knightsample", "paladinsample"}
if isInArray(arrayDenied, string.gsub(transfer[cid]:lower(), " ", "")) then
npcHandler:say('This player does not exist.', cid)
npcHandler.topic[cid] = 0
return true
end
npcHandler:say('So you would like to transfer ' .. count[cid] .. ' gold to ' .. transfer[cid] .. '?', cid)
npcHandler.topic[cid] = 13
else
npcHandler:say('This player does not exist.', cid)
npcHandler.topic[cid] = 0
end
elseif npcHandler.topic[cid] == 13 then
if msgcontains(msg, 'yes') then
if not player:transferMoneyTo(transfer[cid], count[cid]) then --Line 550--
npcHandler:say('You cannot transfer money to this account.', cid)
else
npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. transfer[cid] ..'.', cid)
Player.setExhaustion(player, 494934, 2)
transfer[cid] = nil
end
elseif msgcontains(msg, 'no') then
npcHandler:say('Alright, is there something else I can do for you?', cid)
end
npcHandler.topic[cid] = 0
npchandler.lua
Lua:
-- Handles onCreatureSay events. If you with to handle this yourself, please use the CALLBACK_CREATURE_SAY callback.
function NpcHandler:onCreatureSay(creature, msgtype, msg)
local cid = creature:getId()
local callback = self:getCallback(CALLBACK_CREATURE_SAY)
if callback == nil or callback(cid, msgtype, msg) then
if self:processModuleCallback(CALLBACK_CREATURE_SAY, cid, msgtype, msg) then
if not self:isInRange(cid) then
return
end
if self.keywordHandler ~= nil then
if self:isFocused(cid) or not self:isFocused(cid) then
local ret = self.keywordHandler:processMessage(cid, msg)
if(not ret) then
local callback = self:getCallback(CALLBACK_MESSAGE_DEFAULT)
if callback ~= nil and callback(cid, msgtype, msg) then --Line 384--
self.talkStart[cid] = os.time()
end
else
self.talkStart[cid] = os.time()
end
end
end
end
end
end
Post automatically merged:
I found the solution, in data/global.lua add, case anyone has the same error.
Lua:
function Player.depositMoney(self, amount)
if not self:removeMoney(amount) then
return false
end
self:setBankBalance(self:getBankBalance() + amount)
return true
end
function Player.transferMoneyTo(self, target, amount)
local balance = self:getBankBalance()
if amount > balance then
return false
end
local targetPlayer = Player(target)
if targetPlayer then
targetPlayer:setBankBalance(targetPlayer:getBankBalance() + amount)
else
if not playerExists(target) then
return false
end
db.query("UPDATE `players` SET `balance` = `balance` + '" .. amount .. "' WHERE `name` = " .. db.escapeString(target))
end
self:setBankBalance(self:getBankBalance() - amount)
return true
end
Attachments
-
erro bank.png9.1 KB · Views: 4 · VirusTotal
-
npcsystem.lua5.9 KB · Views: 0 · VirusTotal
-
Eva.lua32.5 KB · Views: 0 · VirusTotal
Last edited: