Ir para conteúdo

TFS 1.2 Npc do barco por gold do BANK e da BP


Posts Recomendados

Bem, o script foi testado no tfs 1.2 ele é bem simples...

 

O npc checa se o player tem gold na BP, se tiver gold na BP ele vai levar pra cidade escolhida e será removido o gold da mesma, se o player nao tiver gold na BP o npc vai retirar do bank...

 

Charles.xml

<?xml version="1.0" encoding="UTF-8"?><npc name="Charles" script="Charles.lua" walkinterval="2000" floorchange="0">    <health now="100" max="100" />    <look type="134" head="57" body="67" legs="95" feet="60" addons="0" /> <parameters><parameter key="message_greet" value="Ola  |PLAYERNAME|, Eu posso te transportar para alguns lugares, diga {passage} ou {travel} que eu digo os lugares para voce." /> </parameters></npc>

 

Charles.lua

 

 

 

 

 

 

 

 

 local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) 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 ---- CIDADE                 POSIÇÃO           CUSTOlocal edron = {x = 33175, y = 31764, z = 6, cost = 160} local carlin = {x = 32387, y = 31820, z = 6, cost = 110}local abdendriel = {x = 32734, y = 31668, z = 6, cost = 130} local venore = {x = 32954, y = 32022, z = 6, cost = 170} local porthope = {x = 32527, y = 32784, z = 6, cost = 160} local roshamuul = {x = 33494, y = 32567, z = 7, cost = 210} local svargrond = {x = 32341, y = 31108, z = 6, cost = 180} local libertybay = {x = 32285, y = 32892, z = 6, cost = 180} local yalahar = {x = 32816, y = 31272, z = 6, cost = 200} local oramond = {x = 33479, y = 31985, z = 7, cost = 140}local krailos = {x = 33491, y = 31711, z = 6, cost = 0} local ankrahmun = {x = 33092, y = 32883, z = 6, cost = 150} local thais = {x = 32310, y = 32210, z = 6, cost = 170} local darashia = {x = 33289, y = 32480, z = 6, cost = 100} local grayisland = {x = 33196, y = 31984, z = 7, cost = 150}local cormaya = {x = 33288, y = 31956, z = 6, cost = 20}  nogold        = 'Voce nao tem gold suficiente!' --------------------------CORMAYA----------------------------function Cormaya(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then         return false end if cormaya.cost <= getPlayerMoney(cid) then        doPlayerRemoveMoney(cid, cormaya.cost)        npcHandler:releaseFocus(cid)        doTeleportThing(cid, cormaya)elseif cormaya.cost <=  getPlayerBalance(cid) then        total =  getPlayerBalance(cid) - cormaya.cost        doPlayerSetBalance(cid, total)        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,  'Foi retirado ' .. cormaya.cost .. ' gold de sua conta bancaria. agora voce tem ' .. getPlayerBalance(cid) .. ' gold.')        npcHandler:releaseFocus(cid)        doTeleportThing(cid, cormaya)else        selfSay(nogold, cid) endend    ------------------------------------------------------------  --------------------------GRAY ISLAND----------------------------function GrayIsland(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then         return false end if grayisland.cost <= getPlayerMoney(cid) then        doPlayerRemoveMoney(cid, grayisland.cost)        npcHandler:releaseFocus(cid)        doTeleportThing(cid, grayisland)elseif grayisland.cost <=  getPlayerBalance(cid) then        total =  getPlayerBalance(cid) - grayisland.cost        doPlayerSetBalance(cid, total)        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,  'Foi retirado ' .. grayisland.cost .. ' gold de sua conta bancaria. agora voce tem ' .. getPlayerBalance(cid) .. ' gold.')        npcHandler:releaseFocus(cid)        doTeleportThing(cid, grayisland)else        selfSay(nogold, cid) endend    ------------------------------------------------------------  --------------------------DARASHIA----------------------------function Darashia(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then         return false end if darashia.cost <= getPlayerMoney(cid) then        doPlayerRemoveMoney(cid, darashia.cost)        npcHandler:releaseFocus(cid)        doTeleportThing(cid, darashia)elseif darashia.cost <=  getPlayerBalance(cid) then        total =  getPlayerBalance(cid) - darashia.cost        doPlayerSetBalance(cid, total)        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,  'Foi retirado ' .. darashia.cost .. ' gold de sua conta bancaria. agora voce tem ' .. getPlayerBalance(cid) .. ' gold.')        npcHandler:releaseFocus(cid)        doTeleportThing(cid, darashia)else        selfSay(nogold, cid) endend    ------------------------------------------------------------   --------------------------THAYS----------------------------function Thais(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then         return false end if thais.cost <= getPlayerMoney(cid) then        doPlayerRemoveMoney(cid, thais.cost)        npcHandler:releaseFocus(cid)        doTeleportThing(cid, thais)elseif thais.cost <=  getPlayerBalance(cid) then        total =  getPlayerBalance(cid) - thais.cost        doPlayerSetBalance(cid, total)        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,  'Foi retirado ' .. thais.cost .. ' gold de sua conta bancaria. agora voce tem ' .. getPlayerBalance(cid) .. ' gold.')        npcHandler:releaseFocus(cid)        doTeleportThing(cid, thais)else        selfSay(nogold, cid) endend    ------------------------------------------------------------  --------------------------ANKRAHMUN----------------------------function Ankrahmun(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then         return false end if ankrahmun.cost <= getPlayerMoney(cid) then        doPlayerRemoveMoney(cid, ankrahmun.cost)        npcHandler:releaseFocus(cid)        doTeleportThing(cid, ankrahmun)elseif ankrahmun.cost <=  getPlayerBalance(cid) then        total =  getPlayerBalance(cid) - ankrahmun.cost        doPlayerSetBalance(cid, total)        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,  'Foi retirado ' .. ankrahmun.cost .. ' gold de sua conta bancaria. agora voce tem ' .. getPlayerBalance(cid) .. ' gold.')        npcHandler:releaseFocus(cid)        doTeleportThing(cid, ankrahmun)else        selfSay(nogold, cid) endend    ------------------------------------------------------------  --------------------------Edron----------------------------function Edron(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then         return false end if edron.cost <= getPlayerMoney(cid) then        doPlayerRemoveMoney(cid, edron.cost)        npcHandler:releaseFocus(cid)        doTeleportThing(cid, edron)elseif edron.cost <=  getPlayerBalance(cid) then        total =  getPlayerBalance(cid) - edron.cost        doPlayerSetBalance(cid, total)        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,  'Foi retirado ' .. edron.cost .. ' gold de sua conta bancaria. agora voce tem ' .. getPlayerBalance(cid) .. ' gold.')        npcHandler:releaseFocus(cid)        doTeleportThing(cid, edron)else        selfSay(nogold, cid) endend    --------------------------------------------------------------------------------------Carlin----------------------------function Carlin(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then         return false end if carlin.cost <= getPlayerMoney(cid) then        doPlayerRemoveMoney(cid, carlin.cost)        npcHandler:releaseFocus(cid)        doTeleportThing(cid, carlin)elseif carlin.cost <=  getPlayerBalance(cid) then        total =  getPlayerBalance(cid) - carlin.cost        doPlayerSetBalance(cid, total)        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,  'Foi retirado ' .. carlin.cost .. ' gold de sua conta bancaria. agora voce tem ' .. getPlayerBalance(cid) .. ' gold.')        npcHandler:releaseFocus(cid)        doTeleportThing(cid, carlin)else        selfSay(nogold, cid) endend    --------------------------------------------------------------------------------------ABDENDRIEL----------------------------function Abdendriel(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then         return false end if abdendriel.cost <= getPlayerMoney(cid) then        doPlayerRemoveMoney(cid, abdendriel.cost)        npcHandler:releaseFocus(cid)        doTeleportThing(cid, abdendriel)elseif abdendriel.cost <=  getPlayerBalance(cid) then        total =  getPlayerBalance(cid) - abdendriel.cost        doPlayerSetBalance(cid, total)        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,  'Foi retirado ' .. abdendriel.cost .. ' gold de sua conta bancaria. agora voce tem ' .. getPlayerBalance(cid) .. ' gold.')        npcHandler:releaseFocus(cid)        doTeleportThing(cid, abdendriel)else        selfSay(nogold, cid) endend    --------------------------------------------------------------------------------------VENORE----------------------------function Venore(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then         return false end if venore.cost <= getPlayerMoney(cid) then        doPlayerRemoveMoney(cid, venore.cost)        npcHandler:releaseFocus(cid)        doTeleportThing(cid, venore)elseif venore.cost <=  getPlayerBalance(cid) then        total =  getPlayerBalance(cid) - venore.cost        doPlayerSetBalance(cid, total)        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,  'Foi retirado ' .. venore.cost .. ' gold de sua conta bancaria. agora voce tem ' .. getPlayerBalance(cid) .. ' gold.')        npcHandler:releaseFocus(cid)        doTeleportThing(cid, venore)else        selfSay(nogold, cid) endend    --------------------------------------------------------------------------------------PORTHOPE----------------------------function PortHope(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then         return false end if porthope.cost <= getPlayerMoney(cid) then        doPlayerRemoveMoney(cid, porthope.cost)        npcHandler:releaseFocus(cid)        doTeleportThing(cid, porthope)elseif porthope.cost <=  getPlayerBalance(cid) then        total =  getPlayerBalance(cid) - porthope.cost        doPlayerSetBalance(cid, total)        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,  'Foi retirado ' .. porthope.cost .. ' gold de sua conta bancaria. agora voce tem ' .. getPlayerBalance(cid) .. ' gold.')        npcHandler:releaseFocus(cid)        doTeleportThing(cid, porthope)else        selfSay(nogold, cid) endend    --------------------------------------------------------------------------------------ROSHAMUUL----------------------------function Roshamuul(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then         return false end if roshamuul.cost <= getPlayerMoney(cid) then        doPlayerRemoveMoney(cid, roshamuul.cost)        npcHandler:releaseFocus(cid)        doTeleportThing(cid, roshamuul)elseif roshamuul.cost <=  getPlayerBalance(cid) then        total =  getPlayerBalance(cid) - roshamuul.cost        doPlayerSetBalance(cid, total)        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,  'Foi retirado ' .. roshamuul.cost .. ' gold de sua conta bancaria. agora voce tem ' .. getPlayerBalance(cid) .. ' gold.')        npcHandler:releaseFocus(cid)        doTeleportThing(cid, roshamuul)else        selfSay(nogold, cid) endend    --------------------------------------------------------------------------------------SVARGROUND----------------------------function Svargrond(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then         return false end if svargrond.cost <= getPlayerMoney(cid) then        doPlayerRemoveMoney(cid, svargrond.cost)        npcHandler:releaseFocus(cid)        doTeleportThing(cid, svargrond)elseif svargrond.cost <=  getPlayerBalance(cid) then        total =  getPlayerBalance(cid) - svargrond.cost        doPlayerSetBalance(cid, total)        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,  'Foi retirado ' .. svargrond.cost .. ' gold de sua conta bancaria. agora voce tem ' .. getPlayerBalance(cid) .. ' gold.')        npcHandler:releaseFocus(cid)        doTeleportThing(cid, svargrond)else        selfSay(nogold, cid) endend    --------------------------------------------------------------------------------------LIBERT BAY----------------------------function LibertBay(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then         return false end if libertybay.cost <= getPlayerMoney(cid) then        doPlayerRemoveMoney(cid, libertybay.cost)        npcHandler:releaseFocus(cid)        doTeleportThing(cid, libertybay)elseif libertybay.cost <=  getPlayerBalance(cid) then        total =  getPlayerBalance(cid) - libertybay.cost        doPlayerSetBalance(cid, total)        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,  'Foi retirado ' .. libertybay.cost .. ' gold de sua conta bancaria. agora voce tem ' .. getPlayerBalance(cid) .. ' gold.')        npcHandler:releaseFocus(cid)        doTeleportThing(cid, libertybay)else        selfSay(nogold, cid) endend    --------------------------------------------------------------------------------------YALAHAR----------------------------function Yalahar(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then         return false end if yalahar.cost <= getPlayerMoney(cid) then        doPlayerRemoveMoney(cid, yalahar.cost)        npcHandler:releaseFocus(cid)        doTeleportThing(cid, yalahar)elseif yalahar.cost <=  getPlayerBalance(cid) then        total =  getPlayerBalance(cid) - yalahar.cost        doPlayerSetBalance(cid, total)        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,  'Foi retirado ' .. yalahar.cost .. ' gold de sua conta bancaria. agora voce tem ' .. getPlayerBalance(cid) .. ' gold.')        npcHandler:releaseFocus(cid)        doTeleportThing(cid, yalahar)else        selfSay(nogold, cid) endend    --------------------------------------------------------------------------------------ORAMOND----------------------------function Oramond(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then         return false end if oramond.cost <= getPlayerMoney(cid) then        doPlayerRemoveMoney(cid, oramond.cost)        npcHandler:releaseFocus(cid)        doTeleportThing(cid, oramond)elseif oramond.cost <=  getPlayerBalance(cid) then        total =  getPlayerBalance(cid) - oramond.cost        doPlayerSetBalance(cid, total)        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,  'Foi retirado ' .. oramond.cost .. ' gold de sua conta bancaria. agora voce tem ' .. getPlayerBalance(cid) .. ' gold.')        npcHandler:releaseFocus(cid)        doTeleportThing(cid, oramond)else        selfSay(nogold, cid) endend    --------------------------------------------------------------------------------------KRAILOS----------------------------function Krailos(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then         return false end if krailos.cost <= getPlayerMoney(cid) then        doPlayerRemoveMoney(cid, krailos.cost)        npcHandler:releaseFocus(cid)        doTeleportThing(cid, krailos)elseif krailos.cost <=  getPlayerBalance(cid) then        total =  getPlayerBalance(cid) - krailos.cost        doPlayerSetBalance(cid, total)        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,  'Foi retirado ' .. krailos.cost .. ' gold de sua conta bancaria. agora voce tem ' .. getPlayerBalance(cid) .. ' gold.')        npcHandler:releaseFocus(cid)        doTeleportThing(cid, krailos)else        selfSay(nogold, cid) endend    ------------------------------------------------------------keywordHandler:addKeyword({'passage'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Passagens para Venore, Cormaya, Yalahar, Carlin, Port Hope, Roshamuul, Oramond,Svargrond, Krailos,Darashia, Gray Island Edron, Darashia, Thais, Ab\'dendriel, Liberty Bay, Ankrahmun."}) keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Passagens para Venore, Cormaya, Yalahar, Carlin, Port Hope, Roshamuul, Oramond,Svargrond, Krailos,Darashia, Gray Island Edron, Darashia, Thais, Ab\'dendriel, Liberty Bay, Ankrahmun."})     node1 = keywordHandler:addKeyword({'edron'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce deseja viajar para Edron? custo de 160 gold.'})     node1:addChildKeyword({'yes'}, Edron, {})     node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ate a proxima!', reset = true})     node2 = keywordHandler:addKeyword({'ab\'dendriel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce deseja viajar para Ab Dendriel? custo de 130 gold.'})     node2:addChildKeyword({'yes'}, Abdendriel, {})     node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ate a proxima!', reset = true})     node3 = keywordHandler:addKeyword({'carlin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce deseja viajar para Carlin? custo de 110 gold.'})     node3:addChildKeyword({'yes'}, Carlin, {})     node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ate a proxima!', reset = true})     node4 = keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce deseja viajar para Thais? custo de 170 gold.'})     node4:addChildKeyword({'yes'}, Thais, {})     node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ate a proxima!', reset = true})     node5 = keywordHandler:addKeyword({'port hope'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce deseja viajar para Port Hope? custo de 160 gold.'})     node5:addChildKeyword({'yes'}, PortHope, {})     node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ate a proxima!', reset = true})     node6 = keywordHandler:addKeyword({'roshamuul'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce deseja viajar para Roshamuul? custo de 210 gold.'})     node6:addChildKeyword({'yes'}, Roshamuul, {})     node6:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ate a proxima!', reset = true})         node7 = keywordHandler:addKeyword({'svargrond'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce deseja viajar para Svargrond? custo de 180 gold.'})     node7:addChildKeyword({'yes'}, Svargrond, {})     node7:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ate a proxima!', reset = true})         node8 = keywordHandler:addKeyword({'liberty bay'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce deseja viajar para Liberty Bay? custo de 180 gold.'})     node8:addChildKeyword({'yes'}, LibertBay, {})     node8:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ate a proxima!', reset = true})      node9 = keywordHandler:addKeyword({'yalahar'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce deseja viajar para Yalahar? custo de 200 gold.'})     node9:addChildKeyword({'yes'}, Yalahar, {})     node9:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ate a proxima!', reset = true})     node10 = keywordHandler:addKeyword({'oramond'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce deseja viajar para Oramond? custo de 170 gold.'})     node10:addChildKeyword({'yes'}, Oramond, {})     node10:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ate a proxima!', reset = true})     node11 = keywordHandler:addKeyword({'krailos'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce deseja viajar para Krailos? Essa viagem e gratuita.'})     node11:addChildKeyword({'yes'}, Krailos, {})     node11:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ate a proxima!', reset = true})             node12 = keywordHandler:addKeyword({'ankrahmun'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce deseja viajar para Ankrahmun? custo de 150.'})     node12:addChildKeyword({'yes'}, Ankrahmun, {})     node12:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ate a proxima!', reset = true})     node13 = keywordHandler:addKeyword({'venore'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce deseja viajar para Venore? custo de 170 gold.'})     node13:addChildKeyword({'yes'}, Venore, {})     node13:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ate a proxima!', reset = true})     node14 = keywordHandler:addKeyword({'darashia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce deseja viajar para Darashia? custo de 100 gold.'})     node14:addChildKeyword({'yes'}, Darashia, {})     node14:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ate a proxima!', reset = true})     node15 = keywordHandler:addKeyword({'gray island'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce deseja viajar para Gray Island? custo de 150 gold.'})     node15:addChildKeyword({'yes'}, GrayIsland, {})     node15:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ate a proxima!', reset = true})         node16 = keywordHandler:addKeyword({'cormaya'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce deseja viajar para Cormaya? custo de 20 gold.'})     node16:addChildKeyword({'yes'}, Cormaya, {})     node16:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ate a proxima!', reset = true})         npcHandler:addModule(FocusModule:new()) 
 

 

Peguei como base o NPC de addons... pra quem quiser adicionar mais cidades é só seguir a lógica ali.. 

 

Abraços!

Editado por Cleberadm
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...