• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved HELP script onkill open bags

gmstrikker

Well-Known Member
Joined
Jul 30, 2014
Messages
458
Solutions
1
Reaction score
50
So folks, I have a script that takes all the gold coins automatically, it is working, but only up to a point

He picks up the currencies of monsters to kill, but do not take coins inside the backpacks, for example if dropped 20 gold coins and a further 30 gold coins inside the monster backpack it does not catch

Anyone know how to fix this?


gp.lua
Code:
function autoloot(cid, position, corpseID)
  if not isPlayer(cid) then
  return
  end

  local corpse = getTileItemById(position, corpseID)
  if corpse and isContainer(corpse.uid) then
  local gold = 0
  for slot = (getContainerSize(corpse.uid) - 1), 0, -1 do
  local item = getContainerItem(corpse.uid, slot)
  local amount = (item.itemid == 2148 and item.type or (item.itemid == 2152 and item.type * 100 or (item.itemid == 2160 and item.type * 10000)) or 0)
  if item.uid > 0 then
  if amount > 0 then
  gold = gold + amount
  doRemoveItem(item.uid)
  end
  else
  break
  end
  end
  doPlayerAddMoney(cid, gold)
  end
end

function onKill(cid, target)
  if isPlayer(target) then
  return true
  end

  local position = getCreaturePosition(target)
  local info = getMonsterInfo(getCreatureName(target))
  addEvent(autoloot, 100, cid, position, info.lookCorpse)
  return true
end
 
Code:
local function doPlayerAddContainerMoney(cid, container, gold)
     local extrac = 0
     for slot = (getContainerSize(container) - 1), 0, -1 do
         local item = getContainerItem(container, slot)
         local amount = (item.itemid == 2148 and item.type or (item.itemid == 2152 and item.type * 100 or (item.itemid == 2160 and item.type * 10000)) or 0)
         if item.uid > 0 then
             if amount > 0 then
                 gold = gold + amount
                 doRemoveItem(item.uid)
             end
         end
         if isContainer(item.uid) then
             extrac = item.uid
         end
     end
     if extrac > 0 then
         doPlayerAddContainerMoney(cid, extrac, gold)
     else
         doPlayerAddMoney(cid, gold)
     end   
end
     
local function autoloot(cid, position, corpseID)
     if not isPlayer(cid) then
         return
     end

     local corpse = getTileItemById(position, corpseID)
     if corpse and isContainer(corpse.uid) then
         doPlayerAddContainerMoney(cid, corpse.uid, 0)   
     end
end

function onKill(cid, target)
     if isPlayer(target) then
         return true
     end

     local position = getCreaturePosition(target)
     local info = getMonsterInfo(getCreatureName(target))
     addEvent(autoloot, 100, cid, position, info.lookCorpse)
     return true
end
 
Code:
local function doPlayerAddContainerMoney(cid, container, gold)
     local extrac = 0
     for slot = (getContainerSize(container) - 1), 0, -1 do
         local item = getContainerItem(container, slot)
         local amount = (item.itemid == 2148 and item.type or (item.itemid == 2152 and item.type * 100 or (item.itemid == 2160 and item.type * 10000)) or 0)
         if item.uid > 0 then
             if amount > 0 then
                 gold = gold + amount
                 doRemoveItem(item.uid)
             end
         end
         if isContainer(item.uid) then
             extrac = item.uid
         end
     end
     if extrac > 0 then
         doPlayerAddContainerMoney(cid, extrac, gold)
     else
         doPlayerAddMoney(cid, gold)
     end  
end
    
local function autoloot(cid, position, corpseID)
     if not isPlayer(cid) then
         return
     end

     local corpse = getTileItemById(position, corpseID)
     if corpse and isContainer(corpse.uid) then
         doPlayerAddContainerMoney(cid, corpse.uid, 0)  
     end
end

function onKill(cid, target)
     if isPlayer(target) then
         return true
     end

     local position = getCreaturePosition(target)
     local info = getMonsterInfo(getCreatureName(target))
     addEvent(autoloot, 100, cid, position, info.lookCorpse)
     return true
end

TYYYYYYYYY work, ur pro :D
 
Back
Top