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

bank help!

Ussef

New Member
Joined
May 27, 2009
Messages
123
Reaction score
2
okay so i have a bank script but i cant get it to work!!!! this is it >>

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

function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end

function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

--------------------MESSAGES------------------------------------------------------------------------------
if msgcontains(msg, 'deposit') then
selfSay('Please tell me how much gold it is you would like to deposit.', cid)
talkState[talkUser] = 1

elseif msgcontains(msg, 'withdraw') then
selfSay('Please tell me how much gold you would like to withdraw.', cid)
talkState[talkUser] = 3

elseif msgcontains(msg, 'transfer') then
selfSay('Please tell me the amount of gold coins you would like to transfer.', cid)
talkState[talkUser] = 5

elseif msgcontains(msg, 'balance') then
n = getPlayerBalance(cid)
selfSay('Your balance are '..n..' golds.', cid)
talkState[talkUser] = 0


----------------------DEPOSIT-------------------------------------------------------
elseif talkState[talkUser] == 1 then
if msgcontains(msg, 'all') then
n = getPlayerMoney(cid)
selfSay('Do you want deposit '..n..' golds?', cid)
talkState[talkUser] = 2
else
n = getNumber(msg)
selfSay('Do you want deposit '..n..' golds?', cid)
talkState[talkUser] = 2
end

elseif talkState[talkUser] == 2 then
if msgcontains(msg, 'yes') then
if getPlayerMoney(cid) >= n then
doPlayerDepositMoney(cid,n)
selfSay('a', cid)
talkState[talkUser] = 0
else
selfSay('You don\'t have money.', cid)
end
else
selfSay('Ok then', cid)
end

----------------------WITHDRAW---------------------------------------------------------------------

elseif talkState[talkUser] == 3 then
if msgcontains(msg, 'all') then
n = getPlayerBalance(cid)
selfSay('Do you want withdraw '..n..' golds ?', cid)
talkState[talkUser] = 4
else
n = getNumber(msg)
selfSay('Do you want withdraw '..n..' golds ?', cid)
talkState[talkUser] = 4
end

elseif talkState[talkUser] == 4 then
if msgcontains(msg, 'yes') then
if getPlayerBalance(cid) >= n then
doPlayerWithdrawMoney(cid, n)
selfSay('Here you are, '..n..' gold. Now your balance account is ' ..getPlayerBalance(cid)..' golds.', cid)
talkState[talkUser] = 0
else
selfSay('There is not enough gold on your account', cid)
end
else
selfSay('Ok then', cid)
end

----------------------TRANSFER----------------------------------------------------------------------------------------

elseif talkState[talkUser] == 5 then
if msgcontains(msg, 'all') then
n = getPlayerBalance(cid)
selfSay('Who would you like transfer '..n..' gold to?', cid)
talkState[talkUser] = 6
else
n = getNumber(msg)
selfSay('Who would you like transfer '..n..' gold to?', cid)
talkState[talkUser] = 6
end

elseif talkState[talkUser] == 6 then
p = msg
selfSay('So you would like to transfer '..n..' gold to '..p..'?', cid)
talkState[talkUser] = 7

elseif talkState[talkUser] == 7 then
if msgcontains(msg, 'yes') then
if getPlayerBalance(cid) >= n then
if doPlayerTransferMoneyTo(cid, p, n) == TRUE then
selfSay('You have transferred '..n..' gold to '..p..' and your account balance is '..getPlayerBalance(cid)..' golds.', cid)
talkState[talkUser] = 0
else
selfSay('This player does not exist. Please tell me a valid name!', cid)
end
else
selfSay('There is not enough gold on your account', cid)
end
else
selfSay('Ok then', cid)
end


end
end

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



-- function maded by Gesior--
function getNumber(txt) --return number if its number and is > 0, else return 0
x = string.gsub(txt,"%a","")
x = tonumber(x)
if x ~= nill and x > 0 then
return x
else
return 0
end
end






so the balance works but when i try depositing it doesnt work and it gives me this error.

[04/02/2013 03:12:25] Lua Script Error: [Npc interface]
[04/02/2013 03:12:25] data/npc/scripts/bank.lua:eek:nCreatureSay
[04/02/2013 03:12:25] data/npc/scripts/bank.lua:52: attempt to call global 'doPlayerDepositMoney' (a nil value)
[04/02/2013 03:12:25] stack traceback:
[04/02/2013 03:12:25] [C]: in function 'doPlayerDepositMoney'
[04/02/2013 03:12:25] data/npc/scripts/bank.lua:52: in function 'callback'
[04/02/2013 03:12:25] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[04/02/2013 03:12:25] data/npc/scripts/bank.lua:8: in function <data/npc/scripts/bank.lua:8>



help me please!
 
Hey, im just want to say when you post that lua codes make tags like
Lua:
 !

I help ya,

[code=lua]local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid) npcHandlernCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandlernCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandlernCreatureSay(cid, type, msg) end
function onThink() npcHandlernThink() end

function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

--------------------MESSAGES------------------------------------------------------------------------------
if msgcontains(msg, 'deposit') then
selfSay('Please tell me how much gold it is you would like to deposit.', cid)
talkState[talkUser] = 1

elseif msgcontains(msg, 'withdraw') then
selfSay('Please tell me how much gold you would like to withdraw.', cid)
talkState[talkUser] = 3

elseif msgcontains(msg, 'transfer') then
selfSay('Please tell me the amount of gold coins you would like to transfer.', cid)
talkState[talkUser] = 5

elseif msgcontains(msg, 'balance') then
n = getPlayerBalance(cid)
selfSay('Your balance are '..n..' golds.', cid)
talkState[talkUser] = 0


----------------------DEPOSIT-------------------------------------------------------
elseif talkState[talkUser] == 1 then
if msgcontains(msg, 'all') then
n = getPlayerMoney(cid)
selfSay('Do you want deposit '..n..' golds?', cid)
talkState[talkUser] = 2 
else
n = getNumber(msg)
selfSay('Do you want deposit '..n..' golds?', cid)
talkState[talkUser] = 2
end

elseif talkState[talkUser] == 2 then
if msgcontains(msg, 'yes') then
if getPlayerMoney(cid) >= n then
doPlayerDepositMoney(cid,n) 
selfSay('a', cid)
talkState[talkUser] = 0
else
selfSay('You don\'t have money.', cid)
end
else
selfSay('Ok then', cid)
end

----------------------WITHDRAW---------------------------------------------------------------------

elseif talkState[talkUser] == 3 then
if msgcontains(msg, 'all') then
n = getPlayerBalance(cid)
selfSay('Do you want withdraw '..n..' golds ?', cid)
talkState[talkUser] = 4 
else
n = getNumber(msg)
selfSay('Do you want withdraw '..n..' golds ?', cid)
talkState[talkUser] = 4
end

elseif talkState[talkUser] == 4 then
if msgcontains(msg, 'yes') then
if getPlayerBalance(cid) >= n then
doPlayerWithdrawMoney(cid, n) 
selfSay('Here you are, '..n..' gold. Now your balance account is ' ..getPlayerBalance(cid)..' golds.', cid)
talkState[talkUser] = 0
else
selfSay('There is not enough gold on your account', cid)
end
else
selfSay('Ok then', cid)
end

----------------------TRANSFER---------------------------------------------------------------------------------------- 

elseif talkState[talkUser] == 5 then
if msgcontains(msg, 'all') then
n = getPlayerBalance(cid)
selfSay('Who would you like transfer '..n..' gold to?', cid)
talkState[talkUser] = 6 
else
n = getNumber(msg)
selfSay('Who would you like transfer '..n..' gold to?', cid)
talkState[talkUser] = 6
end

elseif talkState[talkUser] == 6 then
p = msg
selfSay('So you would like to transfer '..n..' gold to '..p..'?', cid)
talkState[talkUser] = 7

elseif talkState[talkUser] == 7 then
if msgcontains(msg, 'yes') then
if getPlayerBalance(cid) >= n then
if doPlayerTransferMoneyTo(cid, p, n) == TRUE then
selfSay('You have transferred '..n..' gold to '..p..' and your account balance is '..getPlayerBalance(cid)..' golds.', cid)
talkState[talkUser] = 0
else
selfSay('This player does not exist. Please tell me a valid name!', cid)
end
else
selfSay('There is not enough gold on your account', cid)
end
else
selfSay('Ok then', cid)
end


end
end

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



-- function maded by Gesior--
function getNumber(txt) --return number if its number and is > 0, else return 0
x = string.gsub(txt,"%a","")
x = tonumber(x)
if x ~= nill and x > 0 then
return x
else
return 0
end
end
 
it gives me this error!!!

[04/02/2013 13:28:47] Lua Script Error: [Npc interface]
[04/02/2013 13:28:47] data/npc/scripts/bank.lua:eek:nThink
[04/02/2013 13:28:47] data/npc/scripts/bank.lua:9: attempt to call global 'npcHandlernThink' (a nil value)
[04/02/2013 13:28:47] stack traceback:
[04/02/2013 13:28:47] [C]: in function 'npcHandlernThink'
[04/02/2013 13:28:47] data/npc/scripts/bank.lua:9: in function <data/npc/scripts/bank.lua:9>
 
it gives me this error!!!

[04/02/2013 13:28:47] Lua Script Error: [Npc interface]
[04/02/2013 13:28:47] data/npc/scripts/bank.lua:eek:nThink
[04/02/2013 13:28:47] data/npc/scripts/bank.lua:9: attempt to call global 'npcHandlernThink' (a nil value)
[04/02/2013 13:28:47] stack traceback:
[04/02/2013 13:28:47] [C]: in function 'npcHandlernThink'
[04/02/2013 13:28:47] data/npc/scripts/bank.lua:9: in function <data/npc/scripts/bank.lua:9>

that script was broken:
Lua:
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
 
function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
 
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
 
--------------------MESSAGES------------------------------------------------------------------------------
    if msgcontains(msg, 'deposit') then
        selfSay('Please tell me how much gold it is you would like to deposit.', cid)
        talkState[talkUser] = 1
 
    elseif msgcontains(msg, 'withdraw') then
        selfSay('Please tell me how much gold you would like to withdraw.', cid)
        talkState[talkUser] = 3
 
    elseif msgcontains(msg, 'transfer') then
        selfSay('Please tell me the amount of gold coins you would like to transfer.', cid)
        talkState[talkUser] = 5
 
    elseif msgcontains(msg, 'balance') then
        n = getPlayerBalance(cid)
        selfSay('Your balance are '..n..' golds.', cid)
        talkState[talkUser] = 0
 
 
----------------------DEPOSIT-------------------------------------------------------
    elseif talkState[talkUser] == 1 then
        if msgcontains(msg, 'all') then
            n = getPlayerMoney(cid)
            selfSay('Do you want deposit '..n..' golds?', cid)
            talkState[talkUser] = 2 
        else
            n = getNumber(msg)
            selfSay('Do you want deposit '..n..' golds?', cid)
            talkState[talkUser] = 2
        end
 
    elseif talkState[talkUser] == 2 then
        if msgcontains(msg, 'yes') then
            if getPlayerMoney(cid) >= n then
                doPlayerDepositMoney(cid,n) 
                selfSay('a', cid)
                talkState[talkUser] = 0
            else
                selfSay('You don\'t have money.', cid)
            end
        else
            selfSay('Ok then', cid)
        end
 
----------------------WITHDRAW---------------------------------------------------------------------
 
    elseif talkState[talkUser] == 3 then
        if msgcontains(msg, 'all') then
            n = getPlayerBalance(cid)
            selfSay('Do you want withdraw '..n..' golds ?', cid)
            talkState[talkUser] = 4 
        else
            n = getNumber(msg)
            selfSay('Do you want withdraw '..n..' golds ?', cid)
            talkState[talkUser] = 4
        end
 
    elseif talkState[talkUser] == 4 then
        if msgcontains(msg, 'yes') then
            if getPlayerBalance(cid) >= n then
                doPlayerWithdrawMoney(cid, n) 
                selfSay('Here you are, '..n..' gold. Now your balance account is ' ..getPlayerBalance(cid)..' golds.', cid)
                talkState[talkUser] = 0
            else
                selfSay('There is not enough gold on your account', cid)
            end
        else
            selfSay('Ok then', cid)
        end
 
----------------------TRANSFER---------------------------------------------------------------------------------------- 
 
    elseif talkState[talkUser] == 5 then
        if msgcontains(msg, 'all') then
            n = getPlayerBalance(cid)
            selfSay('Who would you like transfer '..n..' gold to?', cid)
            talkState[talkUser] = 6 
        else
            n = getNumber(msg)
            selfSay('Who would you like transfer '..n..' gold to?', cid)
            talkState[talkUser] = 6
        end
 
    elseif talkState[talkUser] == 6 then
        p = msg
        selfSay('So you would like to transfer '..n..' gold to '..p..'?', cid)
        talkState[talkUser] = 7
 
    elseif talkState[talkUser] == 7 then
        if msgcontains(msg, 'yes') then
            if getPlayerBalance(cid) >= n then
                if doPlayerTransferMoneyTo(cid, p, n) == TRUE then
                    selfSay('You have transferred '..n..' gold to '..p..' and your account balance is '..getPlayerBalance(cid)..' golds.', cid)
                    talkState[talkUser] = 0
                else
                    selfSay('This player does not exist. Please tell me a valid name!', cid)
                end
            else
                selfSay('There is not enough gold on your account', cid)
            end
        else
            selfSay('Ok then', cid)
        end
 
 
    end
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
 
 
-- function maded by Gesior--
function getNumber(txt) --return number if its number and is > 0, else return 0
    x = string.gsub(txt,"%a","")
    x = tonumber(x)
    if x ~= nill and x > 0 then
        return x
    else
        return 0
    end
end
 
now it gives this error

[04/02/2013 16:19:06] Lua Script Error: [Npc interface]
[04/02/2013 16:19:06] data/npc/scripts/bank.lua
[04/02/2013 16:19:06] data/npc/scripts/bank.lua:121: attempt to index global 'npcHandler' (a nil value)
[04/02/2013 16:19:06] stack traceback:
[04/02/2013 16:19:06] [C]: in function '__index'
[04/02/2013 16:19:06] data/npc/scripts/bank.lua:121: in main chunk
[04/02/2013 16:19:06] [Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/bank.lua



ty anyways mate! u know how to fix this?
 
now it gives this error

[04/02/2013 16:19:06] Lua Script Error: [Npc interface]
[04/02/2013 16:19:06] data/npc/scripts/bank.lua
[04/02/2013 16:19:06] data/npc/scripts/bank.lua:121: attempt to index global 'npcHandler' (a nil value)
[04/02/2013 16:19:06] stack traceback:
[04/02/2013 16:19:06] [C]: in function '__index'
[04/02/2013 16:19:06] data/npc/scripts/bank.lua:121: in main chunk
[04/02/2013 16:19:06] [Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/bank.lua



ty anyways mate! u know how to fix this?

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

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
 
function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
 
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
 
--------------------MESSAGES------------------------------------------------------------------------------
    if msgcontains(msg, 'deposit') then
        selfSay('Please tell me how much gold it is you would like to deposit.', cid)
        talkState[talkUser] = 1
 
    elseif msgcontains(msg, 'withdraw') then
        selfSay('Please tell me how much gold you would like to withdraw.', cid)
        talkState[talkUser] = 3
 
    elseif msgcontains(msg, 'transfer') then
        selfSay('Please tell me the amount of gold coins you would like to transfer.', cid)
        talkState[talkUser] = 5
 
    elseif msgcontains(msg, 'balance') then
        n = getPlayerBalance(cid)
        selfSay('Your balance are '..n..' golds.', cid)
        talkState[talkUser] = 0
 
 
----------------------DEPOSIT-------------------------------------------------------
    elseif talkState[talkUser] == 1 then
        if msgcontains(msg, 'all') then
            n = getPlayerMoney(cid)
            selfSay('Do you want deposit '..n..' golds?', cid)
            talkState[talkUser] = 2 
        else
            n = getNumber(msg)
            selfSay('Do you want deposit '..n..' golds?', cid)
            talkState[talkUser] = 2
        end
 
    elseif talkState[talkUser] == 2 then
        if msgcontains(msg, 'yes') then
            if getPlayerMoney(cid) >= n then
                doPlayerDepositMoney(cid,n) 
                selfSay('a', cid)
                talkState[talkUser] = 0
            else
                selfSay('You don\'t have money.', cid)
            end
        else
            selfSay('Ok then', cid)
        end
 
----------------------WITHDRAW---------------------------------------------------------------------
 
    elseif talkState[talkUser] == 3 then
        if msgcontains(msg, 'all') then
            n = getPlayerBalance(cid)
            selfSay('Do you want withdraw '..n..' golds ?', cid)
            talkState[talkUser] = 4 
        else
            n = getNumber(msg)
            selfSay('Do you want withdraw '..n..' golds ?', cid)
            talkState[talkUser] = 4
        end
 
    elseif talkState[talkUser] == 4 then
        if msgcontains(msg, 'yes') then
            if getPlayerBalance(cid) >= n then
                doPlayerWithdrawMoney(cid, n) 
                selfSay('Here you are, '..n..' gold. Now your balance account is ' ..getPlayerBalance(cid)..' golds.', cid)
                talkState[talkUser] = 0
            else
                selfSay('There is not enough gold on your account', cid)
            end
        else
            selfSay('Ok then', cid)
        end
 
----------------------TRANSFER---------------------------------------------------------------------------------------- 
 
    elseif talkState[talkUser] == 5 then
        if msgcontains(msg, 'all') then
            n = getPlayerBalance(cid)
            selfSay('Who would you like transfer '..n..' gold to?', cid)
            talkState[talkUser] = 6 
        else
            n = getNumber(msg)
            selfSay('Who would you like transfer '..n..' gold to?', cid)
            talkState[talkUser] = 6
        end
 
    elseif talkState[talkUser] == 6 then
        p = msg
        selfSay('So you would like to transfer '..n..' gold to '..p..'?', cid)
        talkState[talkUser] = 7
 
    elseif talkState[talkUser] == 7 then
        if msgcontains(msg, 'yes') then
            if getPlayerBalance(cid) >= n then
                if doPlayerTransferMoneyTo(cid, p, n) == TRUE then
                    selfSay('You have transferred '..n..' gold to '..p..' and your account balance is '..getPlayerBalance(cid)..' golds.', cid)
                    talkState[talkUser] = 0
                else
                    selfSay('This player does not exist. Please tell me a valid name!', cid)
                end
            else
                selfSay('There is not enough gold on your account', cid)
            end
        else
            selfSay('Ok then', cid)
        end
 
 
    end
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
 
 
-- function maded by Gesior--
function getNumber(txt) --return number if its number and is > 0, else return 0
    x = string.gsub(txt,"%a","")
    x = tonumber(x)
    if x ~= nill and x > 0 then
        return x
    else
        return 0
    end
end

there was something missing :p
 
now when i try to deposit it gives this error.

[04/02/2013 20:38:17] Lua Script Error: [Npc interface]
[04/02/2013 20:38:17] data/npc/scripts/bank.lua:eek:nCreatureSay
[04/02/2013 20:38:17] data/npc/scripts/bank.lua:52: attempt to call global 'doPlayerDepositMoney' (a nil value)
[04/02/2013 20:38:17] stack traceback:
[04/02/2013 20:38:17] [C]: in function 'doPlayerDepositMoney'
[04/02/2013 20:38:17] data/npc/scripts/bank.lua:52: in function 'callback'
[04/02/2013 20:38:17] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[04/02/2013 20:38:17] data/npc/scripts/bank.lua:8: in function <data/npc/scripts/bank.lua:8>


help :)
 
now when i try to deposit it gives this error.

[04/02/2013 20:38:17] Lua Script Error: [Npc interface]
[04/02/2013 20:38:17] data/npc/scripts/bank.lua:eek:nCreatureSay
[04/02/2013 20:38:17] data/npc/scripts/bank.lua:52: attempt to call global 'doPlayerDepositMoney' (a nil value)
[04/02/2013 20:38:17] stack traceback:
[04/02/2013 20:38:17] [C]: in function 'doPlayerDepositMoney'
[04/02/2013 20:38:17] data/npc/scripts/bank.lua:52: in function 'callback'
[04/02/2013 20:38:17] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[04/02/2013 20:38:17] data/npc/scripts/bank.lua:8: in function <data/npc/scripts/bank.lua:8>


help :)
apparently you do not have the function "doPlayerDepositMoney".

What TFS version are you using?
 
nvm i fixed it! its suppose to be doplayergetmoney or something like that. anyways dude i have 0.2.13 how do i get 0.3?
 
Back
Top