• 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+ item on shop no work 100% otv8 tfs 1.5

bpm91

Intermediate OT User
Joined
May 23, 2019
Messages
931
Solutions
7
Reaction score
127
Location
Brazil
YouTube
caruniawikibr
I discovered this bug by testing. when the player buys the item from the client's store, and he has a depot open in another city, then I log in to receive the teleport, and when I arrive at the depot the item hasn't arrived. however, if I have the correct depot open, I receive it. The script works by sending a package of items to the player's hometown.

i discovered the problem is when relogging.
here is function


Code:
function addPackage(category, title, description, itemId, count, price, source, callback, premiumOnly)
    if not GAME_STORE.offers[category] then
        GAME_STORE.offers[category] = {}
    end

    if not callback then
        callback = defaultPackageCallback
    end
    -- if not source then
        -- source = nil
    -- end
    local imager
    if source then
        imager = true
    end
    table.insert(
        GAME_STORE.offers[category],
        {
            type = "item",
            title = title,
            description = description,
            itemId = itemId,
            count = count,
            price = price,
            clientId = ItemType(itemId[1]):getClientId(),
            source = source,
            image = imager or false,
            callback = callback,
            premiumOnly = premiumOnly or false,
        }
    )
end


Lua:
function defaultPackageCallback(player, offer)
    local weight = 1
    for i = 1, #offer.itemId do
        weight = weight + ItemType(offer.itemId[i]):getWeight(offer.count[i])
    end
    local itemName = offer.title
    local parcel = Game.createItem(2596, 1)
    local label = parcel:addItem(2598, 1)
        for y = 1, #offer.itemId do
            parcel:addItem(offer.itemId[y], offer.count[y])
        end
        player:getDepotChest(player:getTown():getId(), true):addItemEx(parcel)
        label:setAttribute(ITEM_ATTRIBUTE_TEXT, "Here is your order!\n\nThank you for purchasing '" .. itemName .. "'.\n\nSincerely,\nCarunia Team.")
    return true
end
 
Last edited:
I discovered this bug by testing. when the player buys the item from the client's store, and he has a depot open in another city, then I log in to receive the teleport, and when I arrive at the depot the item hasn't arrived. however, if I have the correct depot open, I receive it. The script works by sending a package of items to the player's hometown.

i discovered the problem is when relogging.
here is function


Code:
function addPackage(category, title, description, itemId, count, price, source, callback, premiumOnly)
    if not GAME_STORE.offers[category] then
        GAME_STORE.offers[category] = {}
    end

    if not callback then
        callback = defaultPackageCallback
    end
    -- if not source then
        -- source = nil
    -- end
    local imager
    if source then
        imager = true
    end
    table.insert(
        GAME_STORE.offers[category],
        {
            type = "item",
            title = title,
            description = description,
            itemId = itemId,
            count = count,
            price = price,
            clientId = ItemType(itemId[1]):getClientId(),
            source = source,
            image = imager or false,
            callback = callback,
            premiumOnly = premiumOnly or false,
        }
    )
end


Lua:
function defaultPackageCallback(player, offer)
    local weight = 1
    for i = 1, #offer.itemId do
        weight = weight + ItemType(offer.itemId[i]):getWeight(offer.count[i])
    end
    local itemName = offer.title
    local parcel = Game.createItem(2596, 1)
    local label = parcel:addItem(2598, 1)
        for y = 1, #offer.itemId do
            parcel:addItem(offer.itemId[y], offer.count[y])
        end
        player:getDepotChest(player:getTown():getId(), true):addItemEx(parcel)
        label:setAttribute(ITEM_ATTRIBUTE_TEXT, "Here is your order!\n\nThank you for purchasing '" .. itemName .. "'.\n\nSincerely,\nCarunia Team.")
    return true
end

I couldn't understand exactly what happens, but I'll give you a script that sends purchases in parcels to the player, if you want to adapt

Lua:
function sendReward(playerName, townId, itemId, itemCount)
	local town = Town(townId)
	if not town then
		return print("SendReward Error - Town not found.")
	end

	local townName = town:getName()
	local parcel = Game.createItem(ITEM_PARCEL, 1)
	if not parcel then
		return print("SendReward Error - Impossible to create parcel item.")
	end

	local label = Game.createItem(ITEM_LABEL, 1)
	if not label then
		return print("SendReward Error - Impossible to create label item.")
	end

	label:setAttribute(ITEM_ATTRIBUTE_TEXT, playerName .. "\n" .. townName)
	parcel:addItem(itemId, itemCount)
	parcel:addItemEx(label)

	local mailbox = Tile(Position(32308, 31935, 7)):getItemById(2593)
	if not mailbox then
		return print("SendReward Error - No Mailbox found.")
	end

	return Tile(Position(32308, 31935, 7)):addItemEx(parcel)
end

This function sends a parcel to the player with the item he purchased. My tip is to put a mailbox on GM Island, so nothing will stop the system

Using znote shopsystem works well.

Lua:
sendReward(playerName, playerTown, orderItemId, orderCount)
 
I will exemplify what happens. I'm in Carlin, but my character is born in Thai, so when I buy in my store, and after buying I relog, when I arrive in Thai the item is not there. I only get paid if I'm online
 
I will exemplify what happens. I'm in Carlin, but my character is born in Thai, so when I buy in my store, and after buying I relog, when I arrive in Thai the item is not there. I only get paid if I'm online
Well, I don't have much knowledge to speak of, but it seems like a problem with the player save or even with the script when locating the player, when you buy, does the item arrive instantly or is there a delay for it to be delivered?
 
I fixed it by sending the installment directly to the player, but I wanted to block it if he didn't have any slots left so he wouldn't buy it.

Lua:
function defaultPackageCallback(player, offer)
    local weight = 1
    for i = 1, #offer.itemId do
        weight = weight + ItemType(offer.itemId[i]):getWeight(offer.count[i])
    end 
    local itemName = offer.title
    local parcel = Game.createItem(2596, 1)
    local label = parcel:addItem(2598, 1)
    for y = 1, #offer.itemId do
        parcel:addItem(offer.itemId[y], offer.count[y])
    end
    -- Add the parcel to the player's inventory instead of the depot
    player:addItemEx(parcel)
    label:setAttribute(ITEM_ATTRIBUTE_TEXT, "Here is your order!\n\nThank you for purchasing '" .. itemName .. "'.\n\nSincerely,\nCarunia Team.")
    return true
end
 
Lua:
local itemType = ItemType(orderItemId)
if player:getFreeCapacity() >= itemType:getWeight(orderCount) then

local backpack = player:getSlotItem(CONST_SLOT_BACKPACK)
local needslots = orderCount > 98 and math.floor(orderCount / 100) + 1 or orderCount
if backpack ~= nil and backpack:getEmptySlots(false) >= needslots then

Some of this functions can help you
 
Back
Top