Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 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. local storage = 5002
  12.  
  13. function creatureSayCallback(cid, type, msg)
  14. if not npcHandler:isFocused(cid) then
  15. return false
  16. end
  17. local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  18.  
  19. if msgcontains(msg, "mission") then
  20. if getPlayerStorageValue(cid, storage) == -1 then
  21. selfSay("I have a mission for you to kill 5 dragons and 3 dragon lords, do you accept?", cid)
  22. talkState[talkUser] = 1
  23. elseif getPlayerStorageValue(cid, storage) == 1 then
  24. selfSay("Did you kill 5 dragons and 3 dragon lords?", cid)
  25. talkState[talkUser] = 1
  26. else
  27. selfSay("You already did the mission.", cid)
  28. end
  29. elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
  30. if getPlayerStorageValue(cid, storage) == -1 then
  31. selfSay("Good, come back when you killed them.", cid)
  32. setPlayerStorageValue(cid, storage, 1)
  33. else
  34. if getPlayerStorageValue(cid, 19000) == 5 and getPlayerStorageValue(cid, 19001) == 3 then
  35. selfSay("Good job, here is your reward.", cid)
  36. doPlayerAddItem(cid, 2160, 5)
  37. doPlayerAddExp(cid, 50000)
  38. setPlayerStorageValue(cid, storage, 2)
  39. else
  40. selfSay("You didn't kill them all.", cid)
  41. end
  42. end
  43. talkState[talkUser] = 0
  44. elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
  45. selfSay("Ok then.", cid)
  46. talkState[talkUser] = 0
  47. end
  48. return true
  49. end
  50.  
  51. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  52. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement