• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

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

Gesior.pl

Mega Noob&LOL 2012
Senator
Premium User
Joined
Sep 18, 2007
Messages
2,629
Solutions
77
Reaction score
2,543
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
 
Top