nslex

Npc que muda vocação.

Dec 8th, 2011
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.33 KB | None | 0 0
  1. local focus = 0
  2. local talk_start = 0
  3. local target = 0
  4. local following = false
  5. local attacking = false
  6.  
  7. function onThingMove(creature, thing, oldpos, oldstackpos)
  8.  
  9. end
  10.  
  11.  
  12. function onCreatureAppear(creature)
  13.  
  14. end
  15.  
  16.  
  17. function onCreatureDisappear(cid, pos)
  18.     if focus == cid then
  19.           selfSay('?????.')
  20.           focus = 0
  21.           talk_start = 0
  22.     end
  23. end
  24.  
  25.  
  26. function onCreatureTurn(creature)
  27.  
  28. end
  29.  
  30.  
  31. function msgcontains(txt, str)
  32.     return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
  33. end
  34.  
  35.  
  36. function onCreatureSay(cid, type, msg)
  37.     msg = string.lower(msg)
  38.  
  39.     if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
  40.        
  41.             selfSay('Hello. If you ready I can "renascer" you.')
  42.             focus = cid
  43.             talk_start = os.clock()
  44.        
  45.  
  46.     elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  47.         selfSay('Sorry, ' .. getCreatureName(cid) .. '! Hey!.')
  48.  
  49.     elseif focus == cid then
  50.         talk_start = os.clock()
  51.  
  52. if msgcontains(msg, 'renascer') and getPlayerStorageValue(cid,30023) == 4 then
  53.                 selfSay('desculpe, você ja renasceu.')
  54.             focus = 0
  55.             talk_start = 0
  56.  
  57.             elseif msgcontains(msg, 'reborn') and getPlayerLevel(cid) < 250 and getPlayerStorageValue(cid,30023) ~= 4 then
  58.                     selfSay('Hehe, I say If you READY. You do not have 250 level.')
  59.  
  60.             elseif msgcontains(msg, 'renascer') then
  61.                     selfSay('Are you sure?')
  62.                                  talk_state = 2
  63.  
  64. elseif msgcontains(msg, 'yes') and talk_state ==2 and getPlayerLevel(cid) >= 250 and getPlayerVocation(cid) == 21 then
  65. doPlayerSetVocation(cid, 22)
  66. setPlayerStorageValue(cid,30025,4)
  67. talk_state = 0                      
  68.  
  69.  
  70. elseif msgcontains(msg, 'yes') and talk_state == 2 then
  71. selfSay('Sorry, ' .. getCreatureName(cid) .. '! Você não pode mais evoluir.')
  72.  
  73.  
  74.         elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
  75.             selfSay('Good bye.')
  76.             focus = 0
  77.             talk_start = 0
  78.         end
  79.     end
  80. end
  81.  
  82. function onThink()
  83.     doNpcSetCreatureFocus(focus)
  84.     if (os.clock() - talk_start) > 45 then
  85.         if focus > 0 then
  86.             selfSay('Next Please...')
  87.         end
  88.             focus = 0
  89.     end
  90.     if focus ~= 0 then
  91.         if getDistanceToCreature(focus) > 5 then
  92.             selfSay('Good bye then.')
  93.             focus = 0
  94.         end
  95.     end
  96. end
  97.  
Advertisement
Add Comment
Please, Sign In to add comment