Skymagnum

Untitled

May 15th, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.33 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4. local talkState = {}
  5.  
  6. function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
  7. function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
  8. function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
  9. function onThink() npcHandler:onThink() end
  10.  
  11. function creatureSayCallback(cid, type, msg)
  12.  
  13.     if(not npcHandler:isFocused(cid)) then
  14.         return false
  15.     end
  16.  
  17. local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  18.  
  19.     local markPos = {x = 0, y = 0, z = 7}
  20.     local desc = "DESCRIPTION"
  21.  
  22.     if msgcontains(msg, 'hi') then
  23.         selfSay('Olá, você quer marcar o seu mapa, fale {marcar} ou {nao}', cid)
  24.         talkState[talkUser] = 2
  25.     elseif msgcontains(msg, 'marcar') and talkState[talkUser] == 2 then
  26.         selfSay('Pronto, mapa marcado', cid)
  27.         doPlayerAddMapMark(cid, markPos, 4, desc)
  28.         talkState[talkUser] = 0
  29.     elseif msgcontains(msg, "nao") and talkState[talkUser] == 2 then
  30.         selfSay('Ok, então.', cid)
  31.         talkState[talkUser] = 0
  32.     end
  33.  
  34.     return true
  35. end
  36.  
  37. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  38. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment