E
Evil Puncker
Guest
Is there any way to optimize this scan function?
Using tfs 1.3 if it even matters
Lua:
local function scanContainer(cid, position)
local player = Player(cid)
if not player then
return
end
if not player:isPremium() 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
if player then
if isItemStackable(containerItem:getId()) then
if containerItem:getId() == 2148 then
containerItem:remove()
player:setBankBalance(player:getBankBalance() + (containerItem:getCount()))
end
if containerItem:getId() == 2152 then
containerItem:remove()
player:setBankBalance(player:getBankBalance() + (containerItem:getCount() * 100))
end
if containerItem:getId() == 2160 then
containerItem:remove()
player:setBankBalance(player:getBankBalance() + (containerItem:getCount() * 1000))
end
end
end
end
end
local g = player:getBankBalance()
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Bank balance: "..g..".")
end
end
Using tfs 1.3 if it even matters