Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4.  
  5. local t, K = {
  6. level = 75,
  7. minl = 10,
  8. maxl = 150,
  9. base = 25000,
  10. char = 1000,
  11. timer = 45001
  12. }, {}
  13.  
  14. function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
  15. function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
  16. function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
  17. function onThink() npcHandler:onThink() end
  18.  
  19. function greetCallback(cid)
  20. K[cid] = nil
  21. return true
  22. end
  23.  
  24. function creatureSayCallback(cid, type, msg)
  25. if not npcHandler:isFocused(cid) then
  26. return false
  27. elseif not K[cid] then
  28. if t.level and getPlayerLevel(cid) < t.level then
  29. selfSay('You need to be level ' .. t.level .. ' or higher to broadcast.', cid)
  30. elseif t.minl and msg:len() < t.minl then
  31. selfSay('Your message must contain at least ' .. t.minl .. ' characters.', cid)
  32. elseif t.maxl and msg:len() >= t.maxl then
  33. selfSay('Your message may contain no more than ' .. t.maxl .. ' characters.', cid)
  34. else
  35. selfSay('Do you want to broadcast this message for ' .. (t.base or 0) + (t.char or 0) * msg:len() .. ' gold?', cid)
  36. K[cid] = msg
  37. end
  38. elseif K[cid] and msgcontains(msg, 'yes') then
  39. if doPlayerRemoveMoney(cid, (t.base or 0) + (t.char or 0) * K[cid]:len()) then
  40. for _, pid in ipairs(getPlayersOnline()) do
  41. doCreatureSay(cid, K[cid], TALKTYPE_BROADCAST, false, pid)
  42. end
  43. selfSay('Your message has been broadcasted.', cid)
  44. else
  45. selfSay('Come back when you\'ve got enough money!', cid)
  46. end
  47. K[cid] = nil
  48. end
  49. return true
  50. end
  51.  
  52. npcHandler:setCallback(CALLBACK_GREET, greetCallback)
  53. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  54. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement