Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. local focus = 0
  2. local talk_start = 0
  3. local TS = 0
  4.  
  5. function onCreatureDisappear(cid, pos)
  6. if focus == cid then
  7. selfSay('Good bye then.')
  8. focus = 0
  9. talk_start = 0
  10. end
  11. end
  12.  
  13. local function BYE()
  14. focus = 0
  15. talk_start = 0
  16. TS = 0
  17. end
  18.  
  19. function msgcontains(txt, str)
  20. return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
  21. end
  22.  
  23. function onCreatureSay(cid, type, msg)
  24.  
  25. msg = string.lower(msg)
  26. if (msgcontains(msg, 'hi') and (focus == 0)) then
  27. selfSay('Hello ' .. getCreatureName(cid) .. ', Do you want to make arena?.')
  28. focus = cid
  29. talk_start = os.clock()
  30. TS = 1
  31. elseif msgcontains(msg, 'hi') and (focus ~= cid) then
  32. selfSay('Im Bussy')
  33. elseif TS == 1 and msgcontains(msg, 'yes') or msgcontains(msg, 'fight') or msgcontains(msg, 'arena') then
  34. if getPlayerStorageValue(cid, myArenaLevel) < 3 then
  35. local enterArena = myArenaLevelIs(cid)
  36. if getPlayerLevel(cid) >= enterArena.RLV then
  37. if getPlayerMoney(cid) >= enterArena.RC then
  38. setPlayerStorageValue(cid, talkNPC, 1)
  39. doPlayerRemoveMoney(cid, enterArena.RC)
  40. selfSay("Now you can go to test... ".. enterArena.LN .."")
  41. BYE()
  42. else
  43. selfSay("You don\'t have "..enterArena.RC.." gp! Come back when you will be ready!")
  44. BYE()
  45. end
  46. else
  47. selfSay("You don\'t have "..enterArena.RLV.." level! Come back when you will be ready!")
  48. BYE()
  49. end
  50. else
  51. selfSay(Cancel[6])
  52. BYE()
  53. end
  54. elseif TS == 1 and msgcontains(msg, 'no') then
  55. selfSay("Bye!.")
  56. BYE()
  57. elseif msgcontains(msg, 'bye') then
  58. selfSay("Bye!.")
  59. BYE()
  60. end
  61. return true
  62. end
  63.  
  64. function onThink()
  65. doNpcSetCreatureFocus(focus)
  66. if (os.clock() - talk_start) > 60 then
  67. if focus > 0 then
  68. selfSay('Good bye then.')
  69. end
  70. focus = 0
  71. end
  72. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement