Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4.  
  5. local Topic = {}
  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. function thinkCallback(cid)
  13.     if math.random(300) == 1 then
  14.         npcHandler:say("Leave this island by speaking to me!")
  15.     end
  16.    
  17.     return true
  18. end
  19.  
  20. function creatureSayCallback(cid, type, msg)
  21.     if (msgcontains(msg, "hello") or msgcontains(msg, "hi")) and (not npcHandler:isFocused(cid)) then
  22.         npcHandler:say(getPlayerSex(cid) == 0 and "Well hello there, lovely lady! Are you ready to leave this island? {Yes} or {No}." or "Hello there, are you ready to leave this island? {Yes} or {No}.", cid)
  23.         Topic[cid] = 1
  24.         npcHandler:addFocus(cid)
  25.     elseif(not npcHandler:isFocused(cid)) then
  26.         return false
  27.     elseif msgcontains(msg, "bye") or msgcontains(msg, "farewell") and npcHandler:isFocused(cid) then
  28.         npcHandler:say("Good bye.", cid, TRUE)
  29.         Topic[cid] = nil
  30.         npcHandler:releaseFocus(cid)
  31.     elseif Topic[cid] == 1 then
  32.         if msgcontains(msg, "yes") then
  33.             npcHandler:say("Set the sails!", cid)
  34.             doTeleportThing(cid, {x = 100, y = 100, z = 7}, true)
  35.             Topic[cid] = 0
  36.         elseif msgcontains(msg, "no") then
  37.             npcHandler:say("Then not.", cid)
  38.             Topic[cid] = 0
  39.         end
  40.     end
  41.    
  42.     return true
  43. end
  44.  
  45. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  46. npcHandler:setMessage(MESSAGE_WALKAWAY, "How rude!")
  47. npcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement