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

player name on the item you purchased at the shop

jel

Member
Joined
Mar 22, 2014
Messages
302
Reaction score
12
I'm trying to put the name of the player on the item you bought at the store, how would it look?
tfs 1.3

talkactions:
LUA:
function onSay(cid, words, param)
local storage = 54073 -- Make sure to select non-used storage. This is used to prevent SQL load attacks.
local cooldown = 15 -- in seconds.
local player = Player(cid)
if player:getStorageValue(storage) <= os.time() then
player:setStorageValue(storage, os.time() + cooldown)
-- Create the query
local orderQuery = db.storeQuery("SELECT `id`, `type`, `itemid`, `count` FROM `shop_orders` WHERE `account_id` = " .. player:getAccountId() .. " LIMIT 1;")
-- Detect if we got any results
if orderQuery ~= false then
-- Fetch order values
local q_id = result.getDataInt(orderQuery, "id")
local q_type = result.getDataInt(orderQuery, "type")
local q_itemid = result.getDataInt(orderQuery, "itemid")
local q_count = result.getDataInt(orderQuery, "count")
result.free(orderQuery)
-- ORDER TYPE 1 (Regular item shop products)
if q_type == 1 then
-- Get wheight
if player:getFreeCapacity() >= ItemType(q_itemid):getWeight(q_count) then
db.query("DELETE FROM `shop_orders` WHERE `id` = " .. q_id .. ";")
player:addItem(q_itemid, q_count)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received " .. q_count .. " x " .. ItemType(q_itemid):getName() .. "!")
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "Need more CAP!")
end
end
-- Add custom order types here
-- Type 2 is reserved for premium days and is handled on website, not needed here.
-- Type 3 is reserved for character gender(sex) change and is handled on website as well.
-- So use type 4+ for custom stuff, like etc packages.
-- if q_type == 4 then
-- end
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "You have no orders.")
end
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, "Can only be executed once every " .. cooldown .. " seconds. Remaining cooldown: " .. player:getStorageValue(storage) - os.time())
end
return false
end

I tried for that:
Player:setDescription(q_itemid, "description", "Este item foi comprado pelo shop e entregue para o jogador ".. player:getName() .."!")
 
Solution
LUA:
-- 1) Create new item and save it on a variable
local item_from_shop = Game.createItem(q_itemid, q_count)

-- 2) Give the new attribute to the item using the variable created in the first step
item_from_shop:setAttribute("description", "Este item foi comprado pelo shop e entregue para o jogador ".. player:getName() .."!")

-- 3) Add the item to the player
player:addItemEx(item_from_shop)

I added it to your code.

LUA:
function onSay(cid, words, param)
    local storage = 54073 -- Make sure to select non-used storage. This is used to prevent SQL load attacks.
    local cooldown = 15 -- in seconds.
    local player = Player(cid)
    if player:getStorageValue(storage) <= os.time() then
        player:setStorageValue(storage, os.time()...
LUA:
-- 1) Create new item and save it on a variable
local item_from_shop = Game.createItem(q_itemid, q_count)

-- 2) Give the new attribute to the item using the variable created in the first step
item_from_shop:setAttribute("description", "Este item foi comprado pelo shop e entregue para o jogador ".. player:getName() .."!")

-- 3) Add the item to the player
player:addItemEx(item_from_shop)

I added it to your code.

LUA:
function onSay(cid, words, param)
    local storage = 54073 -- Make sure to select non-used storage. This is used to prevent SQL load attacks.
    local cooldown = 15 -- in seconds.
    local player = Player(cid)
    if player:getStorageValue(storage) <= os.time() then
        player:setStorageValue(storage, os.time() + cooldown)
        -- Create the query
        local orderQuery = db.storeQuery("SELECT `id`, `type`, `itemid`, `count` FROM `shop_orders` WHERE `account_id` = " ..player:getAccountId() .. " LIMIT 1;")
        -- Detect if we got any results
        if orderQuery ~= false then
            -- Fetch order values
            local q_id = result.getDataInt(orderQuery, "id")
            local q_type = result.getDataInt(orderQuery, "type")
            local q_itemid = result.getDataInt(orderQuery, "itemid")
            local q_count = result.getDataInt(orderQuery, "count")
            result.free(orderQuery)
            -- ORDER TYPE 1 (Regular item shop products)
            if q_type == 1 then
                -- Get wheight
                if player:getFreeCapacity() >= ItemType(q_itemid):getWeight(q_count) then
                    db.query("DELETE FROM `shop_orders` WHERE `id` = " .. q_id .. ";")
                    -- New code --
                    local item_from_shop = Game.createItem(q_itemid, q_count)
                    item_from_shop:setAttribute("description", "Este item foi comprado pelo shop e entregue para o jogador ".. player:getName() .."!")
                    player:addItemEx(item_from_shop)
                    --
                    player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received " .. q_count .. " x " .. ItemType(q_itemid):getName() .. "!")
                else
                    player:sendTextMessage(MESSAGE_INFO_DESCR, "Need more CAP!")
                end
            end
            -- Add custom order types here
            -- Type 2 is reserved for premium days and is handled on website, not needed here.
            -- Type 3 is reserved for character gender(sex) change and is handled on website as well.
            -- So use type 4+ for custom stuff, like etc packages.
            -- if q_type == 4 then
            -- end
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have no orders.")
        end
    else
        player:sendTextMessage(MESSAGE_STATUS_SMALL,"Can only be executed once every " .. cooldown .. " seconds. Remaining cooldown: " .. player:getStorageValue(storage) - os.time())
    end
    return false
end
 
Last edited:
Solution
Back
Top