• 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+ bank talkaction error

Moody

Member
Joined
Feb 8, 2020
Messages
60
Reaction score
5
i am using this bank talkaction with bank npc too but i have this error when i use !transfer player, amount
can i fix it without removing bank npc? i see 1 reply to fix it but it destroy bank npc
Code:
attempt to concatenate field 'guid' (a nil value)
 
Try change

Lua:
local targetPlayer = Player(target.guid)

To:

Lua:
local targetPlayer = Player(target)
 
Try make new fuction, maybe problem is in

Lua:
function Player.transferMoneyTo(self, target, amount)
    if not target then
        return false -- target isn't set return false --
    end

    -- See if you can afford this transfer
    local balance = self:getBankBalance()
    if amount > balance then
        return false
    end

    -- See if player is online
    local targetPlayer = Player(target.guid) -- If player isn't online this will cause an error (unless you already checked if he is online and sent userdata --
    if targetPlayer then -- Do a check that should of been done already because otherwise there is an error with above line --
        targetPlayer:setBankBalance(targetPlayer:getBankBalance() + amount)
    else -- Code will never reach this if player is not online. --
        db.query("UPDATE `players` SET `balance` = `balance` + " .. amount .. " WHERE `id` = '" .. target.guid .. "'")
    end

    self:setBankBalance(self:getBankBalance() - amount)
    return true
end

Try call diferent the fuction and call in the system, for example:

Lua:
function Player.transferMoneyToTalkaction(self, target, amount)
    if not target then
        return false -- target isn't set return false --
    end

    -- See if you can afford this transfer
    local balance = self:getBankBalance()
    if amount > balance then
        return false
    end

    -- See if player is online
    local targetPlayer = Player(target.guid) -- If player isn't online this will cause an error (unless you already checked if he is online and sent userdata --
    if targetPlayer then -- Do a check that should of been done already because otherwise there is an error with above line --
        targetPlayer:setBankBalance(targetPlayer:getBankBalance() + amount)
    else -- Code will never reach this if player is not online. --
        db.query("UPDATE `players` SET `balance` = `balance` + " .. amount .. " WHERE `id` = '" .. target.guid .. "'")
    end

    self:setBankBalance(self:getBankBalance() - amount)
    return true
end

Put the second modified function at the top of the entire script.

And change in line 82
Lua:
player:transferMoneyTo(target, amount)

To:
Lua:
player:transferMoneyToTalkaction(target, amount)

and keep first changes in target

local targetPlayer = Player(target)
 
Post npc please
Post automatically merged:

Try make new fuction, maybe problem is in

Lua:
function Player.transferMoneyTo(self, target, amount)
    if not target then
        return false -- target isn't set return false --
    end

    -- See if you can afford this transfer
    local balance = self:getBankBalance()
    if amount > balance then
        return false
    end

    -- See if player is online
    local targetPlayer = Player(target.guid) -- If player isn't online this will cause an error (unless you already checked if he is online and sent userdata --
    if targetPlayer then -- Do a check that should of been done already because otherwise there is an error with above line --
        targetPlayer:setBankBalance(targetPlayer:getBankBalance() + amount)
    else -- Code will never reach this if player is not online. --
        db.query("UPDATE `players` SET `balance` = `balance` + " .. amount .. " WHERE `id` = '" .. target.guid .. "'")
    end

    self:setBankBalance(self:getBankBalance() - amount)
    return true
end

Try call diferent the fuction and call in the system, for example:

Lua:
function Player.transferMoneyToTalkaction(self, target, amount)
    if not target then
        return false -- target isn't set return false --
    end

    -- See if you can afford this transfer
    local balance = self:getBankBalance()
    if amount > balance then
        return false
    end

    -- See if player is online
    local targetPlayer = Player(target.guid) -- If player isn't online this will cause an error (unless you already checked if he is online and sent userdata --
    if targetPlayer then -- Do a check that should of been done already because otherwise there is an error with above line --
        targetPlayer:setBankBalance(targetPlayer:getBankBalance() + amount)
    else -- Code will never reach this if player is not online. --
        db.query("UPDATE `players` SET `balance` = `balance` + " .. amount .. " WHERE `id` = '" .. target.guid .. "'")
    end

    self:setBankBalance(self:getBankBalance() - amount)
    return true
end

Put the second modified function at the top of the entire script.

And change in line 82
Lua:
player:transferMoneyTo(target, amount)

To:
Lua:
player:transferMoneyToTalkaction(target, amount)

and keep first changes in target

local targetPlayer = Player(target)
i will try, thankyou
 
Post npc please

Post automatically merged:


i will try, thankyou
It's the first thing that occurred to me, I read about the problem, Sara mentioned it, I'm on my cell phone, try that, let me know if it works or not, so I can review it calmly from my computer
 
@beenii @mano368
it works good if player online but when he is offline I get same bug and if I change this target.guid in db.qury to target it say transferred but nothing transferred to player
 
@beenii @mano368
it works good if player online but when he is offline I get same bug and if I change this target.guid in db.qury to target it say transferred but nothing transferred to player

@Moody
Have you tried removing the .guid from target.guid?

Change this part too:

SQL:
`id` = '" .. target.guid
to
SQL:
`name` = '" .. target
 
Last edited:
Have you tried removing the .guid from target.guid?

Change this part too:

id = '" .. target.guid to name = '" .. target
iwilltry
Post automatically merged:

@Moody
Have you tried removing the .guid from target.guid?

Change this part too:

SQL:
`id` = '" .. target.guid
to
SQL:
`name` = '" .. target
now worked, thanks❤️
 
Back
Top