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

msg.addString/byte - Compiling 1.2

hey @Ninja could you help me add cap on this script?

Code:
function onBuy(player, offer)
    local itemType = ItemType(offer:getName())
    if itemType:getId() == 0 then
        player:sendStoreError(STORE_ERROR_PURCHASE, "Item not found. Please contact an administrator.")
        return false
    end

    player:addItem(itemType:getId(), 1)
    return true
end

I tryed the code below, but isn't working.
Code:
local tmpContainer = Game.createItem(itemType:getId())

    if player:addItemEx(tmpContainer) ~= RETURNVALUE_NOERROR then
        player:sendCancelMessage(player:getFreeCapacity() < tmpContainer:getWeight() and RETURNVALUE_NOTENOUGHCAPACITY or RETURNVALUE_NOTENOUGHROOM)
        return false
    end
 
Back
Top