seriously, no scripter would think in globalevent for this,
and jano had made a container "scanner"
can't be easier than checking the corpse as container 0.1 seconds after deathLua:local function scanContainer(cid, uid, list) for k = (getContainerSize(uid) - 1), 0, -1 do local tmp = getContainerItem(uid, k) if (isInArray(list, tmp.itemid)) then if isItemStackable(tmp.itemid) and (getPlayerItemCount(cid, tmp.itemid) > 0) then doStack(cid, tmp.itemid, tmp.type) else local item = doCreateItemEx(tmp.itemid, tmp.type) doPlayerAddItemEx(cid, item, true) end doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Looted ' .. tmp.type .. ' ' .. getItemNameById(tmp.itemid) .. '.') doRemoveItem(tmp.uid) elseif isContainer(tmp.uid) then scanContainer(cid, tmp.uid, list) end end end
and that function can be easily edited to send looted money to bank, not backpackmaybe you should read the OP. He wants the money to go to the bank, not auto stack into his inventory.
Also with a global event the player could turn it on anywhere he is with a talkaction, sending anything he previously had in his inventory to the bank; therefore any 'scripter' wouldnt go for creature event if they read the OP right and also realized there is more benefits to having it as a global event.
<talkaction words="!autoloot" event="script" value="autoloot.lua"/>
local stor = 7575
function onSay(cid, words, param, channel)
doCreatureSetStorage(cid, stor, (getCreatureStorage(cid, stor) == -1) and 1 or -1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Money autoloot has been ' .. (getCreatureStorage(cid, stor) == -1 and 'disabled' or 'enabled') .. '.')
return true
end
registerCreatureEvent(cid, "loot")
<event type="kill" name="loot" event="script" value="moneyloot.lua"/>
local stor = 7575
function autoloot(cid, target, pos)
if not isPlayer(cid) then
return
end
local function scanContainer(cid, uid)
local added = 0
for k = (getContainerSize(uid) - 1), 0, -1 do
local tmp = getContainerItem(uid, k)
if (isInArray({2148, 2152, 2160}, tmp.itemid)) then
local deposit = (tmp.itemid == 2160) and (tmp.type*10000) or (tmp.itemid == 2152) and (tmp.type*100) or tmp.type
added = added + deposit
local sum = getPlayerBalance(cid) + deposit
doPlayerSetBalance(cid, sum)
doRemoveItem(tmp.uid)
elseif isContainer(tmp.uid) then
scanContainer(cid, tmp.uid)
end
end
return (added > 0) and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Added ' .. added .. 'x gold to your balance from loot. [Balance: ' .. getPlayerBalance(cid) .. ']')
end
local items = {}
for i = getTileInfo(pos).items, 1, -1 do
pos.stackpos = i
items = getThingFromPos(pos)
end
if (#items == 0) then
return
end
local corpse = -1
for _, item in pairs(items) do
if not isCreature(item.uid) then
local name = getItemName(item.uid):lower()
if name:find(target:lower()) then
corpse = item.uid
break
end
end
end
if (corpse ~= -1) and isContainer(corpse) and (getItemAttribute(corpse, "corpseowner") == cid) then
scanContainer(cid, corpse)
end
end
function onKill(cid, target, lastHit)
if isMonster(target) and (getCreatureStorage(cid, stor) == 1) then
addEvent(autoloot, 150, cid, getCreatureName(target), getCreaturePosition(target))
end
return true
end
and that function can be easily edited to send looted money to bank, not backpack
it's more specific and objective to use creaturescript, smth of common sense
talkaction would not matter if it's globalevent, creaturescript or another kind of script, it'll work the same way
I don't see what benefits are you talking about as globalevent, with creaturescript corpse is scanned, money is detected and sent instantly to bank, rather than checking with globalevent needlessly, we only need to execute the script when the monster is killed, not guessing and detecting with a globalevent
@op since our policy is not helping non-premium users who have private revisions of tfs, you have to prove that you've been premium or otherwise I'll have to lock this thread
if (corpse ~= -1) and isContainer(corpse) and (getItemAttribute(corpse, "corpseowner") == cid) then
if (corpse ~= -1) and isContainer(corpse) and (getItemAttribute(corpse, "corpseowner") == cid) then
scanContainer(cid, corpse)
end
function autoloot(cid, target, pos) if not isPlayer(cid) then
return
end
local function scanContainer(cid, uid)
local added = 0
for k = (getContainerSize(uid) - 1), 0, -1 do
local tmp = getContainerItem(uid, k)
if (isInArray({2148, 2152, 2160}, tmp.itemid)) then
local deposit = (tmp.itemid == 2160) and (tmp.type*10000) or (tmp.itemid == 2152) and (tmp.type*100) or tmp.type
added = added + deposit
local sum = getPlayerBalance(cid) + deposit
doPlayerSetBalance(cid, sum)
doRemoveItem(tmp.uid)
elseif isContainer(tmp.uid) then
scanContainer(cid, tmp.uid)
end
end
return (added > 0) and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Added ' .. added .. 'x gold to your balance from loot. [Balance: ' .. getPlayerBalance(cid) .. ']')
end
local items = {}
for i = getTileInfo(pos).items, 1, -1 do
pos.stackpos = i
items[i] = getThingFromPos(pos)
end
if (#items == 0) then
return
end
local corpse = -1
for _, item in pairs(items) do
if not isCreature(item.uid) then
local name = getItemName(item.uid):lower()
if name:find(target:lower()) then
corpse = item.uid
break
end
end
end
if (corpse ~= -1) and isContainer(corpse) and (getItemAttribute(corpse, "corpseowner") == cid) then
scanContainer(cid, corpse)
end
end
function onKill(cid, target, lastHit)
if isMonster(target) then
addEvent(autoloot, 150, cid, getCreatureName(target), getCreaturePosition(target))
end
return true
end
if (corpse ~= -1) and isContainer(corpse) and (getItemAttribute(corpse, "corpseowner") == cid) then
local stor = 7575
function autoloot(cid, target, pos)
if not isPlayer(cid) then
return
end
local function scanContainer(cid, uid)
local added = 0
for k = (getContainerSize(uid) - 1), 0, -1 do
local tmp = getContainerItem(uid, k)
if (isInArray({2148, 2152, 2160}, tmp.itemid)) then
local deposit = (tmp.itemid == 2160) and (tmp.type*10000) or (tmp.itemid == 2152) and (tmp.type*100) or tmp.type
added = added + deposit
local sum = getPlayerBalance(cid) + deposit
doPlayerSetBalance(cid, sum)
doRemoveItem(tmp.uid)
elseif isContainer(tmp.uid) then
scanContainer(cid, tmp.uid)
end
end
return (added > 0) and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Added ' .. added .. 'x gold to your balance from loot. [Balance: ' .. getPlayerBalance(cid) .. ']')
end
local items = {}
for i = getTileInfo(pos).items, 1, -1 do
pos.stackpos = i
items[i] = getThingFromPos(pos)
end
if (#items == 0) then
return
end
local corpse = -1
for _, item in pairs(items) do
if not isCreature(item.uid) then
local name = getItemName(item.uid):lower()
if name:find(target:lower()) then
corpse = item.uid
break
end
end
end
scanContainer(cid, corpse)
end
function onKill(cid, target, lastHit)
if isMonster(target) and (getCreatureStorage(cid, stor) == 1) then
addEvent(autoloot, 150, cid, getCreatureName(target), getCreaturePosition(target))
end
return true
end
if (corpse ~= -1) and isContainer(corpse) and (getItemAttribute(corpse, "corpseowner") == cid) then