• 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 [LUA-ACTION] Uniqueid chest 1624

Enderlop

Banned User
Joined
Jan 10, 2024
Messages
93
Reaction score
16
IF THERE IS NO SPACE IN THE CONTAINER'S BACKPACK AND IN THE SET AND IN THE INVENTORY WHEN USED IN THE CHEST, IT WILL BE SENT FOR DEPOSIT CITY NAME DexSoft id 1

Lua:
function onUse(cid, item, frompos, item2, topos)
    if item.uid == 1624 then
        if getPlayerStorageValue(cid, 1624) == -1 then
            if getPlayerLevel(cid) >= 0 then
                -- Adds backpacks with ID 10518 to the player's inventory
                for i = 1, 42 do
                    if not doPlayerAddItem(cid, 10518, 1) then
                        doPlayerSendCancel(cid, "You don't have enough space for the backpacks.")
                        return true
                    end
                end

                -- Adds 1000 coins (ID 2159) inside a backpack (ID 10518) and repeats 100 times
                for i = 1, 100 do
                    local backpack = doCreateItemEx(10518, 1)
                    if backpack ~= 0 then
                        for j = 1, 42 do
                            doAddContainerItem(backpack, 2159, 1000)
                        end
                        doPlayerAddItemEx(cid, backpack, false)
                    else
                        doPlayerSendCancel(cid, "You don't have enough space for the backpacks.")
                        return true
                    end
                end
            else
                -- If player level requirement not met
                doPlayerSendCancel(cid, "You don't have the required level to use this item.")
            end
        else
            -- If storage value not equal to -1
            doPlayerSendCancel(cid, "You have already used this item.")
        end
    end
end
 
Last edited:
There is no way, instead of falling to the ground, it can be sent to the player's deposit automatically, the name of the city is dexsoft id 1
@bpm91 good morning
 
let's do the test you

@bpm91 I can't get through chatgpt, send the items to the depot if you can help me???
Post automatically merged:

NO FUNCTION

Lua:
function onUse(cid, item, frompos, item2, topos)
    local depotCity = "DexSoft" -- Depot city name
    local depotID = 1 -- Depot ID in the city

    if item.uid == 1624 then
        if getPlayerStorageValue(cid, 1624) == -1 then
            if getPlayerLevel(cid) >= 0 then
                -- Check if there is enough space in the inventory
                if not hasInventorySpace(cid, 42, 100) then
                    sendAllToDepot(cid, depotCity, depotID)
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your inventory is full. All items have been sent to your depot in "..depotCity..".")
                    return true
                end

                -- Add backpacks with ID 10518 to the player's inventory
                for i = 1, 42 do
                    if not doPlayerAddItem(cid, 10518, 1) then
                        doPlayerSendCancel(cid, "You don't have enough space for the backpacks.")
                        return true
                    end
                end

                -- Add 1000 coins (ID 2159) inside a backpack (ID 10518) and repeat 100 times
                for i = 1, 100 do
                    local backpack = doCreateItemEx(10518, 1)
                    if backpack ~= 0 then
                        for j = 1, 42 do
                            doAddContainerItem(backpack, 2159, 1000)
                        end
                        doPlayerAddItemEx(cid, backpack, false)
                    else
                        doPlayerSendCancel(cid, "You don't have enough space for the backpacks.")
                        return true
                    end
                end

                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You've won a prize.")
                setPlayerStorageValue(cid, 1624, 1)
            else
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need to be level 0 to use this.")
            end
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You've already taken the bonus.")
        end
    end
    return true
end

function hasInventorySpace(cid, backpacksAmount, coinsAmount)
    local totalBackpackSlots = backpacksAmount * 42 -- Each backpack has 42 slots
    local totalCoinsSlots = coinsAmount * 100 -- Each coin occupies 1 slot
    local totalSlotsNeeded = totalBackpackSlots + totalCoinsSlots

    -- Check if the player has enough empty slots in the inventory
    local emptySlots = 0
    for slot = 0, PLAYER_SLOT_LAST do
        if getPlayerItemCount(cid, slot) == 0 then
            emptySlots = emptySlots + 1
        end
    end

    return emptySlots >= totalSlotsNeeded
end

function sendAllToDepot(cid, depotCity, depotID)
    -- Send all backpacks and coins to the depot
    sendToDepot(cid, 10518, 42, depotCity, depotID) -- 42 backpacks
    sendToDepot(cid, 2159, 100, depotCity, depotID) -- 4200 coins
end

function sendToDepot(cid, itemID, amount, city, depotID)
    for i = 1, amount do
        doP
 
Last edited:

Similar threads

Back
Top