• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

NPC Banker NPC For TFS

# Up

Code:
Lua Script Error: [Npc interface]
data/npc/scripts/carlin/eva.lua:onCreatureSay

luaDoPlayerDepositMoney(). Player not found

Lua Script Error: [Npc interface]
data/npc/scripts/carlin/eva.lua:onCreatureSay

Please fix for TFS 0.3.3
 
So is ths working with TFS 3.3 and is it safe or does it have the big digit bug... where it gives away money fro free?
 
got it to work for a while but after some time out of nowhere.. this error pops and it stops working..

Code:
[30/05/2009 19:08:40] data/npc/scripts/bank.lua:onCreatureSay

[30/05/2009 19:08:40] data/npc/scripts/bank.lua:72: attempt to index global 'talk_state' (a number value)
[30/05/2009 19:08:40] stack traceback:
[30/05/2009 19:08:40] 	data/npc/scripts/bank.lua:72: in function 'callback'
[30/05/2009 19:08:40] 	data/npc/lib/npcsystem/npchandler.lua:374: in function 'onCreatureSay'
[30/05/2009 19:08:40] 	data/npc/scripts/bank.lua:57: in function <data/npc/scripts/bank.lua:57>
 
This is working with TFS 3.4pl2

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local moneyTo = {}
local playerTo = {}

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

local function isValidMoney(money)
    if isNumber(money) == TRUE and money > 0 and money < 999999999 then
        return TRUE
    end
    return FALSE
end

function creatureSayCallback(cid, type, msg)

    if(not npcHandler:isFocused(cid)) then
        return false
    end

    if msgcontains(msg, 'help') or msgcontains(msg, 'offer') then
        selfSay("You can check the {balance} of your bank account, {deposit} money or {withdraw} it. You can also {transfer} money to other characters, provided that they have a vocation.", cid)
        talkState[cid] = 0
-----------------------------------------------------------------
---------------------------- Balance (stan) ---------------------
-----------------------------------------------------------------
    elseif msgcontains(msg, 'balance') or msgcontains(msg, 'Balance') then
        selfSay('Your account balance is '..getPlayerBalance(cid)..' gold.', cid)
        talkState[cid] = 0
-----------------------------------------------------------------
---------------------------- Help (pomoc) -----------------------
-----------------------------------------------------------------
    elseif msgcontains(msg, 'basic functions') then
        selfSay('You can check the {balance{ of your bank account, Pdeposit{ money or Pwithdraw{ it. You can also {transfer} money to othercharacters, provided that they have a vocation.', cid)
        talkState[cid] = 0
    elseif msgcontains(msg, 'advanced functions') then
        selfSay('Renting a house has never been this easy. Simply make a bid for an auction. We will check immediately if you haveenough money.', cid)
        talkState[cid] = 0
-----------------------------------------------------------------
---------------------------- Deposit (wpłata) -------------------
-----------------------------------------------------------------
    elseif msgcontains(msg, 'deposit all') then
        moneyTo[cid] = getPlayerMoney(cid)
        if moneyTo[cid] < 1 then
            selfSay('You don\'t have any money to deposit in you inventory..', cid)
            talkState[cid] = 0
        else
            selfSay('Would you really like to deposit '..moneyTo[cid]..' gold?', cid)
            talkState[cid] = 2
        end
    elseif msgcontains(msg, 'deposit') then
        selfSay("Please tell me how much gold it is you would like to deposit.", cid)
        talkState[cid] = 1
    elseif talkState[cid] == 1 then
        moneyTo[cid] = tonumber(msg)
        if isValidMoney(moneyTo[cid]) == TRUE then
            selfSay('Would you really like to deposit '..moneyTo[cid]..' gold?', cid)
            talkState[cid] = 2
        else
            selfSay('Is isnt valid amount of gold to deposit.', cid)
            talkState[cid] = 0
        end
    elseif talkState[cid] == 2 then
        if msgcontains(msg, 'yes') then
            if doPlayerDepositMoney(cid, moneyTo[cid]) ~= TRUE then
                selfSay('You do not have enough gold.', cid)
            else
                selfSay('Alright, we have added the amount of '..moneyTo[cid]..' gold to your balance. You can withdraw your money anytime you want to. Your account balance is ' .. getPlayerBalance(cid) .. '.', cid)
            end
        elseif msgcontains(msg, 'no') then
            selfSay('As you wish. Is there something else I can do for you?', cid)
        end
        talkState[cid] = 0
-----------------------------------------------------------------
---------------------------- Withdraw (wypłata) -----------------
-----------------------------------------------------------------
    elseif msgcontains(msg, 'withdraw') then
        selfSay("Please tell me how much gold you would like to withdraw.", cid)
        talkState[cid] = 6
    elseif talkState[cid] == 6 then
        moneyTo[cid] = tonumber(msg)
        if isValidMoney(moneyTo[cid]) == TRUE then
            selfSay('Are you sure you wish to withdraw '..moneyTo[cid]..' gold from your bank account?', cid)
            talkState[cid] = 7
        else
            selfSay('Is isnt valid amount of gold to withdraw.', cid)
            talkState[cid] = 0
        end
    elseif talkState[cid] == 7 then
        if msgcontains(msg, 'yes') then
            if doPlayerWithdrawMoney(cid, moneyTo[cid]) ~= TRUE then
                selfSay('There is not enough gold on your account. Your account balance is '..getPlayerBalance(cid)..'. Please tell me the amount of gold coins you would like to withdraw.', cid)
            else
                selfSay('Here you are, ' .. moneyTo[cid] .. ' gold. Please let me know if there is something else I can do for you.', cid)
                talkState[cid] = 0
            end
        elseif msgcontains(msg, 'no') then
            selfSay('As you wish. Is there something else I can do for you?', cid)
            talkState[cid] = 0
        end
-----------------------------------------------------------------
---------------------------- Transfer (przelew) -----------------
-----------------------------------------------------------------
    elseif msgcontains(msg, 'transfer') then
        selfSay("Please tell me the amount of gold you would like to transfer.", cid)
        talkState[cid] = 11
    elseif talkState[cid] == 11 then
        moneyTo[cid] = tonumber(msg)
        if isValidMoney(moneyTo[cid]) == TRUE then
            selfSay('Who would you like transfer '..moneyTo[cid]..' gold to?', cid)
            talkState[cid] = 12
        else
            selfSay('Is isnt valid amount of gold to transfer.', cid)
            talkState[cid] = 0
        end
    elseif talkState[cid] == 12 then
        playerTo[cid] = msg

        if getCreatureName(cid) == playerTo[cid] then
            selfSay('Ekhm, You want transfer money to yourself? Its impossible!', cid)
            talkState[cid] = 0
            return TRUE
        end

        if playerExists(playerTo[cid]) then
            selfSay('So you would like to transfer ' .. moneyTo[cid] .. ' gold to "' .. playerTo[cid] .. '" ?', cid)
            talkState[cid] = 13
        else
            selfSay('Player with name "' .. playerTo[cid] .. '" doesnt exist.', cid)
            talkState[cid] = 0
        end
    elseif talkState[cid] == 13 then
        if msgcontains(msg, 'yes') then
            if getPlayerBalance(cid) < moneyTo[cid] then
                selfSay('You dont have enought money on your bank account.', cid)
                return TRUE
            end

            if doPlayerTransferMoneyTo(cid, playerTo[cid], moneyTo[cid]) ~= TRUE then
                selfSay('This player does not exist on this world or have no vocation.', cid)
            else
                selfSay('You have transferred ' .. moneyTo[cid] .. ' gold to "' .. playerTo[cid] ..' ".', cid)
                playerTo[cid] = nil
            end
        elseif msgcontains(msg, 'no') then
            selfSay('As you wish. Is there something else I can do for you?', cid)
        end
        talkState[cid] = 0
    end
    return TRUE
end

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


Just had to change

Code:
if doPlayerDepositMoney(cid, moneyTo[cid], 1) ~= TRUE

to

Code:
if doPlayerDepositMoney(cid, moneyTo[cid]) ~= TRUE

Good Luck!
 
# up

Thats same...

Would you really like to deposit 989900 gold?
>yes
You do not have enough gold.
>>You see 98 crystal coins. (and 99 platinum)
 
Last edited:
# up

Thats same...

Would you really like to deposit 989900 gold?
>yes
You do not have enough gold.
>>You see 98 crystal coins.

I guess you would need 99 crystal coins for this :eek:
__________________
klekSu.png

You are welcome on kleksoria.com!
Please visit new open tibia forum with it's own ots list. otservers.net!
 
Last edited:
BUMP!
Script has been updated. All bugs has been fixed and it should work on any distro based on TFS. More info in first post. I have not tested it on 0.2 yet, so please tell me if works there.
 
FOR FIRST TIME in my damn life that 'Search Function' showed up something nice.

I tested , it's working so far.
Will be used!
Rep+ , thx! :D

hehe ;)

@updated once again, fixed small bug with transfer (wasn't freeing db result).
 
Usin 0.4 and getting this error:

[11:46:48.670] [Error - NpcScript Interface]
[11:46:48.670] data/npc/scripts/bank.lua:eek:nCreatureSay
[11:46:48.670] Description:
[11:46:48.670] data/npc/scripts/bank.lua:88: attempt to call global 'isNumber' (a nil value)
[11:46:48.670] stack traceback:
[11:46:48.670] data/npc/scripts/bank.lua:88: in function 'isValidMoney'
[11:46:48.670] data/npc/scripts/bank.lua:94: in function 'getCount'
[11:46:48.670] data/npc/scripts/bank.lua:176: in function 'callback'
[11:46:48.671] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[11:46:48.671] data/npc/scripts/bank.lua:15: in function <data/npc/scripts/bank.lua:15>
 
BUMP BUG!


--------


I made that and keep saying the same error, I restarted the OT and nothing...

I just tested it on latest rev and it worked :p (you probably did something wrong, i think you have still outdated lib/)
 
Back
Top