Facebook
From Soft Crow, 4 Years ago, written in Lua.
Embed
Download Paste or View Raw
Hits: 200
  1. function onKill(cid, target, lastHit)
  2.  
  3.     -- Security check dla potworów, jeśli gdzieś są używane storage w potworach, żeby się nie gryzło z Task Systemem
  4.     local player = isPlayer(cid)
  5.     if not player or isPlayer(target) then
  6.         return true
  7.     end
  8.  
  9.     local startedTasks = getPlayerStartedTasks(cid)
  10.     local monsterName = getCreatureName(target):lower()
  11.  
  12.         for taskmonster, task_id in ipairs(startedTasks) do
  13.             if (startedTasks and #startedTasks > 0) then
  14.                 local currentTask = tasks[task_id]
  15.                 if isInArray(currentTask.creatures, monsterName) then
  16.  
  17.                     local status = KILLSSTORAGE_BASE + task_id
  18.                     local killsCount = getPlayerStorageValue(cid, status)
  19.  
  20.                     if killsCount < currentTask.killsRequired then
  21.                         if(getPlayerStorageValue(cid, status) < 0) then
  22.                             setPlayerStorageValue(cid, status, 0)
  23.                         end
  24.                        
  25.                         local party = getPartyMembers(cid)
  26.  
  27.                         setPlayerStorageValue(cid, status, killsCount + 1)
  28.                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You killed " ..(killsCount+1).. " of " .. currentTask.killsRequired .. " " .. currentTask.raceName .. " so far.")
  29.                         if killsCount == currentTask.killsRequired then
  30.                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulations! You completed " .. currentTask.raceName .. " task! (Killed " ..(killsCount+1).. " of " .. currentTask.killsRequired .. "). Go back to Grizzly Adams and report it to get reward!")
  31.                         end
  32.  
  33.                         if party then
  34.                             if cid then -- Anty Duplikat jebany
  35.                                 return true
  36.                             end
  37.                             for it, member in ipairs(party) do
  38.                                 if member then
  39.                                     local member_status = getPlayerStorageValue(member, status)
  40.                                     if member_status < currentTask.killsRequired then
  41.                                         setPlayerStorageValue(member, status, member_status + 1)
  42.                                         doPlayerSendTextMessage(member, MESSAGE_STATUS_CONSOLE_BLUE, "You killed " ..(member_status+1).. " of " .. currentTask.killsRequired .. " " .. currentTask.raceName .. " so far.")
  43.                                         if member_status == currentTask.killsRequired then
  44.                                         doPlayerSendTextMessage(member, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulations! You completed " .. currentTask.raceName .. " task! (Killed " ..(member_status+1).. " of " .. currentTask.killsRequired .. "). Go back to Grizzly Adams and report it to get reward!")
  45.                                         end
  46.                                     end
  47.                                 end
  48.                             end
  49.                         end
  50.                     end
  51.                 end
  52.             end
  53.         end
  54.     return true
  55. end