Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.46 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4. local talkState = {}
  5.  
  6. -- OTServ event handling functions start
  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 onPlayerEndTrade(cid) npcHandler:onPlayerEndTrade(cid) end
  13. function onPlayerCloseChannel(cid) npcHandler:onPlayerCloseChannel(cid) end
  14. -- OTServ event handling functions end
  15.  
  16.  
  17. function creatureSayCallback(cid, type, msg)
  18. if(not npcHandler:isFocused(cid)) then
  19. return false
  20. end
  21. local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  22.  
  23.  
  24. --------------------------------
  25. ------- NPC MISION 2.5 --------
  26. ---by Acubens, great scripter---
  27. -----modified by Ziggy46802-----
  28. -- Otland.net --
  29. --------------------------------
  30.  
  31. local first = {
  32. -- Place true if you want experience to be part of the quest reward, false if only an item. Place true if you want both
  33. useExpReward = true,
  34. -- The experience, if above is set to true, that the player will receive as a reward for the quest
  35. experience = 1500,
  36. -- Item ID of the "quest item", or the item that the npc takes from you for you to complete the quest
  37. item = 13240,
  38. -- Item ID of the second quest item, just leave alone if you only want one item
  39. itemtwo = 11193,
  40. -- The quanity, or how many, of the item needed to complete the quest
  41. item_count = 10,
  42. -- The quantity, or how many, of the second quest item needed to complete the quest
  43. itemtwo_count = 1,
  44. -- Item ID of the quest reward if the first option is set to false, but an item can be used with true for exp as reward as well
  45. reward = 11691,
  46. -- Item ID of the quest reward if the first option is set to false, this is the second item that can be "not used"
  47. rewardtwo = 2160,
  48. -- The quantity, or how many, of the quest reward that the player will receive for the second item upon completion of the quest, can be "not used"
  49. rewardtwo_count = 10,
  50. -- The quanity, or how many, of the quest reward that the player will receive upon completion of the quest
  51. reward_count = 1,
  52. -- The storage value that the quest will use (advised would be between 1000 and 10000)
  53. storage = 1003,
  54. --this is the value of the storage value above that is set when the quest is completed, most people use -1 (non existant) for starting the quest and 1 for ending, but I use 2
  55. last = 2,
  56. -- The name of the quest which will pop up upon completion of the quest as "You have completed the quest 'quest name'"
  57. questname = "Rat Extermination"
  58. }
  59.  
  60. local npc_message ={
  61.  
  62. --the number at the front just shows you what number message it is so when you see "npc_message[4]" in the script you know which line of code it refers to
  63.  
  64. -- 1Message asking if you have the required items, should be something like "Do you have the 10 antennas?" no highlighting is needed
  65. "Did you kill enough of them to collect 10 of their antennas?",
  66. -- 2if you dont have items - message
  67. "You dont have any items to this mission.",
  68. -- 3thanks - message
  69. "Thank You for Help me, {take it}.",
  70. -- 4Message that the npc says if you have already done the quest
  71. "Well the rats aren't as bad anymore, thanks to you that is.",
  72. -- 5First message for the quest, should be like "Please go collect 10 chicken feathers for me" and do {} around a word like I did, antennas
  73. "We have a real bad rat problem here in Granitewood. If you kill some of them and collect 10 of their {antennas} then I might give up one of my products for free just for you.",
  74. -- 6Message given upon completion of the quest, the npc does not say it, it is another type of text
  75. "Congratulations, you have finished the quest "..first.questname..""
  76.  
  77. }
  78.  
  79.  
  80. if(msgcontains(msg, 'rat')) then --the first keyword, should be a word that the xml file for the npc says to you upon greeting
  81. selfSay(npc_message[5], cid)
  82. end
  83.  
  84. if(msgcontains(msg, 'antennas')) then --the second keyword, should be the {highlighted} word from the "5First message"
  85. selfSay(npc_message[1], cid)
  86. talkState[talkUser] = 1
  87. elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then --this is just saying what happens if you say yes to the "do you have the items" message
  88. if (getPlayerStorageValue(cid,first.storage) == first.last) then --this is checking if you have already done the quest, if you want it repeatable, then set first.last to something like 100, so that it will "never" be done basically, but only set it to 100 on this line, not in the config, make sure it and first.last are different if you want it repeatable
  89. selfSay(npc_message[4], cid)
  90. else
  91. if(doPlayerRemoveItem(cid,first.item,first.item_count)) --you don't need to edit this, it pulls the item required for the quest from the config at the start
  92. and --remove the commenting dashes at the front of this line if you want multiple items for the items required for the quest, or you can use or instead of and if you want the person to be able to turn in one or the other item to complete the quest
  93. (doPlayerRemoveItem(cid,first.itemtwo,first.itemtwo_count)) --remove the commenting dashes at the front of this line if you want two items
  94. then
  95. setPlayerStorageValue(cid,first.storage,first.last) --this sets the storage value so that the quest is "done" and can not be done again
  96. if(useExpReward) then
  97. doPlayerAddExperience(cid,first.experience)
  98. doPlayerAddItem(cid,first.reward,first.reward_count) --comment this line if you want true as exp as reward and only exp as the reward, no item included too
  99. else
  100. doPlayerAddItem(cid,first.reward,first.reward_count) --if useExpReward was set to false, these are the items that the player receives
  101. doPlayerAddItem(cid,first.rewardtwo,first.rewardtwo_count) --comment this line if you only want one item as a reward
  102. end
  103. selfSay(npc_message[3], cid) --this is all the completion of the quest and the thank you and the "you completed quest blah" stuff
  104. doSendMagicEffect(getCreaturePosition(cid), 10)
  105. doCreatureSay(cid, npc_message[6], TALKTYPE_ORANGE_1)
  106. else
  107. selfSay(npc_message[2], cid) --this is the message you get if you don't have the items required for the quest
  108. end
  109. end
  110. return true
  111. end
  112.  
  113. end
  114.  
  115.  
  116.  
  117. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  118. npcHandler:addModule(FocusModule:new())
  119. local shopModule = ShopModule:new() --comment this line if you do not want a shop
  120. npcHandler:addModule(shopModule) --comment this line if you do not want a shop
  121.  
  122. -------------------For sale-------------------
  123. --1
  124. shopModule:addBuyableItem({'bandana'}, 5917, 600, 'bandana')
  125.  
  126. -------------------Sell to him-------------------
  127.  
  128. --1
  129. shopModule:addSellableItem({'bandana'}, 5917, 150,'bandana')
  130.  
  131.  
  132. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  133. npcHandler:addModule(FocusModule:new()) --comment this line if you do not want a shop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement