Fala ae. Bom o meu ta traduzido eu que traduzi:
Em data\npc\scripts copie um arquivo, cole e renomeia-o para banco. Abra-o apague tudo oque estiver dentro e adicione:
focus = 0talk_start = 0
target = 0
dep = 0
wit = 0
trans = 0
following = false
attacking = false
gold_id = 2148
plat_id = 2152
crys_id = 2160
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Volte Sempre.')
focus = 0
talk_start = 0
doNpcSetCreatureFocus(0)
end
end
function onCreatureTurn(creature)
end
function onCreatureSay(cid, type, msg)
msg_org = msg
msg = string.lower(msg)
nome = getCreatureName(cid)
--------------------------------------Begin----------------------------------------------
if (msgcontains(msg, 'hi') or msgcontains(msg, 'Ola')) and (focus == 0) and getDistanceToCreature(cid) < 4 then
doNpcSetCreatureFocus(cid)
dep = 0
wit = 0
trans = 0
selfSay('Ola ' .. nome .. '! O que posso fazer eu para você? Depositar, retirar, equilibrar ou transferir?')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then --NPC is talking with other player
selfSay('Desculpe '..nome..', Eu ja estou falando com um cliente. Aguarde sua vez por favor,..')
end
--------------------------------------Deposit----------------------------------------------
if dep == 0 then
if (msgcontains(msg, 'depositar')) and (focus == cid) and getDistanceToCreature(cid) < 4 then
selfSay('Por favor me fale quantos gps que voce gostaria de depositar.')
dep = 1
wit = 0
trans = 0
talk_start = os.clock()
end
end
if dep == 1 then
if (focus == cid) and getDistanceToCreature(cid) < 4 then
n = getNumber(msg)
if n ~= 0 then --player told valid number, higher than 0
talk_start = os.clock()
selfSay('Tem certeza que deseja depositar '..n..' gps?')
dep = 2
end
end
end
if dep == 2 and (focus == cid) and getDistanceToCreature(cid) < 4 then
if (msgcontains(msg, 'yes')) then --player want deposit
dep = 0
talk_start = os.clock()
if doPlayerRemoveMoney(cid, n) == TRUE then --get cash from player backpack
setBA(nome,getBA(nome)+n)
selfSay('Certo, voce depositou uma quantia de '..n..' gps na sua conta. Voce pode retirar seu dinheiro para o que voce quer a qualquer hora. Seu saldo da conta e '..getBA(nome)..'.')
else --player doesn't have enought cash in backpack
selfSay('Voce nao tem gps suficiente.')
end
end
if (msgcontains(msg, 'no')) then --player doesn't want deposit
selfSay('Certo. Há qualquer outra coisa que eu posso fazer para você?')
dep = 0
talk_start = os.clock()
end
end
-------------------------------------------Withdraw---------------------------------------
if wit == 0 then
if (msgcontains(msg, 'retirar')) and (focus == cid) and getDistanceToCreature(cid) < 4 then
selfSay('Por favor me fale quantia que voce gostaria de retirar.')
dep = 0
trans = 0
wit = 1
talk_start = os.clock()
end
end
if wit == 1 then
if (focus == cid) and getDistanceToCreature(cid) < 4 then
n = getNumber(msg)
if n ~= 0 then --player told valid number, higher than 0
talk_start = os.clock()
selfSay('Tem certeza que deseja retirar '..n..' gps de sua conta bancaria?')
wit = 2
end
end
end
if wit == 2 and (focus == cid) and getDistanceToCreature(cid) < 4 then
if (msgcontains(msg, 'yes')) then --player want withdraw
wit = 0
talk_start = os.clock()
if n <= getBA(nome) then --player has enought cash on account
setBA(nome,getBA(nome)-n) --get cash from player account
gold = n
plat = 0
crys = {}
crys[1] = 0
i = 1
--start counting how many crystal, platinum and gold coins NPC should givve
repeat
if gold >= 100 then
plat = plat + 1
gold = gold - 100
end
until gold < 100
repeat
if plat >= 100 then
if crys == 100 then
i = i + 1
crys = 0
end
crys = crys + 1
plat = plat - 100
end
until plat < 100
--now script give crytal, platinum and gold coins to player (BP/hands if free)
if crys[1] > 0 then
repeat
doPlayerAddItem(cid, crys_id, crys)
i = i-1
until i == 0
end
if plat > 0 then
doPlayerAddItem(cid, plat_id, plat)
end
if gold > 0 then
doPlayerAddItem(cid, gold_id, gold)
end
selfSay('Aqui esta, '..n..' gps. Ha qualquer outra coisa que eu posso fazer para você? Lembrando que seu saldo da conta e '..getBA(nome)..'.')
else --player doesn't have enought cash on this bank account, can't withdraw that much
selfSay('Nao ha gp suficiente em sua conta.')
end
end
if (msgcontains(msg, 'no')) then --player doesn't want to withdraw
selfSay('O cliente e o rei! Volte a qualquer hora que voce desejar retirar seu dinheiro.')
wit = 0
talk_start = os.clock()
end
end
-------------------------------------------Balance---------------------------------------
if (msgcontains(msg, 'equilibrar')) and (focus == cid) and getDistanceToCreature(cid) < 4 then --player who is talking with NPC want to know his account balance
selfSay('Seu saldo da conta e '..getBA(nome)..' gps.')
dep = 0
wit = 0
trans = 0
talk_start = os.clock()
end
-------------------------------------------Transfer---------------------------------------
if trans == 3 and (focus == cid) and getDistanceToCreature(cid) < 4 then
if (msgcontains(msg, 'yes')) then --if he want to tranfer
playerbalance = getBA(nome) --get balance value of player
if setBA(rec, getBA(rec)+quant) > 0 then -- if script set new balance get cash from transfering player account
playerbalance = playerbalance - quant
setBA(nome, playerbalance)
selfSay('Voce transferiu '..quant..' gps para '..rec_org..'. Seu saldo da conta agora e '..playerbalance..' gps.')
trans = 0
talk_start = os.clock()
else --problem with database? dont lose money..
selfSay('Problema na tranferencia. Desculpe.')
trans = 0
talk_start = os.clock()
end
elseif (msgcontains(msg, 'no')) then -- if he dont want to tranfer
selfSay('Ok. What is next?')
trans = 0
talk_start = os.clock()
end
end
if trans == 2 and (focus == cid) and getDistanceToCreature(cid) < 4 then
if getBA(msg) >= 0 then --player with this name exist
rec = msg
rec_org = msg_org
selfSay('Voce quer transferir '..quant..' gps para '..rec_org..'?')
trans = 3
talk_start = os.clock()
else --player with this name doesn't exist
selfSay('Este player nao existe. Por favor diga outro nome.')
trans = 2
talk_start = os.clock()
end
end
if trans == 1 and (focus == cid) and getDistanceToCreature(cid) < 4 then
quant = getNumber(msg)
if quant > 0 then -- its number and is higher than 0
if getBA(nome) >= quant then -- player who want to transfer has enought cash on account
selfSay('Voce quer transferir '..quant..' gps para quem?')
trans = 2
talk_start = os.clock()
else -- player who want to transfer has not enought cash on account
selfSay('Voce nao tem dinheiro sufiente em sua conta. Seu saldo da conta e '..getBA(nome)..'. Por favor me fale a quantia correta de gps que voce gostaria de transferir.')
trans = 1
talk_start = os.clock()
end
else --player told 0 or lower number or word like "asd" (its not a number)
selfSay('Por favor me diga a quantia que voce gostaria de transferir.')
talk_start = os.clock()
trans = 1
end
end
if trans == 0 then
if (msgcontains(msg, 'transferir')) and (focus == cid) and getDistanceToCreature(cid) < 4 then
selfSay('Por favor me fale a quantia que voce gostaria de transferir.')
dep = 0
wit = 0
trans = 1
talk_start = os.clock()
end
end
-------------------------------------------End--------------------------------------------
if (msgcontains(msg, 'bye')) and (focus == cid) and getDistanceToCreature(cid) < 4 then --player say "bye" - npc answer
doNpcSetCreatureFocus(0)
selfSay('Volte sempre.')
focus = 0
dep = 0
wit = 0
trans = 0
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if (os.clock() - talk_start) > 30 then --if player did not say anything from 30 seconds say "Proximo por favor" and wait for another customer
if focus > 0 then
doNpcSetCreatureFocus(0)
selfSay('Proximo por favor...')
end
focus = 0
dep = 0
wit = 0
trans = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then --if distance to player is higher than 5 say bye
doNpcSetCreatureFocus(0)
selfSay('Volte Sempre.')
focus = 0
dep = 0
wit = 0
trans = 0
end
end
end
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
function msgcontains(txt, str)
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end
function setBA(name, nvalue) --save bank account value for online and offline players
local cid = getPlayerByName(name)
set_status = -1
if isPlayer(cid) == TRUE then
--player is online
setPlayerStorageValue(cid,300,nvalue)
set_status = 1
return 1
else
--player is offline, load DB connection info and connect
dofile("./config.lua")
if sqlType == "mysql" then
env = assert(luasql.mysql())
con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
else -- sqlite
env = assert(luasql.sqlite3())
con = assert(env:connect(sqliteDatabase))
end
--check is player exist
local nametodb = escapeString(name)
result_plr = assert(con:execute("SELECT `id` FROM `players` WHERE `name` = '" .. nametodb .. "';"))
player = result_plr:fetch({}, "a")
local players = 0
local guid = 0
while player do
players = players + 1
guid = tonumber(player.id)
player = result_plr:fetch (player, "a")
end
if players > 0 then
if guid > 0 then
--player exist, check his account status
storageqry = assert(con:execute("SELECT `value` FROM `player_storage` WHERE `player_id` = '" .. guid .. "' AND `key` = 300;"))
storage = storageqry:fetch({}, "a")
local whiles = 0
while storage do
whiles = whiles + 1
storage = storageqry:fetch (storage, "a")
end
if whiles < 1 then
--if player hasn't account, create account and set account balance value 'nvalue'
assert(con:execute("INSERT INTO `player_storage` (`player_id` ,`key` ,`value`) VALUES ('" .. guid .. "', '300', '" .. nvalue .. "');"))
set_status = 1
else
assert(con:execute("UPDATE `player_storage` SET `value` = '" .. nvalue .. "' WHERE `player_id` = '" .. guid .. "' AND `key` = 300;"))
set_status = 1
end
end
else
--player with this name doesn't exist
set_status = -1
end
con:close()
env:close()
end
--if player not exist return -1
--if player exist return his bank account value
return set_status
end
function getBA(name) -- check account balance for offline and online players
local cid = getPlayerByName(name)
if isPlayer(cid) == TRUE then
--player is online
local player_cash_str = getPlayerStorageValue(cid, 300)
--create bank account if not exist
if player_cash_str < 0 then
setPlayerStorageValue(cid,300,0)
player_cash = 0
else
player_cash = player_cash_str
end
else
--player is offline, load DB connection info and connect
dofile("./config.lua")
if sqlType == "mysql" then
env = assert(luasql.mysql())
con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
else -- sqlite
env = assert(luasql.sqlite3())
con = assert(env:connect(sqliteDatabase))
end
--check is player exist
local nametodb = escapeString(name)
result_plr = assert(con:execute("SELECT `id` FROM `players` WHERE `name` = '" .. nametodb .. "';"))
player = result_plr:fetch({}, "a")
local players = 0
local guid = 0
while player do
players = players + 1
guid = tonumber(player.id)
player = result_plr:fetch (player, "a")
end
if players > 0 then
if guid > 0 then
--player exist, check his account status
storageqry = assert(con:execute("SELECT `value` FROM `player_storage` WHERE `player_id` = '" .. guid .. "' AND `key` = 300;"))
storage = storageqry:fetch({}, "a")
local whiles = 0
while storage do
whiles = whiles + 1
player_cash = tonumber(storage.value)
storage = storageqry:fetch (storage, "a")
end
if whiles < 1 then
--if player hasn't account, create account and set account balance value to 0
assert(con:execute("INSERT INTO `player_storage` (`player_id` ,`key` ,`value`) VALUES ('" .. guid .. "', '300', '0');"))
player_cash = 0
end
end
else
--player with this name doesn't exist
player_cash = -1
end
cur:close()
con:close()
env:close()
end
--if player not exist return -1
--if player exist return his bank account value
return player_cash
end
depois em data\npc copie 1 arquivo, cole renomeia-o para Bancario ou algum de sua preferencia. Abra-o, apague tudo oque estiver dentro e coloque:
<?xml version="1.0" encoding="UTF-8"?><npc name="Bancario" script="data/npc/scripts/Banco.lua" walkinterval="25" floorchange="0" access="5" level="1" maglevel="1">
<health now="150" max="150"/>
<look type="266" head="114" body="119" legs="114" feet="114" corpse="2212"/>
<parameters>
</parameters>
</npc>
Salve e fexe e entao esta prontinho ![]()
Se der algum erro torne a postar.
Legenda:
Azul= O nome do npc que você desejar.


info
Grupo: Campones
Registrado: 17/01/09
Posts: 2
Reputação: 0
Char no Tibia: Krog Fast
Gostaria de Saber Como colocar o Npc Bank, Não teria que adicionar na Database do server uma tabela com o nome Bank? e nesse bank colocar creditos, sei lá. Meu Server é 8.4 The Forgotten Server, Mysql.
Gostaria de Saber Como colocar o Sistema de Banco. Nunca Funciona.
Coloquei já no Config.lua :
--Bank System
bankSystem = "yes"
Criei um npc :
Criei Script:
function getCount(msg)
local ret = -1
local b, e = string.find(msg, "%d+")
if b ~= nil and e ~= nil then
ret = tonumber(string.sub(msg, b, e))
end
return ret
end
function msgcontains(message, keyword)
local a, b = string.find(message, keyword)
if a == nil or b == nil then
return false
end
return true
end
function addCoin(cid, itemid, count)
if count > 100 then
while(count > 100) do
cash = doCreateItemEx(itemid, 100)
doPlayerAddItemEx(cid, cash, 1)
count = count - 100
end
end
if count > 0 then
cash = doCreateItemEx(itemid, count)
doPlayerAddItemEx(cid, cash, 1)
end
end
function doPlayerExist(name)
local result = db.getResult("SELECT `name` FROM `players` WHERE `name` = " .. db.escapeString(name))
if (result:getID() ~= -1) then
local return_name = result:getDataString("name")
result:free()
return return_name
end
return 0
end
GOLD_COIN = 2148
PLATINUM_COIN = 2152
CRYSTAL_COIN = 2160
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)
talk_state[cid] = 0
npcHandler:onCreatureDisappear(cid)
end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
npcHandler:setMessage(MESSAGE_GREET, "Greetings |PLAYERNAME|. I'm banker.")
talk_state = {}
last_count = {}
last_name = {}
function creatureSayCallback(cid, type, msg)
orginal_msg = msg
msg = string.lower(msg)
if(not npcHandler:isFocused(cid)) then
talk_state[cid] = 0
return false
end
if talk_state[cid] == nil then
talk_state[cid] = 0
last_count[cid] = 0
last_name[cid] = ""
end
-- select action
if msgcontains(msg, 'change') and talk_state[cid] ~= 41 then
talk_state[cid] = 10
npcHandler:say('We exchange gold, platinum and crystal coins.', cid)
elseif msgcontains(msg, 'balance') and talk_state[cid] ~= 41 then
talk_state[cid] = 0
local balance = getPlayerBalance(cid)
if balance == 0 then
npcHandler:say('Your bank account is empty.', cid)
elseif balance <= 100000 then
npcHandler:say('Your account balance is ' .. balance .. ' gold coins.', cid)
elseif balance <= 1000000 then
npcHandler:say('Your account balance is ' .. balance .. ' gold coins.', cid)
else
npcHandler:say('Your account balance is ' .. balance .. ' gold coins.', cid)
end
elseif msgcontains(msg, 'deposit') and talk_state[cid] ~= 41 then
talk_state[cid] = 20
npcHandler:say('How much gold you would like to deposit?', cid)
elseif msgcontains(msg, 'withdraw') and talk_state[cid] ~= 41 then
talk_state[cid] = 30
npcHandler:say('How much gold you would like to withdraw?', cid)
elseif msgcontains(msg, 'transfer') and talk_state[cid] ~= 41 then
talk_state[cid] = 40
npcHandler:say('How much gold you would like to transfer?', cid)
end
-- change
if talk_state[cid] == 10 then
if msgcontains(msg, 'platinum') then
talk_state[cid] = 12
npcHandler:say('Do you want to change your platinum coins to gold or crystal?', cid)
elseif msgcontains(msg, 'gold') then
talk_state[cid] = 11
npcHandler:say('How many platinum coins do you want to get?', cid)
elseif msgcontains(msg, 'crystal') then
talk_state[cid] = 13
npcHandler:say('How many crystal coins do you want to change to platinum?', cid)
end
end
if talk_state[cid] >= 11 and talk_state[cid] <= 13 then
if talk_state[cid] == 11 and getCount(msg) > 0 then
talk_state[cid] = 14
last_count[cid] = getCount(msg)
npcHandler:say('So I should change ' .. getCount(msg) * 100 .. ' of your gold coins to ' .. getCount(msg) .. ' platinum coins for you?', cid)
elseif talk_state[cid] == 12 then
if msgcontains(msg, 'gold') then
talk_state[cid] = 15
npcHandler:say('How many platinum coins do you want to change to gold?', cid)
elseif msgcontains(msg, 'crystal') then
talk_state[cid] = 16
npcHandler:say('How many crystal coins do you want to get?', cid)
end
elseif talk_state[cid] == 13 and getCount(msg) > 0 then
talk_state[cid] = 17
last_count[cid] = getCount(msg)
npcHandler:say('So I should change ' .. getCount(msg) .. ' of your crystal coins to ' .. getCount(msg)*100 .. ' platinum coins for you?', cid)
end
end
if talk_state[cid] >= 14 and talk_state[cid] <= 17 then
if talk_state[cid] == 14 and getCount(msg) <= 0 then
if msgcontains(msg, 'yes') then
if math.floor(getPlayerItemCount(cid, GOLD_COIN) / 100) >= last_count[cid] then
doPlayerRemoveItem(cid, GOLD_COIN, last_count[cid] * 100)
addCoin(cid, PLATINUM_COIN, last_count[cid])
npcHandler:say('Here you are.', cid)
else
npcHandler:say('You don\'t have ' .. last_count[cid] * 100 .. ' gold coins.', cid)
end
else
npcHandler:say('Well, can I help you with something else?', cid)
end
talk_state[cid] = 0
elseif talk_state[cid] == 15 and getCount(msg) > 0 then
talk_state[cid] = 18
last_count[cid] = getCount(msg)
npcHandler:say('So I should change ' .. getCount(msg) .. ' of your platinum coins to ' .. getCount(msg) * 100 .. ' gold coins for you?', cid)
elseif talk_state[cid] == 16 and getCount(msg) > 0 then
talk_state[cid] = 19
last_count[cid] = getCount(msg)
npcHandler:say('So I should change ' .. getCount(msg) * 100 .. ' of your platinum coins to ' .. getCount(msg) .. ' crystal coins for you?', cid)
elseif talk_state[cid] == 17 and getCount(msg) <= 0 then
if msgcontains(msg, 'yes') then
if getPlayerItemCount(cid, CRYSTAL_COIN) >= last_count[cid] then
doPlayerRemoveItem(cid, CRYSTAL_COIN, last_count[cid])
addCoin(cid, PLATINUM_COIN, last_count[cid] * 100)
npcHandler:say('Here you are.', cid)
else
npcHandler:say('You don\'t have ' .. last_count[cid] .. ' crystal coins.', cid)
end
else
npcHandler:say('Well, can I help you with something else?', cid)
end
talk_state[cid] = 0
end
end
if talk_state[cid] >= 18 and talk_state[cid] <= 19 then
if talk_state[cid] == 18 and getCount(msg) <= 0 then
if msgcontains(msg, 'yes') then
print(2)
if getPlayerItemCount(cid, PLATINUM_COIN) >= last_count[cid] then
doPlayerRemoveItem(cid, PLATINUM_COIN, last_count[cid])
addCoin(cid, GOLD_COIN, last_count[cid] * 100)
npcHandler:say('Here you are.', cid)
else
npcHandler:say('You don\'t have ' .. last_count[cid] .. ' platinum coins.', cid)
end
else
npcHandler:say('Well, can I help you with something else?', cid)
end
talk_state[cid] = 0
elseif talk_state[cid] == 19 and getCount(msg) <= 0 then
if msgcontains(msg, 'yes') then
if math.floor(getPlayerItemCount(cid, PLATINUM_COIN) / 100) >= last_count[cid] then
doPlayerRemoveItem(cid, PLATINUM_COIN, last_count[cid] * 100)
addCoin(cid, CRYSTAL_COIN, last_count[cid])
npcHandler:say('Here you are.', cid)
else
npcHandler:say('You don\'t have ' .. last_count[cid] * 100 .. ' platinum coins.', cid)
end
else
npcHandler:say('Well, can I help you with something else?', cid)
end
talk_state[cid] = 0
end
end
--deposit
if talk_state[cid] == 20 and getCount(msg) > 0 then
talk_state[cid] = 21
last_count[cid] = getCount(msg)
npcHandler:say('Would you really like to deposit ' .. last_count[cid] .. ' gold coins?', cid)
elseif talk_state[cid] == 20 and msgcontains(msg, 'all') then
if getPlayerMoney(cid) <= 0 then
talk_state[cid] = 0
npcHandler:say('You don\'t have any money.', cid)
else
talk_state[cid] = 21
last_count[cid] = getPlayerMoney(cid)
npcHandler:say('Would you really like to deposit your all money, ' .. last_count[cid] .. ' gold coins?', cid)
end
elseif talk_state[cid] == 21 and getCount(msg) <= 0 then
if msgcontains(msg, 'yes') then
if doPlayerDepositMoney(cid, last_count[cid]) == TRUE then
npcHandler:say('You deposited ' .. last_count[cid] .. ' gold coins. Now your account balance is ' .. getPlayerBalance(cid) .. ' gold coins.', cid)
else
npcHandler:say('You don\'t have ' .. last_count[cid] .. ' gold coins.', cid)
end
else
npcHandler:say('Well, can I help you with something else?', cid)
end
talk_state[cid] = 0
end
--withdraw
if talk_state[cid] == 30 and getCount(msg) > 0 then
talk_state[cid] = 31
last_count[cid] = getCount(msg)
npcHandler:say('Would you really like to withdraw ' .. last_count[cid] .. ' gold coins?', cid)
elseif talk_state[cid] == 30 and msgcontains(msg, 'all') then
talk_state[cid] = 31
last_count[cid] = getPlayerBalance(cid)
npcHandler:say('Would you really like to withdraw your all money, ' .. last_count[cid] .. ' gold coins?', cid)
elseif talk_state[cid] == 31 and getCount(msg) <= 0 then
if msgcontains(msg, 'yes') then
if doPlayerWithdrawMoney(cid, last_count[cid]) == TRUE then
npcHandler:say('You withdrawed ' .. last_count[cid] .. ' gold coins. Now your account balance is ' .. getPlayerBalance(cid) .. ' gold coins.', cid)
else
npcHandler:say('You don\'t have ' .. last_count[cid] .. ' gold coins on your account. You account balance is ' .. getPlayerBalance(cid) .. '.', cid)
end
talk_state[cid] = 0
else
npcHandler:say('Well, can I help you with something else?', cid)
end
talk_state[cid] = 0
end
-- transfer
if talk_state[cid] == 40 and getCount(msg) > 0 then
if getPlayerBalance(cid) >= getCount(msg) then
talk_state[cid] = 41
last_count[cid] = getCount(msg)
npcHandler:say('To who would you like transfer ' .. last_count[cid] .. ' gold coins from your account? Tell me his or her name.', cid)
else
talk_state[cid] = 0
npcHandler:say('You don\'t have ' .. getCount(msg) .. ' gold coins on your account.', cid)
end
elseif talk_state[cid] == 41 then
local toPlayer = doPlayerExist(msg)
if toPlayer ~= 0 then
last_name[cid] = toPlayer
talk_state[cid] = 42
npcHandler:say('So you would like to transfer ' .. last_count[cid] .. ' gold coins to ' .. last_name[cid] .. '?', cid)
else
talk_state[cid] = 0
npcHandler:say('I don\'t know player with name ' .. orginal_msg .. '.', cid)
end
elseif talk_state[cid] == 42 then
if msgcontains(msg, 'yes') then
if doPlayerTransferMoneyTo(cid, last_name[cid], last_count[cid]) == TRUE then
npcHandler:say('You have transfered ' .. last_count[cid] .. ' gold coins to bank account of player ' .. last_name[cid] .. '. Now your account balance is ' .. getPlayerBalance(cid) .. '.', cid)
else
npcHandler:say('You don\'t have ' .. last_count[cid] .. ' gold coins on your bank account or player with name ' .. last_name[cid] .. ' doesn\'t exist. Money not transfered.', cid)
last_name[cid] = ""
end
else
npcHandler:say('Well, can I help you with something else?', cid)
end
talk_state[cid] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Nada funcionou Pode Me ajudar?