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

TFS 0.X Remove all items from depot

fyalhed

Member
Joined
Nov 18, 2017
Messages
156
Reaction score
20
I wanna make a server with stages lvl citys, but when u talk to oracle and go to the next city (city lvl 2,3)
I want to remove all your items from depot and send to the new city
Is it possible to do by scripts?

For now i'm doing this bad short solution :(
Code:
        if getPlayerDepotItems(cid, town_id) > 1 then
            selfSay("Clean your DEPOT! You can not have items in DEPOT if you want to change your city level!", cid)
            return true
        end
 
Delete all items, transfer, anything like this?

Lua:
local townID = 2
    if getPlayerDepotItems(cid, townID) > 1 then
        doPlayerSendTextMessage(cid, 27, "You have a total of: ".. getPlayerDepotItems(cid, townID) - 1 .." items in your depot, clear your depot before going to next city.")
      end

OBS: > 1 because depot chest is one item
 
Lua:
local townID = 2
    if getPlayerDepotItems(cid, townID) > 1 then
        doPlayerSendTextMessage(cid, 27, "You have a total of: ".. getPlayerDepotItems(cid, townID) - 1 .." items in your depot, clear your depot before going to next city.")
      end

OBS: > 1 because depot chest is one item

No bro, the if i posted is working
What i need to do is clean that depot, delete all items there :)
 
Its not possible or at least not with existing functions on tfs 0.x - however you can use a query to achieve that (bad news is that player must be logout, otherwise wont work)

PHP:
db.query("DELETE FROM `player_depotitems` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
 
Its not possible or at least not with existing functions on tfs 0.x - however you can use a query to achieve that (bad news is that player must be logout, otherwise wont work)

PHP:
db.query("DELETE FROM `player_depotitems` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")

it delete all items the player got in depot, right?

how can i delete only for city 7?

i didn't understand how this depot items works on DB

what is sid? what is pid?

 
Pid is the depot_id

101 - No town
102 - Town id 1
103 - Town id 2

Etc

So for example, if you want to remove items from town id 4 depot, pid should be 105
PHP:
db.query("DELETE FROM `player_depotitems` WHERE `player_id` = " .. getPlayerGUID(cid) .. " AND `pid` = 105;")
 
Pid is the depot_id

101 - No town
102 - Town id 1
103 - Town id 2

Etc

So for example, if you want to remove items from town id 4 depot, pid should be 105
PHP:
db.query("DELETE FROM `player_depotitems` WHERE `player_id` = " .. getPlayerGUID(cid) .. " AND `pid` = 105;")

I had a idea, tried:

npc oracle, that teleport
Code:
        -- clean depot after logout in main
        local storage_clean_rook_depot = 150861 -- creaturescript
        setPlayerStorageValue(cid,storage_clean_rook_depot,1)


creaturescripts
Code:
<event type="logout" name="AutoCleanRookDP" event="script" value="clean_rook_dp_after_first_main_logout.lua"/>

login.lua
Code:
registerCreatureEvent(cid, "AutoCleanRookDP") -- primeiro logout em main apaga todos os itens de rook

clean_rook_dp_after_first_main_logout.lua
Code:
-- 101 - No town
-- 102 - Town id 1
-- 103 - Town id 2
-- 104 - Town id 3
-- 105 - Town id 4
-- 106 - Town id 5
-- 107 - Town id 6
-- 108 - Town id 7 (ROOK)

function onLogout(cid)
    local storage_clean_rook_depot = 150861
    if getPlayerStorageValue(cid, storage_clean_rook_depot) ~= -1 then
        doPlayerSave(cid)
        db.query("DELETE FROM `player_depotitems` WHERE `player_id` = " .. getPlayerGUID(cid) .. " AND `pid` = 108;")
        setPlayerStorageValue(cid,storage_clean_rook_depot,-1)
    end
    return true
end

but didn't work...
why?
 
No errors? Did you make sure 108 is the pid value from rooks items?
Also move doPlayerSave under setStorage

-- EDIT --
Try this way
Lua:
function onLogout(cid)
    local storage_clean_rook_depot = 150861
    if getPlayerStorageValue(cid, storage_clean_rook_depot) ~= -1 then
        local id = getPlayerGUID(cid)
        setPlayerStorageValue(cid,storage_clean_rook_depot, -1)
        addEvent(function() db.query("DELETE FROM `player_depotitems` WHERE `player_id` = " .. id .. " AND `pid` = 108;") end, 100)
    end
    return true
end
 
Last edited:
rook is town id 7
are u sure that stuff about 108 is the items from town id 7?

i've add only 50 blank runes in depot
and that is my db:
 
rook is town id 7
are u sure that stuff about 108 is the items from town id 7?

i've add only 50 blank runes in depot
and that is my db:
Depot ID on RME has rook town id on properties? Also which tfs version you using? Cuz im with 0.3.7
 
I think you are overthinking this. What you want to achieve is to take items from depot of level 1 city to depot of level 2 city, because you are unable to go back, right?
Why don't you just use a global depot? Setup depots for the same city so it always has the same items inside.
 
Back
Top