SHARE
TWEET

Untitled

a guest Feb 16th, 2020 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ---------------------------------------------- creaturescritps.xml
  2.  
  3.     <event type="kill" name="Tasks2" script="killtasks2.lua"/>
  4.  
  5.  
  6. ---------------------------------------------- login.lua
  7.  
  8.     player:registerEvent("Tasks2")
  9.  
  10.  
  11. ---------------------------------------------- killtask2.lua
  12.  
  13. local config = {
  14.  
  15.     ['troll'] = {amount = 50, storage = 18000, startstorage = 6110, startvalue = 1},
  16.  
  17.     ['rotworm'] = {amount = 100, storage = 18001, startstorage = 6111, startvalue = 1},
  18.  
  19.     ['tortoise'] = {amount = 200, storage = 18002, startstorage = 6112, startvalue = 1},
  20.  
  21.     ['cyclops'] = {amount = 100, storage = 18003, startstorage = 6113, startvalue = 1},
  22.  
  23.     ['amazon'] = {amount = 100, storage = 18004, startstorage = 6114, startvalue = 1},
  24.  
  25.     ['valkyrie'] = {amount = 100, storage = 18005, startstorage = 6115, startvalue = 1},
  26.  
  27.     ['tarantula'] = {amount = 150, storage = 18006, startstorage = 6116, startvalue = 1},
  28.  
  29.     ['scarab'] = {amount = 150, storage = 18007, startstorage = 6117, startvalue = 1},
  30.  
  31.     ['slime'] = {amount = 50, storage = 18008, startstorage = 6118, startvalue = 1},
  32.  
  33.     ['ice golem'] = {amount = 50, storage = 18009, startstorage = 6119, startvalue = 1},
  34.  
  35.     ['mammoth'] = {amount = 50, storage = 18010, startstorage = 6120, startvalue = 1},
  36.  
  37.     ['fire elemental'] = {amount = 50, storage = 18011, startstorage = 6121, startvalue = 1},
  38.  
  39.     ['demon skeleton'] = {amount = 100, storage = 18012, startstorage = 6122, startvalue = 1},
  40.  
  41.     ['crypt shambler'] = {amount = 100, storage = 18013, startstorage = 6123, startvalue = 1},
  42.  
  43.     ['mummy'] = {amount = 100, storage = 18014, startstorage = 6124, startvalue = 1},
  44.  
  45.     ['kongra'] = {amount = 100, storage = 18015, startstorage = 6125, startvalue = 1},
  46.  
  47.     ['wyvern'] = {amount = 100, storage = 18016, startstorage = 6126, startvalue = 1},
  48.  
  49.     ['orc leader'] = {amount = 100, storage = 18017, startstorage = 6127, startvalue = 1},
  50.  
  51.     ['ancient scarab'] = {amount = 200, storage = 18018, startstorage = 6128, startvalue = 1},
  52.  
  53.     ['banshee'] = {amount = 50, storage = 18019, startstorage = 6129, startvalue = 1},
  54.  
  55.     ['hero'] = {amount = 200, storage = 18020, startstorage = 6130, startvalue = 1},
  56.  
  57.     ['dragon'] = {amount = 200, storage = 18021, startstorage = 6131, startvalue = 1},
  58.  
  59.     ['dragon lord'] = {amount = 100, storage = 18022, startstorage = 6132, startvalue = 1},
  60.  
  61.     ['frost dragon'] = {amount = 200, storage = 18023, startstorage = 6133, startvalue = 1},
  62.  
  63.     ['warlock'] = {amount = 200, storage = 18024, startstorage = 6134, startvalue = 1},
  64.  
  65.     ['hydra'] = {amount = 150, storage = 18025, startstorage = 6135, startvalue = 1},
  66.  
  67.     ['demon'] = {amount = 150, storage = 18026, startstorage = 6136, startvalue = 1},
  68.  
  69.     ['necromancer'] = {amount = 200, storage = 18027, startstorage = 6137, startvalue = 1},
  70.  
  71.     ['vampire'] = {amount = 150, storage = 18028, startstorage = 6138, startvalue = 1},
  72.  
  73.     ['serpent spawn'] = {amount = 200, storage = 18029, startstorage = 6139, startvalue = 1},
  74.  
  75.     ['thornback tortoise'] = {amount = 200, storage = 18030, startstorage = 6140, startvalue = 1},
  76.  
  77.     ['plaguesmith'] = {amount = 200, storage = 18031, startstorage = 6141, startvalue = 1},
  78.  
  79.     ['dark torturer'] = {amount = 200, storage = 18032, startstorage = 6142, startvalue = 1},
  80.  
  81.     ['nightmare'] = {amount = 300, storage = 18033, startstorage = 6143, startvalue = 1},
  82.  
  83.     ['ghoul'] = {amount = 10, storage = 18034, startstorage = 6144, startvalue = 1},
  84.  
  85.     ['bonebeast'] = {amount = 200, storage = 18035, startstorage = 6145, startvalue = 1}
  86.  
  87.  
  88. }
  89.  
  90.  
  91.  
  92. function onKill(player, target)
  93.  
  94.     local monster = config[target:getName():lower()]
  95.  
  96.     if target:isPlayer() or not monster or target:getMaster() then
  97.  
  98.         return true
  99.  
  100.     end
  101.  
  102.     local stor = player:getStorageValue(monster.storage)+1
  103.  
  104.     if stor < monster.amount and player:getStorageValue(monster.startstorage) >= monster.startvalue then
  105.  
  106.         player:setStorageValue(monster.storage, stor)
  107.  
  108.         player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(stor +1)..' of '..monster.amount..' '..target:getName()..'s killed.')
  109.  
  110.     end
  111.  
  112.     if (stor +1) == monster.amount then
  113.  
  114.         player:sendTextMessage(MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(stor +1)..' '..target:getName()..'s and completed the '..target:getName()..'s mission.')
  115.  
  116.         player:setStorageValue(monster.storage, stor +1)
  117.  
  118.     end
  119.  
  120.     return true
  121.  
  122. end
  123.  
  124.  
  125. ---------------------------------------------- Grizzly Adams.xml
  126.  
  127. <?xml version="1.0" encoding="UTF-8"?>
  128.  
  129. <npc name="Grizzly Adams" script="tasks2.lua" walkinterval="2000" floorchange="0">
  130.  
  131.     <health now="100" max="100" />
  132.  
  133.     <look type="144" head="44" body="41" legs="86" feet="48" addons="3" />
  134.  
  135. </npc>
  136.  
  137.  
  138. ---------------------------------------------- tasks2.lua
  139.  
  140. -- Monster Tasks by Limos
  141.  
  142. local keywordHandler = KeywordHandler:new()
  143.  
  144. local npcHandler = NpcHandler:new(keywordHandler)
  145.  
  146. NpcSystem.parseParameters(npcHandler)
  147.  
  148. local xmsg = {}
  149.  
  150.  
  151.  
  152. function onCreatureAppear(cid)  npcHandler:onCreatureAppear(cid)  end
  153.  
  154. function onCreatureDisappear(cid)  npcHandler:onCreatureDisappear(cid)  end
  155.  
  156. function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg)  end
  157.  
  158. function onThink()  npcHandler:onThink()  end
  159.  
  160.  
  161.  
  162. local storage = 62003
  163.  
  164.  
  165.  
  166. local monsters = {
  167.  
  168.    ["Trolls"] = {storage = 6110, mstorage = 18000, amount = 50, exp = 2500, items = {{id = 2152, count = 25}}},
  169.  
  170.    ["Rotworms"] = {storage = 6111, mstorage = 18001, amount = 100, exp = 8000, items = {{id = 2152, count = 60}}},
  171.  
  172.    ["Tortoises"] = {storage = 6112, mstorage = 18002, amount = 200, exp = 30000, items = {{id = 2152, count = 70}}},
  173.  
  174.    ["Cyclops"] = {storage = 6113, mstorage = 18003, amount = 100, exp = 25000, items = {{id = 2160, count = 1}}},
  175.  
  176.    ["Amazons"] = {storage = 6114, mstorage = 18004, amount = 100, exp = 15000, items = {{id = 2160, count = 1}}},
  177.  
  178.    ["Valkyries"] = {storage = 6115, mstorage = 18005, amount = 100, exp = 20000, items = {{id = 2160, count = 1}}},
  179.  
  180.    ["Tarantulas"] = {storage = 6116, mstorage = 18006, amount = 150, exp = 40000, items = {{id = 2160, count = 1}, {id = 2152, count = 60}}},
  181.  
  182.    ["Scarabs"] = {storage = 6117, mstorage = 18007, amount = 150, exp = 45000, items = {{id = 2160, count = 1}, {id = 2152, count = 50}}},
  183.  
  184.    ["Slimes"] = {storage = 6118, mstorage = 18008, amount = 50, exp = 12000, items = {{id = 2152, count = 50}}},
  185.  
  186.    ["Ice Golems"] = {storage = 6119, mstorage = 18009, amount = 50, exp = 30000, items = {{id = 2152, count = 80}}},
  187.  
  188.    ["Mammoths"] = {storage = 6120, mstorage = 18010, amount = 50, exp = 12000, items = {{id = 2152, count = 70}}},
  189.  
  190.    ["Fire Elementals"] = {storage = 6121, mstorage = 18011, amount = 50, exp = 25000, items = {{id = 2160, count = 1}}},
  191.  
  192.    ["Demon Skeletons"] = {storage = 6122, mstorage = 18012, amount = 100, exp = 50000, items = {{id = 2160, count = 2}}},
  193.  
  194.    ["Crypt Shamblers"] = {storage = 6123, mstorage = 18013, amount = 100, exp = 40000, items = {{id = 2160, count = 1}}},
  195.  
  196.    ["Mummys"] = {storage = 6124, mstorage = 18014, amount = 100, exp = 35000, items = {{id = 2160, count = 1}}},
  197.  
  198.    ["Kongras"] = {storage = 6125, mstorage = 18015, amount = 100, exp = 30000, items = {{id = 2160, count = 1}}},
  199.  
  200.    ["Wyverns"] = {storage = 6126, mstorage = 18016, amount = 100, exp = 120000, items = {{id = 2160, count = 2}}},
  201.  
  202.    ["Orc Leaders"] = {storage = 6127, mstorage = 18017, amount = 150, exp = 80000, items = {{id = 2160, count = 1}}},
  203.  
  204.    ["Ancient Scarabs"] = {storage = 6128, mstorage = 18018, amount = 200, exp = 250000, items = {{id = 2160, count = 3}}},
  205.  
  206.    ["Banshees"] = {storage = 6129, mstorage = 18019, amount = 50, exp = 100000, items = {{id = 2160, count = 3}}},
  207.  
  208.    ["Heros"] = {storage = 6130, mstorage = 18020, amount = 200, exp = 500000, items = {{id = 2160, count = 4}}},
  209.  
  210.    ["Dragons"] = {storage = 6131, mstorage = 18021, amount = 200, exp = 300000, items = {{id = 2160, count = 3}}},
  211.  
  212.    ["Dragon Lords"] = {storage = 6132, mstorage = 18022, amount = 100, exp = 450000, items = {{id = 2160, count = 6}}},
  213.  
  214.    ["Frost Dragons"] = {storage = 6133, mstorage = 18023, amount = 200, exp = 900000, items = {{id = 2160, count = 9}}},
  215.  
  216.    ["Warlocks"] = {storage = 6134, mstorage = 18024, amount = 200, exp = 1500000, items = {{id = 2160, count = 15}}},
  217.  
  218.    ["Hydras"] = {storage = 6135, mstorage = 18025, amount = 150, exp = 700000, items = {{id = 2160, count = 7}}},
  219.  
  220.    ["Demons"] = {storage = 6136, mstorage = 18026, amount = 150, exp = 2000000, items = {{id = 2160, count = 15}}},
  221.  
  222.    ["Necromancers"] = {storage = 6137, mstorage = 18027, amount = 200, exp = 250000, items = {{id = 2160, count = 4}}},
  223.  
  224.    ["Vampires"] = {storage = 6138, mstorage = 18028, amount = 150, exp = 100000, items = {{id = 2160, count = 3}}},
  225.  
  226.    ["Serpent Spawns"] = {storage = 6139, mstorage = 18029, amount = 200, exp = 1000000, items = {{id = 2160, count = 10}}},
  227.  
  228.    ["Thornback Tortoises"] = {storage = 6140, mstorage = 18030, amount = 200, exp = 80000, items = {{id = 2160, count = 2}}},
  229.  
  230.    ["Plaguesmith"] = {storage = 6141, mstorage = 18031, amount = 200, exp = 2300000, items = {{id = 2160, count = 15}}},
  231.  
  232.    ["Dark Torturer"] = {storage = 6142, mstorage = 18032, amount = 200, exp = 2100000, items = {{id = 2160, count = 15}}},
  233.  
  234.    ["Nightmare"] = {storage = 6143, mstorage = 18033, amount = 300, exp = 1000000, items = {{id = 2160, count = 12}}},
  235.  
  236.    ["Ghoul"] = {storage = 6144, mstorage = 18034, amount = 100, exp = 18000, items = {{id = 2160, count = 1}}},
  237.  
  238.    ["Bonebeast"] = {storage = 6145, mstorage = 18035, amount = 200, exp = 340000, items = {{id = 2160, count = 4}}}
  239.  
  240. }
  241.  
  242. local function getItemsFromTable(itemtable)
  243.  
  244.      local text = ""
  245.  
  246.      for v = 1, #itemtable do
  247.  
  248.          count, info = itemtable[v].count, ItemType(itemtable[v].id)
  249.  
  250.          local ret = ", "
  251.  
  252.          if v == 1 then
  253.  
  254.              ret = ""
  255.  
  256.          elseif v == #itemtable then
  257.  
  258.              ret = " and "
  259.  
  260.          end
  261.  
  262.          text = text .. ret
  263.  
  264.          text = text .. (count > 1 and count or info:getArticle()).." "..(count > 1 and info:getPluralName() or info:getName())
  265.  
  266.      end
  267.  
  268.      return text
  269.  
  270. end
  271.  
  272.  
  273.  
  274. local function Cptl(f, r)
  275.  
  276.      return f:upper()..r:lower()
  277.  
  278. end
  279.  
  280.  
  281.  
  282. function creatureSayCallback(cid, type, msg)
  283.  
  284.  
  285.  
  286.      local player, cmsg = Player(cid), msg:gsub("(%a)([%w_']*)", Cptl)
  287.  
  288.      if not npcHandler:isFocused(cid) then
  289.  
  290.          if msg == "hi" or msg == "hello" then
  291.  
  292.              npcHandler:addFocus(cid)
  293.  
  294.              if player:getStorageValue(storage) <= 1 then
  295.  
  296.                  local text, n = "",  0
  297.  
  298.                  for k, x in pairs(monsters) do
  299.  
  300.                      if player:getStorageValue(x.mstorage) < x.amount then
  301.  
  302.                          n = n + 1
  303.  
  304.                          text = text .. ", "
  305.  
  306.                          text = text .. ""..x.amount.." {"..k.."}"
  307.  
  308.                      end
  309.  
  310.                  end
  311.  
  312.                  if n > 1 then
  313.  
  314.                      npcHandler:say("I have several tasks for you to kill monsters. I can show you a [task] with rewards to let you choose the task that you want and you can [cancel] a task if you want. Say [report] if u finished task.", cid)
  315.  
  316.                      npcHandler.topic[cid] = 1
  317.  
  318.                      xmsg[cid] = msg
  319.  
  320.                  elseif n == 1 then
  321.  
  322.                      npcHandler:say("I have one last task for you"..text..".", cid)
  323.  
  324.                      npcHandler.topic[cid] = 1
  325.  
  326.                  else
  327.  
  328.                      npcHandler:say("You already did all tasks, I have nothing for you to do anymore, good job though.", cid)
  329.  
  330.                  end
  331.  
  332.              elseif player:getStorageValue(storage) > 1 then
  333. print("tasks.lua")
  334. print(storage)
  335.                  for k, x in pairs(monsters) do
  336. print(x.storage)
  337.                      if player:getStorageValue(storage) == x.storage then
  338.  
  339.                          npcHandler:say("Did you kill? If yes say [report] "..x.amount.." "..k.."? ("..#monsters..")", cid)
  340.  
  341.                          npcHandler.topic[cid] = 2
  342.  
  343.                          xmsg[cid] = k
  344.  
  345.                      end
  346.  
  347.                  end
  348.  
  349.              end
  350.  
  351.          else
  352.  
  353.              return false
  354.  
  355.          end
  356.  
  357.      elseif monsters[cmsg] and npcHandler.topic[cid] == 1 then
  358.  
  359.          if player:getStorageValue(monsters[cmsg].storage) == -1 then
  360.  
  361.              npcHandler:say("Good luck, come back when you killed "..monsters[cmsg].amount.." "..cmsg..".", cid)
  362.  
  363.              player:setStorageValue(storage, monsters[cmsg].storage)
  364.  
  365.              player:setStorageValue(monsters[cmsg].storage, 1)
  366.  
  367.          else
  368.  
  369.              npcHandler:say("You already did the mission.", cid)
  370.  
  371.          end
  372.  
  373.          npcHandler.topic[cid] = 0
  374.  
  375.      elseif msgcontains(msg, "report") and npcHandler.topic[cid] == 2 then
  376.  
  377.          local x = monsters[xmsg[cid]]
  378.  
  379.          if player:getStorageValue(x.mstorage) >= x.amount then
  380.  
  381.              npcHandler:say("Good job, here is your reward, "..getItemsFromTable(x.items)..".", cid)
  382.  
  383.              for g = 1, #x.items do
  384.  
  385.                  player:addItem(x.items[g].id, x.items[g].count)
  386.  
  387.              end
  388.  
  389.              player:addExperience(x.exp)
  390.  
  391.              player:setStorageValue(x.storage, 2)
  392.  
  393.              player:setStorageValue(storage, -1)
  394.  
  395.              npcHandler.topic[cid] = 3
  396.  
  397.          else
  398.  
  399.              npcHandler:say("You didn't kill them all, you still need to kill "..x.amount -(player:getStorageValue(x.mstorage) + 1).." "..xmsg[cid]..".", cid)
  400.  
  401.          end
  402.  
  403.      elseif msgcontains(msg, "task") and npcHandler.topic[cid] == 3 then
  404.  
  405.          local text, n = "",  0
  406.  
  407.          for k, x in pairs(monsters) do
  408.  
  409.              if player:getStorageValue(x.mstorage) < x.amount then
  410.  
  411.                  n = n + 1
  412.  
  413.                  text = text .. (n == 1 and "" or ", ")
  414.  
  415.                  text = text .. "{"..k.."}"
  416.  
  417.              end
  418.  
  419.          end
  420.  
  421.          if text ~= "" then
  422.         text = "Want to do another task? You can choose "..text.."."
  423.              --npcHandler:say("Want to do another task? You can choose "..text..".", cid)
  424.          player:showTextDialog(2175, text)
  425.              npcHandler.topic[cid] = 1
  426.  
  427.          else
  428.  
  429.              npcHandler:say("You already did all tasks.", cid)
  430.  
  431.          end
  432.  
  433.      elseif msgcontains(msg, "no") and npcHandler.topic[cid] == 1 then
  434.  
  435.          npcHandler:say("Ok then.", cid)
  436.  
  437.          npcHandler.topic[cid] = 0
  438.  
  439.      elseif msgcontains(msg, "cancel") then
  440.  
  441.          local text, n = "",  0
  442.  
  443.          for k, x in pairs(monsters) do
  444.  
  445.              if player:getStorageValue(x.mstorage) < x.amount then
  446.  
  447.                  n = n + 1
  448.  
  449.                  text = text .. (n == 1 and "" or ", ")
  450.  
  451.                  text = text .. "{"..k.."}"
  452.  
  453.                  if player:getStorageValue(x.storage) > 1 then
  454.  
  455.                       player:setStorageValue(x.storage, -1)
  456.  
  457.                  end
  458.  
  459.              end
  460.  
  461.          end
  462.  
  463.          if player:getStorageValue(storage) > 1 then
  464.  
  465.              npcHandler:say("Alright, let me know if you want to continue an other task, you can still choose", cid)
  466.          local tmp = player:getStorageValue(storage)
  467.         player:setStorageValue(tmp, -1)
  468.  
  469.          else
  470.  
  471.              npcHandler:say("You didn't start any new task yet, if you want to start one, you can choose ", cid)
  472.  
  473.          end
  474.  
  475.          player:setStorageValue(storage, -1)
  476.  
  477.          npcHandler.topic[cid] = 1
  478.  
  479.      elseif msgcontains(msg, "task") then
  480.  
  481.          local text = "Tasks\n\n"
  482.  
  483.          for k, x in pairs(monsters) do
  484.  
  485.              if player:getStorageValue(x.mstorage) < x.amount then
  486.  
  487.                  text = text ..k .." ["..(player:getStorageValue(x.mstorage) + 1).."/"..x.amount.."]:\n  Rewards:\n  "..getItemsFromTable(x.items).."\n  "..x.exp.." experience \n\n"
  488.  
  489.              else
  490.  
  491.                  text = text .. k .." [DONE]\n"
  492.  
  493.              end
  494.  
  495.          end
  496.  
  497.          player:showTextDialog(2175, "" .. text)
  498. --player:showTextDialog(item:getId(), text)
  499.          npcHandler:say("Here you are.", cid)
  500.  
  501.      elseif msgcontains(msg, "bye") then
  502.  
  503.          npcHandler:say("Bye.", cid)
  504.  
  505.          npcHandler:releaseFocus(cid)
  506.  
  507.      else
  508.  
  509.          npcHandler:say("What?", cid)
  510.  
  511.      end
  512.  
  513.      return true
  514.  
  515. end
  516.  
  517.  
  518.  
  519. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top