W npc dodaj plik Bank.xml i wklej to:
Spoiler: <?xml version="1.0"?>
<npc name="Bank" script="data/npc/scripts/bank.lua" access="3" lookdir="2" autowalk="25"> <mana now="800" max="800"/> <health now="200" max="200"/> <look type="133" head="114" body="114" legs="132" feet="114" addons="3"/> </npc>
iw npc/scripts stwórz bank.lua i wklej to:
Spoiler: -- RL Tibia Bank System local keywordHandler = KeywordHandler:new() 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)
-- OTServ event handling functions start 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 -- OTServ event handling functions end function creatureSayCallback(cid, type, msg) if(npcHandler.focus ~= cid) then return false end if getPlayerStorageValue(cid,8996) <= 0 then setPlayerStorageValue(cid,8996,0) end if msgcontains(msg, 'deposit') or msgcontains(msg, 'wplac') then if string.find(msg, number_pattern) then b, e = string.find(msg, number_pattern_two) count = tonumber(string.sub(msg, b, e)) if pay(cid,count) then stan = getPlayerStorageValue(cid,8996) + count setPlayerStorageValue(cid,8996,stan) doPlayerRemoveMoney(cid,count) selfSay('Money was deposited!') talk_state = 0 else selfSay('You dont have anought money!') talk_state = 0 end else selfSay('How much money you want deposit?') talk_state = 1 end elseif msgcontains(msg, 'withdraw') or msgcontains(msg, 'wyplac') 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) selfSay('Money was withdrawed!') talk_state = 0 else selfSay('You do not have anought money on account!') talk_state = 0 end else selfSay('How much money you want withdraw?') talk_state = 2 end elseif msgcontains(msg, 'transfer') or msgcontains(msg, 'transferuj') then selfSay('Want you for who transfer money?') talk_state = 3 elseif msgcontains(msg, 'balance') or msgcontains(msg, 'stan') then selfSay('Your account have ' .. getPlayerStorageValue(cid,8996) .. 'gp.') talk_state = 4 elseif talk_state == 1 then if string.find(msg, number_pattern) then if pay(cid,msg) then stan = getPlayerStorageValue(cid,8996) + msg setPlayerStorageValue(cid,8996,stan) doPlayerRemoveMoney(cid,msg) selfSay('Money was deposited!') talk_state = 0 else selfSay('You dont have anought money!') talk_state = 0 end else selfSay('There is not number!') talk_state = 0 end elseif talk_state == 2 then 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) selfSay('Money was withdrawed!') talk_state = 0 else selfSay('You do not have anought money on account!') talk_state = 0 end else selfSay('There is not number!') talk_state = 0 end elseif talk_state == 3 then if string.find(msg, player_pattern) then target_cid = getPlayerByName(msg) if isPlayer(target_cid) == 1 then talk_state = 4 selfSay('How much i must transfer?') else talk_state = 0 selfSay('Player is not online or this player dont exists.') end else selfSay('It isnt nick!') talk_state = 0 end elseif talk_state == 4 then stan = getPlayerStorageValue(cid,8996) if string.find(msg, number_pattern) then if stan - msg >= 0 then stan_two = getPlayerStorageValue(target_cid,8996) + msg stan = getPlayerStorageValue(cid,8996) - msg setPlayerStorageValue(target_cid,8996,stan_two) setPlayerStorageValue(cid,8996,stan) doPlayerRemoveMoney(cid,msg) talk_state = 0 selfSay('Money transfered.') else selfSay('You do not have anought money on account!') talk_state = 0 end else selfSay('There is not number!') talk_state = 0 end elseif talk_state == 5 then end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new
|