adrianoswatt

Swatt TaskSystem CreatureScripts

Apr 1st, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.27 KB | None | 0 0
  1. function onKill(cid, target, lastHit)
  2.     if(isPlayer(target)) then
  3.         return true
  4.     end
  5.     local inTask = checkPlayerIsInTask(cid)
  6.     if #inTask >= 1 then
  7.         local task = _MONSTERS_TASK_SYSTEM_CONFIG
  8.         getCName = getCreatureName(target):lower()
  9.         check = checkAlreadyDoingThisTask(cid, getCName, inTask)
  10.         if check then -- Return Monster Name if Can Do, or false if can't
  11.             getTask = task[check]
  12.             if getTask then
  13.                 if getTask.inDay ~= false then
  14.                     b = getInfoPlayerTask(cid, getCName)
  15.                     data = tonumber(b[2])
  16.                     now = os.time()
  17.                     a = {sto = getTask.storage, killeds = getTask.countSto, total = getTask.count, timeToDo = getTask.inDay}
  18.                     getKills = getPlayerStorageValue(cid, a.killeds)
  19.                     if not isNumber(getKills) or getKills == nil then
  20.                         getKills = 1
  21.                         print('The '..getTask.mlist[1]..' task have some error with player '..getCreatureName(cid)..' and was FIXED Automatically by Swatt Script, please check is out.')
  22.                     end
  23.                     doneMsg = "Congratulations, you have killed "..a.total.." "..getTask.mlist[1]..", go to NPC of Task for get yours awards."
  24.                     closedMsg = "Sorry, but your "..getTask.mlist[1].." task was closed in "..os.date("%b %d, %Y at %X", data).."."
  25.                     if now < data then
  26.                         if getKills < a.total then
  27.                             calc = (getKills+1)
  28.                             setPlayerStorageValue(cid, a.killeds, tonumber(calc))
  29.                             if (getKills+1) < a.total then
  30.                                 if a.timeToDo then
  31.                                     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have killed " .. getPlayerStorageValue(cid, a.killeds) .. " of "..a.total.." "..getTask.mlist[1]..", you have untill "..os.date("%b %d, %Y at %X", data).." to complete this task.")
  32.                                 else
  33.                                     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have killed " .. getPlayerStorageValue(cid, a.killeds) .. "/"..a.total.." "..getTask.mlist[1]..".")
  34.                                 end
  35.                             else
  36.                                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, doneMsg)
  37.                             end
  38.                         else
  39.                             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, doneMsg)
  40.                         end
  41.                     else
  42.                         doCloseTimedTask(cid, getCName)
  43.                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, closedMsg)
  44.                         return true
  45.                     end
  46.                 else
  47.                     a = {sto = getTask.storage, killeds = getTask.countSto, total = getTask.count}
  48.                     getKills = getPlayerStorageValue(cid, a.killeds)
  49.                     if not isNumber(getKills) or getKills == nil then
  50.                         getKills = 1
  51.                         print('The '..getTask.mlist[1]..' task have some error with player '..getCreatureName(cid)..' and was FIXED Automatically by Swatt Script, please check is out.')
  52.                     end
  53.                     doneMsg = "Congratulations, you have killed "..a.total.." "..getTask.mlist[1]..", go to NPC of Task for get yours awards."
  54.                     if getKills < a.total then
  55.                         calc = (getKills+1)
  56.                         setPlayerStorageValue(cid, a.killeds, tonumber(calc))
  57.                         if (getKills+1) < a.total then
  58.                             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have killed " .. getPlayerStorageValue(cid, a.killeds) .. "/"..a.total.." "..getTask.mlist[1]..".")
  59.                         else
  60.                             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, doneMsg)
  61.                         end
  62.                     else
  63.                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, doneMsg)
  64.                     end
  65.                 end
  66.             end
  67.         end
  68.     end
  69. return TRUE
  70. end
Add Comment
Please, Sign In to add comment