Facebook
From Harmless Pheasant, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 175
  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.     if not isPlayer(cid) then
  5.         return true
  6.     end
  7.  
  8.     -- Sprawdzanie czy `target` jest graczem, security check
  9.     if isPlayer(target) then
  10.         return true
  11.     end
  12.    
  13.     local startedTasks = getPlayerStartedTasks(cid)
  14.     local monsterName = getCreatureName(target):lower()
  15.     for taskmonster, task_id in ipairs(startedTasks) do
  16.         if(startedTasks and #startedTasks > 0) then
  17.             local currentTask = tasks[task_id]
  18.             if isInArray(currentTask.creatures, monsterName) then
  19.                 local status = KILLSSTORAGE_BASE + task_id
  20.                 if(getPlayerStorageValue(cid, status) < 0) then
  21.                     setPlayerStorageValue(cid, status, 0)
  22.                 end
  23.                 local killsCount = getPlayerStorageValue(cid, status)
  24.  
  25.                -- Dla solo
  26.                 if killsCount < currentTask.killsRequired then
  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.                     local party = getPartyMembers(cid)
  34.                     -- Dla Party
  35.                     if party then
  36.                         for it, member in ipairs(party) do
  37.                             local member_status = getPlayerStorageValue(member, status)
  38.                             -- isPartySharedExperienceActive(member) // canUseSharedExperience
  39.                             if (not member == cid) and (member and canUseSharedExperience(member)) then -- Musi być share włączone, żeby zaliczało task.
  40.                             if member_status < currentTask.killsRequired then
  41.                                     setPlayerStorageValue(member, status, killsCount + 1)
  42.                                     doPlayerSendTextMessage(member, MESSAGE_STATUS_CONSOLE_BLUE, "You killed " ..(killsCount+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 " ..(killsCount+1).. " of " .. currentTask.killsRequired .. "). Go back to Grizzly Adams and report it to get reward!")
  45.                                 end
  46.                             end
  47.                             end
  48.                             break
  49.                         end
  50.                     end
  51.                 end
  52.             end
  53.         end
  54.     end
  55.  
  56.     return true
  57. end