Ola Galera Do XTibia
Hj trago um novo npc.
Eu entrei em varios foruns procurando um npc banker + todos que eu axava não funfava então eu peguei o script de uma aki e vo postar pra vcs.
Testado em ot server full global 2.3
Versão:8.4
Vamos lava em data/npcs e crie um arquivo xml com o nome bankman billy e coloque isso dentro
<npc name="Bankman Billy" script="data/npc/scripts/bank.lua" floorchange="0" walkinterval="4000">
<health now="150" max="150"/>
<look type="133" head="10" body="122" legs="19" feet="10"/>
<interaction range="3" idletime="30" idleinterval="300" defaultpublic="0">
<!--This will include the bankman interaction, in this way several npc can use the same interaction-->
<include file="bankman.xml"/>
<interact keywords="hi" focus="1">
<!--These are the alternative keywords-->
<keywords>hello</keywords>
<response text="Hello. How may I help you |NAME|?"/>
</interact>
<interact keywords="bye" focus="0">
<!--These are the alternative keywords-->
<keywords>farewell</keywords>
<response text="It was a pleasure to help you."/>
</interact>
<!--
<interact event="onBusy">
<response text="One moment please, |NAME|.">
<action name="addqueue" value="|PLAYER|"/>
</response>
</interact>
-->
<interact event="onIdle">
<response text="Beatiful day is it not |NAME|?" public="1">
<action name="idle" value="1"/>
</response>
<response>
<action name="script">
<![CDATA[
-- The npc will just say this on average once every 4 hours (240 minutes)
local interval = 240 * 60
local p = math.random(0, 10000000)
local r = (10000000 * idleinterval) / interval
--selfSay("r: " .. r .. ", p: " .. p)
if(r >= p) then
selfSay("Hey " .. name .. " can you help me?")
_state.topic = 999
end
]]>
</action>
<interact keywords="yes" topic="999">
<response text="Ah great, would you mind holding this for me while I use the bathroom?">
<action name="topic" value="-1"/>
<interact keywords="yes">
<response>
<action name="script">
<![CDATA[
local result = doPlayerAddItem(cid, 2157, 3, 0)
if(result == -1) then
selfSay("Never mind, I'll have to hold it in until I quit work.")
else
selfSay("Thanks alot! I'll be right back.")
_state.b1 = true
end
]]>
</action>
</response>
</interact>
</response>
<interact keywords="|*|">
<response text="Hmpf."/>
</interact>
</interact>
</response>
</interact>
<interact event="onPlayerLeave" focus="0">
<response text="It was a pleasure to help you |NAME|."/>
<response b1="1" text="Hey hey give back my gold nuggets! POLICE HELP!"/>
</interact>
<interact keywords="name">
<response text="My name is |NPCNAME|."/>
</interact>
<interact keywords="job">
<response text="I am a banker, my job is to exchange coins."/>
</interact>
</interaction>
</npc>
Depois va em scripts e crie um arquivo .lua com o nome bank e coloque isso dentro
local npcHandler = NpcHandler:new(keywordHandler)
local stan = 0
local stan_two = 0
local player_pattern = '^[a-zA-Z0-9 -]+$'
local number_pattern = '%d'
local target_cid = 0
local number_pattern_two = '%d+'
local b, e = 0
local count = 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 creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return FALSE
end
if getPlayerStorageValue(cid,8996) == -1 then
setPlayerStorageValue(cid,8996,0)
end
if msgcontains(msg, 'deposit') then
if string.find(msg, number_pattern) then
b, e = string.find(msg, number_pattern_two)
count = tonumber(string.sub(msg, b, e))
if getPlayerMoney(cid) >= count then
doPlayerRemoveMoney(cid,count)
stan = getPlayerStorageValue(cid,8996) + count
setPlayerStorageValue(cid,8996,stan)
npcHandler:say('Alright, we have added the amount of '..count..' gold to your balance. You can withdraw your money anytime.', cid)
local talk_state = 0
else
npcHandler:say('You don\'t have so much gold.', cid)
local talk_state = 0
end
else
npcHandler:say('Please tell me how much gold you would like to deposit.', cid)
local talk_state = 1
end
elseif msgcontains(msg, 'withdraw') then
if string.find(msg, number_pattern) then
b, e = string.find(msg, number_pattern_two)
count = tonumber(string.sub(msg, b, e))
if getPlayerStorageValue(cid,8996) - count >= 0 then
stan = getPlayerStorageValue(cid,8996) - count
setPlayerStorageValue(cid,8996,stan)
doPlayerAddMoney(cid,count)
npcHandler:say('Here you are, '..count..' gold. Please let me know if there is something else I can do for you.', cid)
local talk_state = 0
else
npcHandler:say('There is not enough gold on your account.', cid)
local talk_state = 0
end
else
npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
local talk_state = 2
end
elseif msgcontains(msg, 'balance') then
if getPlayerStorageValue(cid,8996) == -1 then
setPlayerStorageValue(cid,8996,0)
end
npcHandler:say('Your account balance is ' .. getPlayerStorageValue(cid,8996) .. ' gold.', cid)
local talk_state = 0
elseif talk_state == 1 then
count = tonumber(string.sub(msg, b, e))
if string.find(msg, number_pattern) then
if doPlayerRemoveMoney(cid, msg) then
stan = getPlayerStorageValue(cid,8996) + msg
setPlayerStorageValue(cid,8996,stan)
doPlayerRemoveMoney(cid,msg)
npcHandler:say('Alright, we have added the amount of '..count..' gold to your balance. You can withdraw your money anytime.', cid)
local talk_state = 0
else
npcHandler:say('You don\'t have so much gold.', cid)
local talk_state = 0
end
else
npcHandler:say('Please tell me how much gold you would like to deposit.', cid)
local talk_state = 1
end
elseif talk_state == 2 then
count = tonumber(string.sub(msg, b, e))
stan = getPlayerStorageValue(cid,8996)
if string.find(msg, number_pattern) then
if getPlayerStorageValue(cid,8996) - msg >= 0 then
stan = getPlayerStorageValue(cid,8996) - msg
setPlayerStorageValue(cid,8996,stan)
doPlayerAddMoney(cid,msg)
npcHandler:say('Here you are, '..count..' gold. Please let me know if there is something else I can do for you.', cid)
local talk_state = 0
else
npcHandler:say('There is not enough gold on your account.', cid)
local talk_state = 0
end
else
npcHandler:say('Please tell me how much gold you would like to deposit.', cid)
local talk_state = 2
end
return true
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
--npcHandler:setMessage(MESSAGE_FAREWELL, 'Bye, bye. You gold safe at here, |PLAYERNAME|. <snickers>!')
npcHandler:addModule(FocusModule:new())
Prontinho agoraum tuto para explicar melhor:
TUTO para depositar dinheiro
Tuto para tirar dinheiro
Não vou postar o tutoral de transferir dinheiro pq eu to ndo viajar + quando eu xegar na casa da minha tia eu posto como tranferir grana
Duvidas não deixem de perguntar
Comentem
:dlb: Fuizzzzzzzzzz
Metas:
[x]1 post (NOOB)
[x]5 posts (SERVO)
[x]10 posts (CAMPONÊS)
[x]25 posts (CAÇADOR)
[x]50 posts (CAVALEIRO)
[ ]100 posts (BARONETE)
[ ]200 posts (BARÃO)
[ ]300 posts (VISCONDE)
[ ]400 posts (DUQUE)
[ ]600 posts (ARQUEDUQUE)
[ ]800 posts (ARISTOCRATA)
[ ]1000 posts (REGENTE)
[ ]1400 posts (SÁBIO)
[ ]1800 posts (SACERDOTE)
[ ]2500 posts (PRÍNCIPE)