• 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!

Windows Auto Loot Sell dont work

This Is War

Member
Joined
Aug 22, 2013
Messages
123
Reaction score
11
Having problem getting auto loot sell to work, this is my problem

When i but item id 2466 on the position where you have to set the item to sell it i get this problem.

HkaHPPn.png


Script
Lua:
local items = { -- you need to set up all items here where :
					[2466] = {cost = 100},
					[2446] = {cost = 3000},
					[2470] = {cost = 4000},
					}
 
 
local basin = {x=999,y=1001,z=7,stackpos = 1} -- basin pos
 
 
 
-- // SCRIPT START \\ --
 
function getContentDescription(uid, li) -- credits to Cyko for main form of this function
	local ret, i, containers,removes, left = {}, 0, {}, {}, {}
 
	while i <= getContainerSize(uid) do
		local v = getContainerItem(uid, i)
		local k = v.uid
		local k2 = v.itemid
 
		local check = items[k2]
		if check then
			table.insert(ret, k2)
			table.insert(removes,k)
		end
		if isContainer(k) then
				table.insert(containers, k)
		end
		i = i + 1
	end
	for i = 1, #containers do
		local bah = getContentDescription(containers[i], li)
		for i = 1,#bah do
			if li == 1 then
				table.insert(removes,bah[i])
			elseif li == 2 then	
				table.insert(ret,bah[i])
			end
		end
	end
	return li== 1 and removes or ret 
end
 
function getKey(t)
	local s = {}
	for k,v in pairs(t) do
		table.insert(s,k)
	end
	return s
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local exist = getThingFromPos(basin).uid
local itm = getThingFromPos(basin).itemid
 
	if isContainer(exist) then
		local t = getContentDescription(exist,2)
		local t2 = getContentDescription(exist,1)
		if #t > 0 then
			local f = {}
			for i = 1,#t do
				if not isInArray(getKey(f),t[i]) then
					f[t[i]] = 1
				else
					f[t[i]] = f[t[i]] + 1
				end
			end
			local str = "Sold items : "
			local money = 0
			for k,v in pairs(f) do
				str = str.."\n".."•••• "..v.."x "..getItemNameById(k).." : ".. ( tonumber(items[k].cost) * tonumber(v) ) .. " gold coins."
				money = money + tonumber(items[k].cost) * tonumber(v)
 
			end
			for i = 1,#t2 do
				doRemoveItem(t2[i])
			end
			doPlayerSendTextMessage(cid,27,str)
			doPlayerAddMoney(cid,money)
			if #t > 1 then
				doPlayerSendTextMessage(cid,19," Total money : ".. money.." gold coins.")
			end
		else
			doPlayerSendTextMessage(cid,18,"Warning : Sold nothing --> either bag is empty or items included arn't sellable here.")
			doSendMagicEffect(fromPosition,2)
 
		end
	else
		local merge = items[itm]
		if not merge then
			doPlayerSendTextMessage(cid,18,"Warning : This item isn't sellable here.")
			doSendMagicEffect(fromPosition,2)
 
		else
			doRemoveItem(exist)
			doPlayerSendTextMessage(cid,27,"Sold item : \n •••• 1x "..getItemNameById(itm).." : "..merge.cost.."." )
			doPlayerAddMoney(cid,merge.cost)
		end
 
	end
	return doTransformItem(item.uid,item.uid == 1945 and 1946 or 1945)
end

anyone know what im doing wrong?
 
Try putting them item in a bag lol Because I'm pretty sure the script checks for a bag then check what items are in the bag. so if it checks for the bag and the bag isnt there. It would probably not work. lmk if that fixes ur problem. Because the purpose of this script it for people to threw there loot bags on it and it auto sell all the loot in 1 shot instead of saying. 'hi''trade' and scrolling threw the menu
 
btw tested this works on 0.4 with and without a loot bag so also make sure your actionid is correct on actions.xml to your lever!


also this is how my script looks so

Lua:
<!-- Auto Loot -->
	<action actionid="2212" event="script" value="other/auto.lua"/>

Lua:
local items = { -- you need to set up all items here where :
					[2466] = {cost = 1000},
					[2446] = {cost = 3000},
					[2470] = {cost = 4000},
					}
 
 
local basin = {x=996,y=895,z=7,stackpos = 1} -- basin pos
 
 
 
-- // SCRIPT START \\ --
 
function getContentDescription(uid, li) -- credits to Cyko for main form of this function
	local ret, i, containers,removes, left = {}, 0, {}, {}, {}
 
	while i <= getContainerSize(uid) do
		local v = getContainerItem(uid, i)
		local k = v.uid
		local k2 = v.itemid
 
		local check = items[k2]
		if check then
			table.insert(ret, k2)
			table.insert(removes,k)
		end
		if isContainer(k) then
				table.insert(containers, k)
		end
		i = i + 1
	end
	for i = 1, #containers do
		local bah = getContentDescription(containers[i], li)
		for i = 1,#bah do
			if li == 1 then
				table.insert(removes,bah[i])
			elseif li == 2 then	
				table.insert(ret,bah[i])
			end
		end
	end
	return li== 1 and removes or ret 
end
 
function getKey(t)
	local s = {}
	for k,v in pairs(t) do
		table.insert(s,k)
	end
	return s
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local exist = getThingFromPos(basin).uid
local itm = getThingFromPos(basin).itemid
 
	if isContainer(exist) then
		local t = getContentDescription(exist,2)
		local t2 = getContentDescription(exist,1)
		if #t > 0 then
			local f = {}
			for i = 1,#t do
				if not isInArray(getKey(f),t[i]) then
					f[t[i]] = 1
				else
					f[t[i]] = f[t[i]] + 1
				end
			end
			local str = "Sold items : "
			local money = 0
			for k,v in pairs(f) do
				str = str.."\n".."•••• "..v.."x "..getItemNameById(k).." : ".. ( tonumber(items[k].cost) * tonumber(v) ) .. " gold coins."
				money = money + tonumber(items[k].cost) * tonumber(v)
 
			end
			for i = 1,#t2 do
				doRemoveItem(t2[i])
			end
			doPlayerSendTextMessage(cid,27,str)
			doPlayerAddMoney(cid,money)
			if #t > 1 then
				doPlayerSendTextMessage(cid,19," Total money : ".. money.." gold coins.")
			end
		else
			doPlayerSendTextMessage(cid,18,"Warning : Sold nothing --> either bag is empty or items included arn't sellable here.")
			doSendMagicEffect(fromPosition,2)
 
		end
	else
		local merge = items[itm]
		if not merge then
			doPlayerSendTextMessage(cid,18,"Warning : This item isn't sellable here.")
			doSendMagicEffect(fromPosition,2)
 
		else
			doRemoveItem(exist)
			doPlayerSendTextMessage(cid,27,"Sold item : \n •••• 1x "..getItemNameById(itm).." : "..merge.cost.."." )
			doPlayerAddMoney(cid,merge.cost)
		end
 
	end
	return doTransformItem(item.uid,item.uid == 1945 and 1946 or 1945)
end

ofc change coal basin position!!! :D:D:D
 
Back
Top