Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local config = {
- method = 'all', -- single, all, near
- loot = {
- [3031] = 1 -- backpack index, slot type, ground, use
- }
- }
- local lastTarget = 0
- local targets = {}
- local que = {}
- local function checkForNewTarget()
- local target = Self.TargetID()
- if (target > 0) then
- local creature = Creature.GetByID(target)
- if (creature:isValid()) and creature:ID() ~= Self.ID() then
- if (creature:isOnScreen() and creature:isVisible() and creature:isAlive() and not creature:isPlayer()) then
- targets[creature:ID()] = creature:Position()
- lastTarget = target
- end
- end
- end
- end
- local function checkForDeadTargets()
- for cid, pos in pairs(targets)do
- local creature = Creature.GetByID(cid)
- if (not creature:isValid()) then -- target is gone?
- targets[cid] = nil
- elseif (not creature:isAlive()) and (Self.DistanceFromPosition(pos.x, pos.y, pos.z) <= 7) then -- target died?
- que[cid] = pos -- add to loot que
- targets[cid] = nil -- delete from target list
- end
- end
- end
- local function lootTargets()
- wait(700, 900) -- incase one just died
- for cid, pos in pairs(que)do
- local tries = 5
- local corpse = 0
- repeat
- corpse = Self.UseItemFromGround(pos.x, pos.y, pos.z)
- wait(1500)
- tries = tries - 1
- print("attempts left: " .. tries)
- until (corpse > 0) or (tries <= 0)
- que[cid] = nil
- print(corpse)
- end
- end
- while(true)do
- checkForNewTarget()
- checkForDeadTargets()
- if (#targets == 0) or (config.method ~= 'all') then
- print(#targets)
- lootTargets()
- end
- wait(100)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement