Summ

Npc.lua

Feb 12th, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.06 KB | None | 0 0
  1. local citys = {
  2.     town1 = {x=1555, y=2576, z=6}, -- yalahar
  3.     town2 = {x=487, y=261, z=6},  -- anknor
  4.     town3 = {x=1367, y=195, z=6}, -- goroma
  5.     town4 = {x=1995, y=2394, z=6}, -- smallville
  6.     town5 = {x=238, y=370, z=6}, -- venonh
  7.     town6= {x=114, y=282, z=6}, -- alfon
  8.     town7 = {x=31, y=79, z=6}, -- dorion
  9.     town8  = {x=10386, y=10311, z=6}, -- everwood
  10.     town9 = {x=1348, y=1155, z=6}, -- falelfia
  11.     town10 = {x=114 ,y=282 ,z=6} -- nunca
  12. }
  13.  
  14. local cost = 100
  15.  
  16. local keywordHandler = KeywordHandler:new()
  17. local npcHandler = NpcHandler:new(keywordHandler)
  18. NpcSystem.parseParameters(npcHandler)
  19. local talkState = {}
  20.  
  21. function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
  22. function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
  23. function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
  24. function onThink() npcHandler:onThink() end
  25.  
  26.  
  27. function creatureSayCallback(cid, type, msg)
  28.  
  29.     if not npcHandler:isFocused(cid) then
  30.         return false
  31.     end
  32.    
  33.     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  34.  
  35.             if msgcontains(msg, 'travel') then
  36.                 selfSay('Eu posso te levar para, {yalahar}, {anknor}, {goroma}, {smallville}, {venonh}, {alfon}, {dorion}, {everwood}, {falelfia}, {nunca}, por um pequeno custo.', cid)
  37.                 talkState[talkUser] = 0
  38.             end
  39.            
  40.             if msgcontains(msg, 'yalahar') then
  41.                 selfSay('você tem certeza que quer viajar por 100 gold coin ?', cid)
  42.                 talkState[talkUser] = 1
  43.             end
  44.            
  45.             if msgcontains(msg, 'anknor') then
  46.                 selfSay('você tem certeza que quer viajar por 100 gold coin ?', cid)
  47.                 talkState[talkUser] = 2
  48.             end
  49.            
  50.             if msgcontains(msg, 'goroma') then
  51.                 selfSay('você tem certeza que quer viajar por 100 gold coin ?', cid)
  52.                 talkState[talkUser] = 3
  53.             end
  54.            
  55.             if msgcontains(msg, 'smallville') then
  56.                 selfSay('você tem certeza que quer viajar por 100 gold coin ?', cid)
  57.                 talkState[talkUser] = 4
  58.             end
  59.            
  60.             if msgcontains(msg, 'venonh') then
  61.                 selfSay('você tem certeza que quer viajar por 100 gold coin ?', cid)
  62.                 talkState[talkUser] = 5
  63.             end
  64.            
  65.             if msgcontains(msg, 'alfon') then
  66.                 selfSay('você tem certeza que quer viajar por 100 gold coin ?', cid)
  67.                 talkState[talkUser] = 6
  68.             end
  69.            
  70.             if msgcontains(msg, 'dorion') then
  71.                 selfSay('você tem certeza que quer viajar por 100 gold coin ?', cid)
  72.                 talkState[talkUser] = 7
  73.             end
  74.            
  75.             if msgcontains(msg, 'everwood') then
  76.                 selfSay('você tem certeza que quer viajar por 100 gold coin ?', cid)
  77.                 talkState[talkUser] = 8
  78.             end
  79.            
  80.             if msgcontains(msg, 'falelfia') then
  81.                 selfSay('você tem certeza que quer viajar por 100 gold coin ?', cid)
  82.                 talkState[talkUser] = 9
  83.             end
  84.            
  85.             if msgcontains(msg, 'nunca') then
  86.                 selfSay('você tem certeza que quer viajar por 100 gold coin ?', cid)
  87.                 talkState[talkUser] = 10
  88.             end
  89.            
  90.             if msgcontains(msg, 'yes') then
  91.                 if talkState[talkUser] == 1 then
  92.                     if doPlayerRemoveMoney(cid, cost) then
  93.                         doTeleportThing(cid, {x=citys.town1.x, y=citys.town1.y, z=citys.town1.z})
  94.                         selfSay('Let\'s GO', cid)
  95.                         talkState[talkUser] = 0
  96.                     else
  97.                         selfSay('Desculpe, você não tem dinheiro suficiente', cid)
  98.                         talkState[talkUser] = 0
  99.                     end
  100.                 elseif talkState[talkUser] == 2 then
  101.                     if doPlayerRemoveMoney(cid, cost) then
  102.                         doTeleportThing(cid, {x=citys.town2.x, y=citys.town2.y, z=citys.town2.z})
  103.                         selfSay('Let\'s GO', cid)
  104.                         talkState[talkUser] = 0
  105.                     else
  106.                         selfSay('Desculpe, você não tem dinheiro suficiente', cid)
  107.                         talkState[talkUser] = 0
  108.                     end
  109.                 elseif talkState[talkUser] == 3 then
  110.                     if doPlayerRemoveMoney(cid, cost) then
  111.                         doTeleportThing(cid, {x=citys.town3.x, y=citys.town3.y, z=citys.town3.z})
  112.                         selfSay('Let\'s GO', cid)
  113.                         talkState[talkUser] = 0
  114.                     else
  115.                         selfSay('Desculpe, você não tem dinheiro suficiente', cid)
  116.                         talkState[talkUser] = 0
  117.                     end
  118.                 elseif talkState[talkUser] == 4 then
  119.                     if doPlayerRemoveMoney(cid, cost) then
  120.                         doTeleportThing(cid, {x=citys.town4.x, y=citys.town4.y, z=citys.town4.z})
  121.                         selfSay('Let\'s GO', cid)
  122.                         talkState[talkUser] = 0
  123.                     else
  124.                         selfSay('Desculpe, você não tem dinheiro suficiente', cid)
  125.                         talkState[talkUser] = 0
  126.                     end
  127.                 elseif talkState[talkUser] == 5 then
  128.                     if doPlayerRemoveMoney(cid, cost) then
  129.                         doTeleportThing(cid, {x=citys.town5.x, y=citys.town5.y, z=citys.town5.z})
  130.                         selfSay('Let\'s GO', cid)
  131.                         talkState[talkUser] = 0
  132.                     else
  133.                         selfSay('Desculpe, você não tem dinheiro suficiente', cid)
  134.                         talkState[talkUser] = 0
  135.                     end
  136.                 elseif talkState[talkUser] == 6 then
  137.                     if doPlayerRemoveMoney(cid, cost) then
  138.                         doTeleportThing(cid, {x=citys.town6.x, y=citys.town6.y, z=citys.town6.z})
  139.                         selfSay('Let\'s GO', cid)
  140.                         talkState[talkUser] = 0
  141.                     else
  142.                         selfSay('Desculpe, você não tem dinheiro suficiente', cid)
  143.                         talkState[talkUser] = 0
  144.                     end
  145.                 elseif talkState[talkUser] == 7 then
  146.                     if doPlayerRemoveMoney(cid, cost) then
  147.                         doTeleportThing(cid, {x=citys.town7.x, y=citys.town7.y, z=citys.town7.z})
  148.                         selfSay('Let\'s GO', cid)
  149.                         talkState[talkUser] = 0
  150.                     else
  151.                         selfSay('Desculpe, você não tem dinheiro suficiente', cid)
  152.                         talkState[talkUser] = 0
  153.                     end
  154.                 elseif talkState[talkUser] == 8 then
  155.                     if getPlayerVipDays(cid) > 0 then
  156.                         if doPlayerRemoveMoney(cid, cost) then
  157.                             doTeleportThing(cid, {x=citys.town8.x, y=citys.town8.y, z=citys.town8.z})
  158.                             selfSay('Let\'s GO', cid)
  159.                             talkState[talkUser] = 0
  160.                         else
  161.                             selfSay('Desculpe, você não tem dinheiro suficiente', cid)
  162.                             talkState[talkUser] = 0
  163.                         end
  164.                     else
  165.                         selfSay('Você não tem VIP!', cid)
  166.                         talkState[talkUser] = 0
  167.                     end
  168.                 elseif talkState[talkUser] == 9 then
  169.                     if getPlayerVipDays(cid) > 0 then
  170.                         if doPlayerRemoveMoney(cid, cost) then
  171.                             doTeleportThing(cid, {x=citys.town9.x, y=citys.town9.y, z=citys.town9.z})
  172.                             selfSay('Let\'s GO', cid)
  173.                             talkState[talkUser] = 0
  174.                         else
  175.                             selfSay('Desculpe, você não tem dinheiro suficiente', cid)
  176.                             talkState[talkUser] = 0
  177.                         end
  178.                     else
  179.                         selfSay('Você não tem VIP!', cid)
  180.                         talkState[talkUser] = 0
  181.                     end
  182.                 elseif talkState[talkUser] == 10 then
  183.                     if getPlayerVipDays(cid) > 0 then
  184.                         if doPlayerRemoveMoney(cid, cost) then
  185.                             doTeleportThing(cid, {x=citys.town10.x, y=citys.town10.y, z=citys.town10.z})
  186.                             selfSay('Let\'s GO', cid)
  187.                             talkState[talkUser] = 0
  188.                         else
  189.                             selfSay('Desculpe, você não tem dinheiro suficiente', cid)
  190.                             talkState[talkUser] = 0
  191.                         end
  192.                     else
  193.                         selfSay('Você não tem VIP!', cid)
  194.                         talkState[talkUser] = 0
  195.                     end
  196.                 elseif msgcontains(msg, 'no') and talkState[talkUser] >= 1 then
  197.                     selfSay('Tchau! Volte Logo', cid)
  198.                     talkState[talkUser] = 0
  199.                 end
  200.             end
  201.                          
  202. return true
  203. end
  204.  
  205. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  206. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment