• 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 1.X+ Define Item

Caduceus

Unknown Member
Joined
May 10, 2010
Messages
321
Solutions
2
Reaction score
24
I am trying to find a way to define Item in a script that does not have it included in the function. I keep getting "attempt to index local 'item' (a nil value)"

Lua:
        elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_MULTI_ITEM then
            local inbox = player:getSlotItem(CONST_SLOT_STORE_INBOX)
            if inbox and inbox:getEmptySlots() > 0 then
                local item = Item(uid) -- this does not work
                local multipack = isInArray(offer.thingId, item:getId())
                local parcel = inbox:addItem(2596, 1)
                local packagename = ''.. offer.count..'x '.. offer.name ..' package.'
                    if parcel then
                        parcel:setAttribute(ITEM_ATTRIBUTE_NAME, packagename)
                        for e = 1,offer.count do
                            parcel:addItem(multipack, 1)
                    end
                end
            else
                return addPlayerEvent(sendStoreError, 250, player, GameStore.StoreErrors.STORE_ERROR_NETWORK, "Please make sure you have free slots in your store inbox.")
        end
 
Last edited:
offer.thingId does call itemId, so item:getId() is not needed. I have tried to do like this, but the array does not return items to add to parcel

I am trying to call an array on offer.thingId
Lua:
{    name = "Hangables test",
        state = GameStore.States.STATE_NEW,
        icons = {"Ferumbras_Portrait.png"},
        offers = {
            {name = "Painting of Tibiasula", thingId = {30987,30988}, count = 1, type = GameStore.OfferTypes.OFFER_TYPE_MULTI_ITEM, price = 0, icons = {"nothing.png"}, description = "a Painting of Tibiasula."},
        }
    },
Lua:
elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_MULTI_ITEM then
            local inbox = player:getSlotItem(CONST_SLOT_STORE_INBOX)
            if inbox and inbox:getEmptySlots() > 0 then
                local parcel = inbox:addItem(2596, 1)
                local multiPack = isInArray(offer.thingId)
                local packagename = ''.. offer.count..'x '.. offer.name ..' package.'
                    if parcel then
                        parcel:setAttribute(ITEM_ATTRIBUTE_NAME, packagename)
                        for e = 1,offer.count do
                            parcel:addItem(multiPack, 1)
                    end
                end
            else
                return addPlayerEvent(sendStoreError, 250, player, GameStore.StoreErrors.STORE_ERROR_NETWORK, "Please make sure you have free slots in your store inbox.")
        end
 
Last edited:
This worked, thanks!

Lua:
        elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_MULTI_ITEM then
            local inbox = player:getSlotItem(CONST_SLOT_STORE_INBOX)
            if inbox and inbox:getEmptySlots() > 0 then
                local parcel = inbox:addItem(2596, 1)
                local packagename = ''.. offer.count..'x '.. offer.name ..' package.'
                    if parcel then
                        parcel:setAttribute(ITEM_ATTRIBUTE_NAME, packagename)
                        for i = 1, #offer.thingId do
                            parcel:addItem(offer.thingId[i], 1)
                    end
                end
            else
                return addPlayerEvent(sendStoreError, 250, player, GameStore.StoreErrors.STORE_ERROR_NETWORK, "Please make sure you have free slots in your store inbox.")
        end
 

Similar threads

Back
Top