leandroluck
New Member
- Joined
- Dec 24, 2010
- Messages
- 104
- Reaction score
- 1
all the loot always goes to the main backpack would have to do for example choose the backpack by name or item goes to the backpack that already has the item
You are free to edit the code, however you wantall the loot always goes to the main backpack would have to do for example choose the backpack by name or item goes to the backpack that already has the item
I'm trying, it's not working.You are free to edit the code, however you want
I'm trying to get this to work. Copy/pasted everything in to their respective place but it wont work. I can get all commands etc to work (add,remove,show,clear) but the looting wont work.
post here man, other person can help too, if possibleHey @psychonaut i have sent a few feedback trough discord if you could take a look
local function scanContainer(cid, position)
local player = Player(cid)
if not player then
return
end
local corpse = Tile(position):getTopDownItem()
if not corpse or not corpse:isContainer() then
return
end
if corpse:getType():isCorpse() and corpse:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == cid then
for a = corpse:getSize() - 1, 0, -1 do
local containerItem = corpse:getItem(a)
if containerItem then
for b = AUTOLOOT_STORAGE_START, AUTOLOOT_STORAGE_END do
if player:getStorageValue(b) == containerItem:getId() then
containerItem:moveTo(player)
end
end
if player:isPremium() then
if isItemStackable(containerItem:getId()) then
if containerItem:getId() == 2148 then
containerItem:remove()
doPlayerSetBalance(player, (getPlayerBalance(player) + containerItem:getCount()) * 1.1)
end
if containerItem:getId() == 2152 then
containerItem:remove()
doPlayerSetBalance(player, (getPlayerBalance(player) + (containerItem:getCount() * 100) * 1.1))
end
if containerItem:getId() == 2160 then
containerItem:remove()
doPlayerSetBalance(player, (getPlayerBalance(player) + (containerItem:getCount() * 1000) * 1.1))
end
end
end
if not player:isPremium() then
if isItemStackable(containerItem:getId()) then
if containerItem:getId() == 2148 then
containerItem:remove()
doPlayerSetBalance(player, getPlayerBalance(player) + containerItem:getCount())
end
if containerItem:getId() == 2152 then
containerItem:remove()
doPlayerSetBalance(player, getPlayerBalance(player) + (containerItem:getCount() * 100))
end
if containerItem:getId() == 2160 then
containerItem:remove()
doPlayerSetBalance(player, getPlayerBalance(player) + (containerItem:getCount() * 1000))
end
end
end
end
end
end
end
function onKill(player, target)
if not target:isMonster() then
return true
end
addEvent(scanContainer, 100, player:getId(), target:getPosition())
return true
end
local function scanContainer(cid, position)
local player = Player(cid)
if not player then
return
end
local corpse = Tile(position):getTopDownItem()
if not corpse or not corpse:isContainer() then
return
end
if corpse:getType():isCorpse() and corpse:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == cid then
for a = corpse:getSize() - 1, 0, -1 do
local containerItem = corpse:getItem(a)
if containerItem then
for b = AUTOLOOT_STORAGE_START, AUTOLOOT_STORAGE_END do
if player:getStorageValue(b) == containerItem:getId() then
containerItem:moveTo(player)
end
end
if player:isPremium() then
if isItemStackable(containerItem:getId()) then
local g = containerItem:getCount()
local g2 = containerItem:getCount() * 1.1 / 10
local g3 = containerItem:getCount()
local g4 = (containerItem:getCount() * 100) * 1.1 / 10
local g5 = containerItem:getCount()
local g6 = (containerItem:getCount() * 1000) * 1.1 / 10
if containerItem:getId() == 2148 then
containerItem:remove()
doPlayerSetBalance(player, getPlayerBalance(player) + (containerItem:getCount() * 1.1))
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Gold Coins: "..g.."(+"..g2..").")
end
if containerItem:getId() == 2152 then
containerItem:remove()
doPlayerSetBalance(player, getPlayerBalance(player) + ((containerItem:getCount() * 100) * 1.1))
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Platinum Coins: "..g3.."(+"..g4.."Gold Coin).")
end
if containerItem:getId() == 2160 then
containerItem:remove()
doPlayerSetBalance(player, getPlayerBalance(player) + ((containerItem:getCount() * 1000) * 1.1))
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Crystal Coins: "..g5.."(+"..g6.."Gold Coin).")
end
end
end
if not player:isPremium() then
if isItemStackable(containerItem:getId()) then
if containerItem:getId() == 2148 then
containerItem:remove()
doPlayerSetBalance(player, getPlayerBalance(player) + containerItem:getCount())
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Gold Coins: "..g.."(+0).")
end
if containerItem:getId() == 2152 then
containerItem:remove()
doPlayerSetBalance(player, getPlayerBalance(player) + (containerItem:getCount() * 100))
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Platinum Coins: "..g3.."(+0).")
end
if containerItem:getId() == 2160 then
containerItem:remove()
doPlayerSetBalance(player, getPlayerBalance(player) + (containerItem:getCount() * 1000))
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Crystal Coins: "..g5.."(+0).")
end
end
end
end
end
end
end
function onKill(player, target)
if not target:isMonster() then
return true
end
addEvent(scanContainer, 100, player:getId(), target:getPosition())
return true
end
Hey @psychonaut i have sent a few feedback trough discord if you could take a look
SORRY WRONG SCRIPT Now is correct! i ADD MEssade LooT!
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
data/creaturescripts/scripts/autoloot.lua:57: attempt to concatenate global 'g' (a nil value)
stack traceback:
[C]: in function '__concat'
data/creaturescripts/scripts/autoloot.lua:57: in function <data/c
reaturescripts/scripts/autoloot.lua:1>
I have added a item which allows you to loot other items trough modal window, no commands.
Also I have added a option to loot automatically items which have a price over a established price.
All items are going to a loot bag:
My players are loving it. It took so much effort and a few money invest in order to make it perfect.
I leave this idea here cause someone else might need it.
PS: It works on client 10 and 11.
SORRY WRONG SCRIPT Now is correct! i ADD MEssade LooT!
Lua:local function scanContainer(cid, position) local player = Player(cid) if not player then return end local corpse = Tile(position):getTopDownItem() if not corpse or not corpse:isContainer() then return end if corpse:getType():isCorpse() and corpse:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == cid then for a = corpse:getSize() - 1, 0, -1 do local containerItem = corpse:getItem(a) if containerItem then for b = AUTOLOOT_STORAGE_START, AUTOLOOT_STORAGE_END do if player:getStorageValue(b) == containerItem:getId() then containerItem:moveTo(player) end end if player:isPremium() then if isItemStackable(containerItem:getId()) then local g = containerItem:getCount() local g2 = containerItem:getCount() * 1.1 / 10 local g3 = containerItem:getCount() local g4 = (containerItem:getCount() * 100) * 1.1 / 10 local g5 = containerItem:getCount() local g6 = (containerItem:getCount() * 1000) * 1.1 / 10 if containerItem:getId() == 2148 then containerItem:remove() doPlayerSetBalance(player, getPlayerBalance(player) + (containerItem:getCount() * 1.1)) player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Gold Coins: "..g.."(+"..g2..").") end if containerItem:getId() == 2152 then containerItem:remove() doPlayerSetBalance(player, getPlayerBalance(player) + ((containerItem:getCount() * 100) * 1.1)) player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Platinum Coins: "..g3.."(+"..g4.."Gold Coin).") end if containerItem:getId() == 2160 then containerItem:remove() doPlayerSetBalance(player, getPlayerBalance(player) + ((containerItem:getCount() * 1000) * 1.1)) player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Crystal Coins: "..g5.."(+"..g6.."Gold Coin).") end end end if not player:isPremium() then if isItemStackable(containerItem:getId()) then if containerItem:getId() == 2148 then containerItem:remove() doPlayerSetBalance(player, getPlayerBalance(player) + containerItem:getCount()) player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Gold Coins: "..g.."(+0).") end if containerItem:getId() == 2152 then containerItem:remove() doPlayerSetBalance(player, getPlayerBalance(player) + (containerItem:getCount() * 100)) player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Platinum Coins: "..g3.."(+0).") end if containerItem:getId() == 2160 then containerItem:remove() doPlayerSetBalance(player, getPlayerBalance(player) + (containerItem:getCount() * 1000)) player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Crystal Coins: "..g5.."(+0).") end end end end end end end function onKill(player, target) if not target:isMonster() then return true end addEvent(scanContainer, 100, player:getId(), target:getPosition()) return true end
local function scanContainer(cid, position)
local player = Player(cid)
if not player then
return
end
local corpse = Tile(position):getTopDownItem()
if not corpse or not corpse:isContainer() then
return
end
if corpse:getType():isCorpse() and corpse:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == cid then
for a = corpse:getSize() - 1, 0, -1 do
local containerItem = corpse:getItem(a)
if containerItem then
for b = AUTOLOOT_STORAGE_START, AUTOLOOT_STORAGE_END do
if player:getStorageValue(b) == containerItem:getId() then
containerItem:moveTo(player)
end
end
if player then
if isItemStackable(containerItem:getId()) then
local g = containerItem:getCount()
local g2 = containerItem:getCount() * 1.1 / 10
local g3 = containerItem:getCount()
local g4 = (containerItem:getCount() * 100) * 1.1 / 10
local g5 = containerItem:getCount()
local g6 = (containerItem:getCount() * 1000) * 1.1 / 10
if containerItem:getId() == 2148 then
containerItem:remove()
doPlayerSetBalance(player, getPlayerBalance(player) + (containerItem:getCount() * 1.1))
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Gold Coins: "..g.."(+"..g2..").")
end
if containerItem:getId() == 2152 then
containerItem:remove()
doPlayerSetBalance(player, getPlayerBalance(player) + ((containerItem:getCount() * 100) * 1.1))
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Platinum Coins: "..g3.."(+"..g4.."Gold Coin).")
end
if containerItem:getId() == 2160 then
containerItem:remove()
doPlayerSetBalance(player, getPlayerBalance(player) + ((containerItem:getCount() * 1000) * 1.1))
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Crystal Coins: "..g5.."(+"..g6.."Gold Coin).")
end
end
end
if not player then
if isItemStackable(containerItem:getId()) then
if containerItem:getId() == 2148 then
containerItem:remove()
doPlayerSetBalance(player, getPlayerBalance(player) + containerItem:getCount())
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Gold Coins: "..g.."(+0).")
end
if containerItem:getId() == 2152 then
containerItem:remove()
doPlayerSetBalance(player, getPlayerBalance(player) + (containerItem:getCount() * 100))
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Platinum Coins: "..g3.."(+0).")
end
if containerItem:getId() == 2160 then
containerItem:remove()
doPlayerSetBalance(player, getPlayerBalance(player) + (containerItem:getCount() * 1000))
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Crystal Coins: "..g5.."(+0).")
end
end
end
end
end
end
end
function onKill(player, target)
if not target:isMonster() then
return true
end
addEvent(scanContainer, 100, player:getId(), target:getPosition())
return true
end
Lua Script Error: [TalkAction Interface]
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/autoloot.luanSay
data/talkactions/scripts/autoloot.lua:6: attempt to index a nil value
stack traceback:
[C]: in function '__index'
data/talkactions/scripts/autoloot.lua:6: in function <data/talkactions/scripts/autoloot.lua:1>