Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4. local talkState = {}
  5. function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
  6. function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
  7. function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
  8. function onThink() npcHandler:onThink() end
  9. function creatureSayCallback(cid, type, msg)
  10. local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  11. --[[
  12. REMEMBER TO SET YOUR STORAGE AS YOURSTORAGE!
  13. ]]--
  14. local storage = 98238
  15. if(msgcontains(msg, 'piece of draconian steel') or msgcontains(msg, 'obsidian knife')) then
  16. if(getPlayerStorageValue(cid, storage) < 1) then
  17. npcHandler:say("You bringing me draconian steel and obsidian lance in exchange for obsidian knife?", cid)
  18. setPlayerStorageValue(cid, storage, 1)
  19. elseif(getPlayerStorageValue(cid, storage) == 1) then
  20. npcHandler:say("Did you bring me the draconian steel and obsidian lance in exchange for obsidian knife?", cid)
  21. talkState[talkUser] = 1
  22. elseif(getPlayerStorageValue(cid, storage) == 2) then
  23. npcHandler:say("Sorry no more trade with you.", cid)
  24. end
  25. elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
  26. if doPlayerRemoveItem(cid,2425,1) and doPlayerRemoveItem(cid,5889,1) and getPlayerStorageValue(cid, storage) == 1 then
  27. npcHandler:say("Here you have it.", cid)
  28. doPlayerAddItem(cid, 5908, 1)
  29. setPlayerStorageValue(cid, storage, 2)
  30. talkState[talkUser] = 0
  31. else
  32. npcHandler:say("You don't have the neccesary items.", cid)
  33. talkState[talkUser] = 0
  34. end
  35. elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then
  36. npcHandler:say("Then not.", cid)
  37. talkState[talkUser] = 0
  38. end
  39. return TRUE
  40. end
  41. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  42. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement