• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua 2 IFs to my auto gold

warriorfrog

Active Member
Joined
Jul 29, 2015
Messages
334
Reaction score
35
I have this auto gold loot, but i have 2 problems using this...

If you don't have slots free, money going to ground

If you don't have cap, money going to ground

How make this 2 checks to remove this problems?

Code:
<event type="kill" name="GP" event="script" value="gp.lua"/>

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
 
Send it to their bank instead.

Nah...

To remove cap problem i just removed on items.xml
Code:
<attribute key="weight" value="10" />

But to check slots i don't know have ideia...

Its can be a big problem..
Imagine 10 players botting with no slots... imagine how many golds will throed on ground

I need check it on script
 
Nah...

To remove cap problem i just removed on items.xml
Code:
<attribute key="weight" value="10" />

But to check slots i don't know have ideia...

Its can be a big problem..
Imagine 10 players botting with no slots... imagine how many golds will throed on ground

I need check it on script

Considering you are using TFS 1.2, you can use getPlayerFreeCap(cid) and ContainerGetEmptySlots().

I'll see if I can do it and post it.
 
Last edited:
Considering you are using TFS 1.2, you can use getPlayerFreeCap(cid) and ContainerGetEmptySlots().

I'll see if I can do it and post it.

I'm using 0.4 to check cap here i need use:
Code:
if getPlayerFreeCap(cid) < X then

But removing <attribute key="weight" value="10" />
My server is more light...

Now i just need fix this slots thing
 
I dont understand why you dont just send to bank like @Omni Cloud suggested?
Right?
If there is no capacity to the gold itself, why would you not send it to bank?

tabbed.
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
 
Right?
If there is no capacity to the gold itself, why would you not send it to bank?

tabbed.
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


To PK things... Ty

I tried this script but money still drop onfoot if have bp full :(
 
Back
Top