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

Auto Looter Money

Status
Not open for further replies.

Jonass

Here who doesn't run, it flies.
Joined
Nov 12, 2008
Messages
216
Reaction score
3
I'm looking for a script to take the money from the monsters and automatically send it to the bank. Does anyone help me?

Thanks :)
 
Last edited:
seriously, no scripter would think in globalevent for this,
and jano had made a container "scanner"
Lua:
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
can't be easier than checking the corpse as container 0.1 seconds after death

maybe 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.
 
maybe 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.
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
 
I've been donator in otland a few times with this account, they can check. Why you'll lock this thread?
 
it's just the common autoloot script

add at /data/talkactions/talkactions.xml
Code:
<talkaction words="!autoloot" event="script" value="autoloot.lua"/>

create autoloot.lua @ /data/talkactions/scripts/
Code:
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

add this line at /data/creaturescripts/scripts/login.lua creaturescript
Code:
registerCreatureEvent(cid, "loot")

creaturescripts.xml
Code:
<event type="kill" name="loot" event="script" value="moneyloot.lua"/>

creature moneyloot.lua @ /data/creaturescripts/scripts/
Code:
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

This is true and i know that but i was also saying it could be used to send previous money in your bp to bank also, not just the money looted from the monster once it was activated. say you were carrying money prior to killing the monster it wouldnt send that; this could be a bonus/a non bonus, but also not what the OP really wanted, so i will decline here and say i was in the wrong. My apolgozies
 
@cbrm:
Sorry cbrm but script not work and console not show nothing error. But i put print in script of moneyloot.lua and i find error but i can't fix it. The error is in line 47, here:
Code:
if (corpse ~= -1) and isContainer(corpse) and (getItemAttribute(corpse, "corpseowner") == cid) then
You can make the script without enable and disable?

Thank you :)
 
Last edited:
This part not execute:
Code:
		if (corpse ~= -1) and isContainer(corpse) and (getItemAttribute(corpse, "corpseowner") == cid) then
		scanContainer(cid, corpse)
	end

The script not put error in console, but i put print in this if and not execute. But I put print in the rest of script and console put print.
 
you must be doing something wrong
Lua:
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
 
I do it all well.
For example i delete this part:
Code:
if (corpse ~= -1) and isContainer(corpse) and (getItemAttribute(corpse, "corpseowner") == cid) then

And it looks like this:
Code:
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


And if that works, but console displays this error:
[Error - CreatureScript Interface]
In a timer event called from:
data/creaturescirpts/scripts/moneyloot.lua:eek:nKill
Description:
(luaGetContainerSize) Container not found

[Error - CreatureScript Interface]
In a timer event called from:
data/creaturescirpts/scripts/moneyloot.lua:eek:nKill
Description:
data/creaturescripts/scripts/moneyloot.lua:eek:nKill
Description:
data/creaturescripts/scripts/moneyloot.lua:attempt to perform arithmetic on a boolean value
stack traceback:
data/creaturescripts/scripts/moneyloot.lua:7: in function 'scanContainer'
data/screaturescripts/scripts/moneyloot.lua:43: in function <data/creaturescripts/scripts/moneyloot.lua:1>
 
you deleting this part is the reason its giving that error
Code:
if (corpse ~= -1) and isContainer(corpse) and (getItemAttribute(corpse, "corpseowner") == cid) then
^the code after this if then statement scans the corpse
 
@UpInSmoke: Read me post, i delete this part and console display errores, but script work. When i don't delete this part console don't display errors and not work script.
 
Status
Not open for further replies.
Back
Top