• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

(solved) gold dont drop on the floor (changegold.lua tfs 1.2)

_M4G0_

Intermediate OT User
Joined
Feb 6, 2016
Messages
550
Solutions
17
Reaction score
108
LUA:
local config = {
    [ITEM_GOLD_COIN] = {changeTo = ITEM_PLATINUM_COIN},
    [ITEM_PLATINUM_COIN] = {changeBack = ITEM_GOLD_COIN, changeTo = ITEM_CRYSTAL_COIN},
    [ITEM_CRYSTAL_COIN] = {changeBack = ITEM_PLATINUM_COIN, changeTo = ITEM_BAR_OF_GOLD},
    [ITEM_BAR_OF_GOLD]    = {changeBack = ITEM_CRYSTAL_COIN}
}

function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey, container)
    local coin = config[item.itemid]
    if not coin then
        return false
    end

    local bp = getPlayerSlotItem(player, CONST_SLOT_BACKPACK).uid
    local freeSlotsInBp = math.max(0, getContainerCap(bp) - getContainerSize(bp))
    if freeSlotsInBp > 0 then
    if coin.changeTo and item.type == 100 then
        item:remove()
        player:addItem(coin.changeTo, 1)
    elseif coin.changeBack then
        item:transform(item.itemid, item.type - 1)
        player:addItem(coin.changeBack, 100)
    else
 
        return false
    end
    return true
end

end

i add this in the script
LUA:
    local bp = getPlayerSlotItem(player, CONST_SLOT_BACKPACK).uid
    local freeSlotsInBp = math.max(0, getContainerCap(bp) - getContainerSize(bp))
    if freeSlotsInBp > 0 then

but not work on other empty bp, when the main bp is full it stops even with the other empty bp
tfs 1.2
BUMP
 
Last edited:
Are you looking for someone to write that function to you? In that case ill move this to requests, otherwise you have the way to fix the problem in my last post.
i tried what you suggested, but dont work
i cant do it, so i need help
thanks for support
 
Code:
local config = {
    [ITEM_GOLD_COIN] = {changeTo = ITEM_PLATINUM_COIN},
    [ITEM_PLATINUM_COIN] = {changeBack = ITEM_GOLD_COIN, changeTo = ITEM_CRYSTAL_COIN},
    [ITEM_CRYSTAL_COIN] = {changeBack = ITEM_PLATINUM_COIN, changeTo = ITEM_BAR_OF_GOLD},
    [ITEM_BAR_OF_GOLD]    = {changeBack = ITEM_CRYSTAL_COIN}
}
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey, container)
    local coin = config[item.itemid]
    if not coin then
        return false
    end
        local bp = player:getSlotItem(CONST_SLOT_BACKPACK)
        if backpack and backpack:getEmptySlots(false) > 0 then
        if coin.changeTo and item.type == 100 then
        item:remove()
        player:addItem(coin.changeTo, 1)
        elseif coin.changeBack then
        item:transform(item.itemid, item.type - 1)
        player:addItem(coin.changeBack, 100)
   else
        player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "Please make sure that you have at least 1 free inventory slots in your main backpack.")
        return false
    end
    return true
end
end


If the player have backpack(on slot backpack) and the backpack have 1 free slot or more then do the convertion.
if not return a message.
 
Last edited:
solved

LUA:
        local bp = player:getSlotItem(CONST_SLOT_BACKPACK)
       local freeSlotsInBp = math.max(1, bp:getEmptySlots(bp))
 
Last edited:
Solution
Back
Top