Vá em SeuOT > Data > Npc e crie um arquivo chamado Banker.xml e cole isto.
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Banker" script="data/npc/scripts/bank.lua" walkinterval="25" floorchange="0" access="5" >
<health now="150" max="150"/>
<look type="132" head="115" body="0" legs="114" feet="0" addons="3" corpse="2212"/>
<parameters>
<parameter key="message_greet" value="Ola |PLAYERNAME|. Bem Vindo Ao Meu Banco, Voce Quer {deposit}, {withdraw} ou {transfer}."/>
<parameter key="message_alreadyfocused" value="Voce Esta Bebado ? Estou Falando Com Voce."/>
<parameter key="message_farewell" value="Flw. Eu Vejo Seu Dinheiro Depois... OH Voce Ainda Esta Aqui."/>
</parameters>
</npc>
Depois vá na pasta Scripts e crie um arquivo bank e cole isto.
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, "Olá |PLAYERNAME|. Eu Sou o 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('Você Pode Escolher, Platinum e 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('Sua Conta do Banco Está Vazia.', cid)
elseif balance <= 100000 then
npcHandler:say('O Balanciamento da Sua Conta é ' .. balance .. ' gold coins.', cid)
elseif balance <= 1000000 then
npcHandler:say('O Balanciamento da Sua Conta é ' .. balance .. ' gold coins.', cid)
else
npcHandler:say('O Balanciamento da Sua Conta é ' .. balance .. ' gold coins.', cid)
end
elseif msgcontains(msg, 'deposit') and talk_state[cid] ~= 41 then
talk_state[cid] = 20
npcHandler:say('Quantos Golds Você Gostaria de Depositar?', cid)
elseif msgcontains(msg, 'withdraw') and talk_state[cid] ~= 41 then
talk_state[cid] = 30
npcHandler:say('Quantos Golds Você Gostaria de Retirar?', cid)
elseif msgcontains(msg, 'transfer') and talk_state[cid] ~= 41 then
talk_state[cid] = 40
npcHandler:say('Quantos Golds Você Gostaria de Tranferir?', cid)
end
-- change
if talk_state[cid] == 10 then
if msgcontains(msg, 'platinum') then
talk_state[cid] = 12
npcHandler:say('Você Gostaria de Mudar Sua Platinum Coin Para Gold ou Crystal Coin?', cid)
elseif msgcontains(msg, 'gold') then
talk_state[cid] = 11
npcHandler:say('Quantas Platinum Coin Você Quer Pegar?', cid)
elseif msgcontains(msg, 'crystal') then
talk_state[cid] = 13
npcHandler:say('Quantas Crystal Coin Você Quer Mudar Para 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('Quantas Platinum Coin Eu Deveria ' .. getCount(msg) * 100 .. ' Transformar Em ' .. getCount(msg) .. ' Platinum Coin Para Você?', cid)
elseif talk_state[cid] == 12 then
if msgcontains(msg, 'gold') then
talk_state[cid] = 15
npcHandler:say('Quantas Platinum Coin Você Quer Transformar em Gold?', cid)
elseif msgcontains(msg, 'crystal') then
talk_state[cid] = 16
npcHandler:say('Quantas Crystal Coin Você Quer Pegar?', cid)
end
elseif talk_state[cid] == 13 and getCount(msg) > 0 then
talk_state[cid] = 17
last_count[cid] = getCount(msg)
npcHandler:say('Então Eu Deveria ' .. getCount(msg) .. ' Transformar Suas Crystal Coin Para ' .. getCount(msg)*100 .. ' Platinum Coin Para Você?', 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('Você Poraqui.', cid)
else
npcHandler:say('Você Não Tem ' .. last_count[cid] * 100 .. ' gold coins.', cid)
end
else
npcHandler:say('Bom.., Eu Posso Ajuda-lo em Alguma Coisa?', 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('Então Eu Deveria Transformar ' .. getCount(msg) .. ' Suas Platinum Coin Em ' .. getCount(msg) * 100 .. ' Gold Para Você?', cid)
elseif talk_state[cid] == 16 and getCount(msg) > 0 then
talk_state[cid] = 19
last_count[cid] = getCount(msg)
npcHandler:say('Então Eu Deveria Transformar ' .. getCount(msg) * 100 .. ' Suas Platinum Coin Em ' .. getCount(msg) .. ' Em Crystal Coin Para Você?', 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('Você Poraqui.', cid)
else
npcHandler:say('Você Não Tem ' .. last_count[cid] .. ' crystal coins.', cid)
end
else
npcHandler:say('Bom.., Posso Ajuda-lo Em Alguma Coisa?', 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('Você Não Tem ' .. last_count[cid] .. ' platinum coins.', cid)
end
else
npcHandler:say('Bom.., Posso Ajuda-lo Em Alguma Coisa?', 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('Você Não Tem ' .. last_count[cid] * 100 .. ' platinum coins.', cid)
end
else
npcHandler:say('Bom.., Posso Ajuda-lo Em Alguma Coisa?', 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('Tem Certeza Que Quer Depositar ' .. 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('Você Não Tem Nenhum Dinheiro.', cid)
else
talk_state[cid] = 21
last_count[cid] = getPlayerMoney(cid)
npcHandler:say('Tem Certeza Que Quer Depositar, ' .. 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('Você Depositou ' .. last_count[cid] .. ' gold coins. Agora Seu Balanciamento é ' .. getPlayerBalance(cid) .. ' gold coins.', cid)
else
npcHandler:say('Você Não Tem ' .. last_count[cid] .. ' gold coins.', cid)
end
else
npcHandler:say('Bom.., Posso Ajuda-lo Em Alguma Coisa?', 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('Você Retirou ' .. last_count[cid] .. ' gold coins. Agora Seu Balanciamento é ' .. getPlayerBalance(cid) .. ' gold coins.', cid)
else
npcHandler:say('Você Não Tem ' .. last_count[cid] .. ' Gold Na Sua Conta. Agora Seu Balanciamento é ' .. getPlayerBalance(cid) .. '.', cid)
end
talk_state[cid] = 0
else
npcHandler:say('Bom.., Posso Ajuda-lo Em Alguma Coisa?', 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('Quer Mesmo Transferir ' .. last_count[cid] .. ' Gold Da Sua Conta? Me Diga o Nome Dele.', cid)
else
talk_state[cid] = 0
npcHandler:say('Você Não Tem ' .. getCount(msg) .. ' Gold Coins Na Sua Conta.', 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('Quanto Você Gostaria de Transferir ' .. last_count[cid] .. ' Gold Coins Para ' .. last_name[cid] .. '?', cid)
else
talk_state[cid] = 0
npcHandler:say('Não Conheço Nenhum Player Com Esse Nome ' .. 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('Você Transferiu ' .. last_count[cid] .. ' Golds Coin Para o Banco Daquele Player ' .. last_name[cid] .. '. Agora o Balanceamento da Sua Conta é ' .. getPlayerBalance(cid) .. '.', cid)
else
npcHandler:say('Você Não Tem ' .. last_count[cid] .. ' Gold Coins Na Conta do Seu Banco Ou Player Com Esse Nome ' .. last_name[cid] .. ' Não Existe. Dinheiro Não Transferido.', cid)
last_name[cid] = ""
end
else
npcHandler:say('Bom.., Posso Ajuda-lo Em Alguma Coisa?', cid)
end
talk_state[cid] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Veja se funciona :smile_positivo:





info
Grupo: Campones
Registrado: 14/06/10
Posts: 11
Reputação: +5
oi eu gostaria tirar minha duvida.
como sou novo aqui não sei se é o lugar certo qualquer coisa me avise
eu baixei a versao the easy beta 8.7x
editei o mapa, arrumei alguns bugs...
mais não consigo depositar dinheiro no bank, procurei varios forun relacionado a script de npc, mais nao conseguir achar nenhum que ajuda se, criei até outro npc de bank e deu
na mesma. na hora de falar yes. o npc fica mudo
.
Bom se alguem poder me ajudar com isso, eu serei muito grato.
é assim que está no bank.lua
Editado Fevereiro 7 por lipeehhhh