¿Quieres reaccionar a este mensaje? Regístrate en el foro con unos pocos clics o inicia sesión para continuar.



 
ÍndicePortalBuscarÚltimas imágenesRegistrarseConectarse

 

 Npc Banker

Ir abajo 
2 participantes
AutorMensaje
PoloX
Mirageman
PoloX


Masculino
Cantidad de envíos : 492
Edad : 29
Localización : donde la melodia me quiera llevaar (8)
Fecha de inscripción : 16/12/2007

Npc Banker Empty
MensajeTema: Npc Banker   Npc Banker Icon_minitimeDom Mar 09, 2008 8:10 am

Bueno aqui les dejo el NPC BANKER... Lo saque de OTfans.

1-Crear un lua en npc/scripts , borrarle todo y ponerle esto encima.
Código:
--by brandnew
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)

local transaction_count = 0
local transaction_type = 0 --1-withdraw 2-store 3 -transfer
local transfer_name = ""
local transfer_cid = 0

NpcSystem.parseParameters(npcHandler)

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 clearCrap()
talkState = 0
transaction_count = 0
transfer_name = ""
transfer_cid = 0
end
function createBankAccount(_cid)
if getPlayerStorageValue(_cid,STORAGE_BANK) < 0 then
setPlayerStorageValue(_cid,STORAGE_BANK,0)
end
end
function upgradeCoin(cid , item_origin , item_dest, count)
if getPlayerItemCount(cid,item_origin) < count*100 then
return FALSE
else
doPlayerRemoveItem(cid,item_origin,count*100)
doPlayerAddItem(cid,item_dest,count)
end
return TRUE
end

function creatureSayCallback(cid, type, msg)
if(npcHandler.focus ~= cid) then
return FALSE
end

if msgcontains(msg, 'balance') then
local balance = getPlayerStorageValue(cid, STORAGE_BANK )
if  balance >= 0 then
selfSay("Your account balance is " .. tostring(balance) .. " gold.")
else
selfSay("You haven't stored anything in your account yet.")
end


elseif msgcontains(msg, 'withdraw') then
selfSay("How much do you want to withdraw?")
talkState = 1
transaction_count = 0

elseif msgcontains(msg, 'store') or msgcontains(msg,'deposit') then
selfSay("How much do you want to store? <oink!>")
talkState = 2
transaction_count = 0


elseif msgcontains(msg, 'transfer') then
selfSay("To whom do you like to transfer money?")
talkState = 3
transfer_name = ""
transfer_cid = 0
transaction_count = 0

elseif msgcontains(msg, 'change gold') then
selfSay("How many platinum coins do you want?")
talkState = 5

elseif msgcontains(msg, 'change platinum') then
selfSay("How many crystal coins do you want?")
talkState = 6

elseif msgcontains(msg, 'change all') then
local _count = getPlayerMoney(cid)
if _count < 0 then
selfSay("You dont have any money!")
else
selfSay("Do you want to change all your money to better coins?")
talkState = 10
transaction_type = 6
transaction_count = _count
end

elseif msgcontains(msg, 'change') then
selfSay('I can change gold coins to platinum coins or platinum coins to crystal coins. Or I could change *all* your money.')


elseif msgcontains(msg, 'help') then
selfSay("I am the Banker. I can do transactions in your bank account and change coins.")

elseif msgcontains(msg, 'account') or msgcontains(msg, 'bank') then
selfSay("You can withdraw or deposit money in your bank account. If you want to check your *balance* just tell me.")

--confirm to withdraw money
elseif talkState == 1 then
local num = tonumber(msg)
if (num ~= nil and num > 0) or msgcontains(msg,"all") then
if msgcontains(msg,"all") then
num = getPlayerStorageValue(cid,STORAGE_BANK)
end

transaction_count = num
selfSay("Do you want to withdraw " .. tostring(num) .. " gold coins?")
talkState = 10
transaction_type = 1

else
selfSay("How much?")
end

--confirm to deposit money
elseif talkState == 2 then
local num = tonumber(msg)
if (num ~= nil and num > 0) or msgcontains(msg,"all") then
if msgcontains(msg,"all") then
num = getPlayerMoney(cid)
end
transaction_count = num
selfSay("Do you want to deposit " .. tostring(num) .. " gold coins?")
talkState = 10
transaction_type = 2

else
selfSay("How much?")
end

--ask how much to transfer
elseif talkState == 3 then
local _transid = getPlayerByName(msg)
if _transid ~= nil and _transid > 0 then
transfer_name = msg
transfer_cid = _transid
selfSay("How much do you want to transfer?")
talkState = 4
else
selfSay("That player is not online or does not exist.")
talkState = 0
end

--confirm transfer
elseif talkState == 4 then
local num = tonumber(msg)
if(num ~= nil and num>0) or msgcontains(msg,"all") then

if msgcontains(msg,"all") then
num = getPlayerStorageValue(cid,STORAGE_BANK)
end

transaction_count = num
selfSay("Do you want to transfer " .. tostring(num) .. " gold coins to " .. transfer_name .. "?")
talkState = 10
transaction_type = 3
else
selfSay("How much?")
end

--confirm change gold coin
elseif talkState == 5 then
local num = tonumber(msg)
if(num ~= 0 and num > 0) then
transaction_count = num
selfSay("Do you want to change " .. tostring(num*100) .. " gold coins to " .. tostring(num) .. " platinum coins?")
talkState = 10
transaction_type = 4
else
selfSay("How many?")
end

--confirm change platinum coin
elseif talkState == 6 then
local num = tonumber(msg)
if(num ~= 0 and num > 0) then
transaction_count = num
selfSay("Do you want to change " .. tostring(num*100) .. " platinum coins to " .. tostring(num) .. " crystal coins?")
talkState = 10
transaction_type = 5
else
selfSay("How many?")
end

elseif talkState == 10 then
if msgcontains(msg,'yes') then
createBankAccount(cid)
local balance = getPlayerStorageValue(cid, STORAGE_BANK )

--withdraw
if transaction_type == 1 then
if balance >= transaction_count then
setPlayerStorageValue(cid,STORAGE_BANK,balance-transaction_count)
doPlayerAddMoney(cid,transaction_count)
selfSay('Done.')
else
selfSay('Sorry, your bank account does not have that much money.')
end

--store
elseif transaction_type == 2 then
if(doPlayerRemoveMoney(cid, transaction_count) == TRUE) then
setPlayerStorageValue(cid,STORAGE_BANK,balance+transaction_count)
selfSay('Done!')
else
selfSay("You do not have that much money!")
end
--transfer
elseif transaction_type == 3 then
if balance >= transaction_count then
setPlayerStorageValue(cid,STORAGE_BANK,balance-transaction_count)
createBankAccount(transfer_cid)
setPlayerStorageValue(transfer_cid,STORAGE_BANK,getPlayerStorageValue(transfer_cid,STORAGE_BANK)+transaction_count)
doPlayerSendTextMessage(transfer_cid, MESSAGE_INFO_DESCR, getPlayerName(cid) .. ' has transfered ' .. tostring(transaction_count) .. ' gold coins to your bank account.')
selfSay('Done.')
else
selfSay("Your bank account does not have that much money.")
end

elseif transaction_type == 6 then
doPlayerRemoveMoney(cid,transaction_count)
doPlayerAddMoney(cid,transaction_count)
selfSay('There you go!')

elseif transaction_type > 3 then
local _ifrom = ITEM_GOLD_COIN
local _ito = ITEM_PLATINUM_COIN
if transaction_type == 5 then
_ifrom = ITEM_PLATINUM_COIN
_ito = ITEM_CRYSTAL_COIN
end
if upgradeCoin(cid,_ifrom,_ito,transaction_count) == TRUE then
selfSay('There you go.')
else
selfSay("You don't have that many coins.")
end
end

clearCrap()
return TRUE

elseif msgcontains(msg,'no') then
selfSay('Transaction canceled <oink!>')
clearCrap()
end
end

return TRUE
end

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

y luego cerrarlo y ponerle de nombre "bank"

2-Copian un npc en la carpeta npc y le borran todo lo de adentro y le pegan esto :

Código:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Banker" script="data/npc/scripts/bank.lua" autowalk="1" floorchange="0">
<health now="100" max="100"/>
<look type="273" head="114" body="106" legs="0" feet="0" corpse="2115"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|. I am the bank." />
</parameters>
</npc>

Y le ponen de nombre Banker al archivo.

Hasta ahi estmos bien luego debes poner el npc en tu mapa y deberia funcionar al 100%

eso era cya!
Volver arriba Ir abajo
Kbzaaa
Admin
Admin
Kbzaaa


Femenino
Cantidad de envíos : 2653
Edad : 32
Localización : en camboya
Fecha de inscripción : 26/12/2007

Npc Banker Empty
MensajeTema: Re: Npc Banker   Npc Banker Icon_minitimeDom Mar 09, 2008 9:01 am

asdasfsafsadasfa qlo true weon D;!!!!
Volver arriba Ir abajo
http://www.petardas.com
 
Npc Banker
Volver arriba 
Página 1 de 1.

Permisos de este foro:No puedes responder a temas en este foro.
 :: Tibia :: Guias Ot-
Cambiar a: