Advertisement
Guest User

Untitled

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