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

TalkAction [Gesior2012] TFS 1.4+ Add offers to Shop using talkaction

Gesior.pl

Mega Noob&LOL 2012
Senator
Joined
Sep 18, 2007
Messages
2,955
Solutions
98
Reaction score
3,351
Location
Poland
GitHub
gesior
There was script to add items to website Shop offer using talkaction for TFS 0.4 ( [GESIOR2012] Items Shop Installation/Administration (https://otland.net/threads/gesior2012-items-shop-installation-administration.170654/) ).

I made version for TFS 1.4+.

How to use:
1. Stand in front of item dropped on floor
2. Type /addshop 50 to add item with price 50 premium points
- if it's normal item or empty container (BP/bag), it will add it with it's count as 'item offer'
1646428284520.png
1646428454309.png
- if it's container and there is some item inside, script will add 'container offer' with container filled with first item found in BP
1646428211925.png
1646428473141.png


In data/talkactions/talkactions.xml add:
XML:
<talkaction words="/addshop" separator=" " script="add_shop_offer.lua" />
Create file data/talkactions/scripts/add_shop_offer.lua:
Lua:
function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end

    local price = tonumber(param)
    if not price or price <= 0 then
        player:sendTextMessage(MESSAGE_STATUS_WARNING, "Price must be higher than 0. Command use ex.: /addshop 50")
        return false
    end

    local lookPosition = player:getPosition()
    lookPosition:getNextPosition(player:getDirection())

    if not Tile(lookPosition) then
        player:sendTextMessage(MESSAGE_STATUS_WARNING, "There is no tile in front of you.")
        return false
    end

    local topThing = Tile(lookPosition):getTopVisibleThing(player)
    if not topThing:isItem() then
        player:sendTextMessage(MESSAGE_STATUS_WARNING, "There is no item in front of you.")
        return false
    end

    local itemType = ItemType(topThing:getId())
    if not itemType:isMovable() then
        player:sendTextMessage(MESSAGE_STATUS_WARNING, "Item in front of you is not movable.")
        return false
    end

    if itemType:isContainer() and topThing:getItem(0) then
        local containerId = itemType:getId()
        local containerItemCount = topThing:getCapacity()
        local firstItemInContainer = topThing:getItem(0)
        local itemId = firstItemInContainer:getId()
        local itemCount = firstItemInContainer:getCount()

        local offerName = (containerItemCount * itemCount) .. 'x ' .. firstItemInContainer:getName()
        local offerDescription = containerItemCount .. 'x You see ' .. firstItemInContainer:getDescription()

        db.query(
                'INSERT INTO `z_shop_offer` (`id`, `points`, `itemid1`, `count1`, `itemid2`, `count2`, ' ..
                        '`offer_type`, `offer_name`,`offer_description`) VALUES ' ..
                        '(NULL , ' .. price .. ', ' .. containerId .. ', ' .. containerItemCount .. ', ' ..
                        itemId .. ', ' .. itemCount .. ', \'container\', ' .. db.escapeString(offerName) ..
                        ', ' .. db.escapeString(offerDescription) .. ')'
        )
        player:sendTextMessage(
                MESSAGE_STATUS_WARNING,
                "Container >> " .. offerName .. " << added to SMS shop. Price set to " .. price .. " premium points."
        )

        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    else
        local itemId = itemType:getId()
        local itemCount = topThing:getCount()

        local offerName = itemCount .. 'x ' .. topThing:getName()
        local offerDescription = 'You see ' .. topThing:getDescription()

        db.query(
                'INSERT INTO `z_shop_offer` (`id`, `points`, `itemid1`, `count1`, `itemid2`, `count2`, ' ..
                        '`offer_type`, `offer_name`,`offer_description`) VALUES ' ..
                        '(NULL , ' .. price .. ', ' .. itemId .. ', ' .. itemCount .. ', ' ..
                        '0, 0, \'item\', ' .. db.escapeString(offerName) ..
                        ', ' .. db.escapeString(offerDescription) .. ')'
        )
        player:sendTextMessage(
                MESSAGE_STATUS_WARNING,
                "Item >> " .. offerName .. " << added to SMS shop. Price set to " .. price .. " premium points."
        )

        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    end

    return true
end
 
There was script to add items to website Shop offer using talkaction for TFS 0.4 ( [GESIOR2012] Items Shop Installation/Administration (https://otland.net/threads/gesior2012-items-shop-installation-administration.170654/) ).

I made version for TFS 1.4+.

How to use:
1. Stand in front of item dropped on floor
2. Type /addshop 50 to add item with price 50 premium points
- if it's normal item or empty container (BP/bag), it will add it with it's count as 'item offer'
View attachment 65996
View attachment 65997
- if it's container and there is some item inside, script will add 'container offer' with container filled with first item found in BP
View attachment 65994
View attachment 65998


In data/talkactions/talkactions.xml add:
XML:
<talkaction words="/addshop" separator=" " script="add_shop_offer.lua" />
Create file data/talkactions/scripts/add_shop_offer.lua:
Lua:
function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end

    local price = tonumber(param)
    if not price or price <= 0 then
        player:sendTextMessage(MESSAGE_STATUS_WARNING, "Price must be higher than 0. Command use ex.: /addshop 50")
        return false
    end

    local lookPosition = player:getPosition()
    lookPosition:getNextPosition(player:getDirection())

    if not Tile(lookPosition) then
        player:sendTextMessage(MESSAGE_STATUS_WARNING, "There is no tile in front of you.")
        return false
    end

    local topThing = Tile(lookPosition):getTopVisibleThing(player)
    if not topThing:isItem() then
        player:sendTextMessage(MESSAGE_STATUS_WARNING, "There is no item in front of you.")
        return false
    end

    local itemType = ItemType(topThing:getId())
    if not itemType:isMovable() then
        player:sendTextMessage(MESSAGE_STATUS_WARNING, "Item in front of you is not movable.")
        return false
    end

    if itemType:isContainer() and topThing:getItem(0) then
        local containerId = itemType:getId()
        local containerItemCount = topThing:getCapacity()
        local firstItemInContainer = topThing:getItem(0)
        local itemId = firstItemInContainer:getId()
        local itemCount = firstItemInContainer:getCount()

        local offerName = (containerItemCount * itemCount) .. 'x ' .. firstItemInContainer:getName()
        local offerDescription = containerItemCount .. 'x You see ' .. firstItemInContainer:getDescription()

        db.query(
                'INSERT INTO `z_shop_offer` (`id`, `points`, `itemid1`, `count1`, `itemid2`, `count2`, ' ..
                        '`offer_type`, `offer_name`,`offer_description`) VALUES ' ..
                        '(NULL , ' .. price .. ', ' .. containerId .. ', ' .. containerItemCount .. ', ' ..
                        itemId .. ', ' .. itemCount .. ', \'container\', ' .. db.escapeString(offerName) ..
                        ', ' .. db.escapeString(offerDescription) .. ')'
        )
        player:sendTextMessage(
                MESSAGE_STATUS_WARNING,
                "Container >> " .. offerName .. " << added to SMS shop. Price set to " .. price .. " premium points."
        )

        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    else
        local itemId = itemType:getId()
        local itemCount = topThing:getCount()

        local offerName = itemCount .. 'x ' .. topThing:getName()
        local offerDescription = 'You see ' .. topThing:getDescription()

        db.query(
                'INSERT INTO `z_shop_offer` (`id`, `points`, `itemid1`, `count1`, `itemid2`, `count2`, ' ..
                        '`offer_type`, `offer_name`,`offer_description`) VALUES ' ..
                        '(NULL , ' .. price .. ', ' .. itemId .. ', ' .. itemCount .. ', ' ..
                        '0, 0, \'item\', ' .. db.escapeString(offerName) ..
                        ', ' .. db.escapeString(offerDescription) .. ')'
        )
        player:sendTextMessage(
                MESSAGE_STATUS_WARNING,
                "Item >> " .. offerName .. " << added to SMS shop. Price set to " .. price .. " premium points."
        )

        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    end

    return true
end
how to use with this table? my shop table is different

Lua:
CREATE TABLE `z_shop_offer` (
  `id` int(11) NOT NULL,
  `category` int(11) NOT NULL,
  `coins` int(11) NOT NULL DEFAULT '0',
  `price` varchar(50) NOT NULL,
  `itemid` int(11) NOT NULL DEFAULT '0',
  `mount_id` varchar(100) NOT NULL,
  `addon_name` varchar(100) NOT NULL,
  `count` int(11) NOT NULL DEFAULT '0',
  `offer_type` varchar(255) DEFAULT NULL,
  `offer_description` text NOT NULL,
  `offer_name` varchar(255) NOT NULL,
  `offer_date` int(11) NOT NULL,
  `default_image` varchar(50) NOT NULL,
  `hide` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `z_shop_category` (`id`, `name`, `desc`, `button`, `hide`) VALUES
(2, 'Extra Services', 'Buy an extra service to transfer a character to another game world, to change your character name or sex, to change your account name, or to get a new recovery key.', '_sbutton_getextraservice.gif', 0),
(3, 'Mounts', 'Buy your characters one or more of the fabulous mounts offered here.', '_sbutton_getmount.gif', 0),
(4, 'Outfits', 'Buy your characters one or more of the fancy outfits offered here.', '_sbutton_getoutfit.gif', 0),
(5, 'Items', 'Buy items for your character be more stronger in the game.', '_sbutton_getitem.gif', 0);
 
Back
Top