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

Wand sell items

Kuantikum

Member
Joined
Jul 3, 2015
Messages
221
Solutions
1
Reaction score
21
Hello guys,

Could someone help me with this script for version TFS 1.3?
It would be interesting for the script to be able to sell full stacks or more than 1 item at a time, currently it sells only 1 item at a time ...


LUA:
local items = {


   [11350] = 10000,
   [2181] = 5000,
   [11296] = 50000,
   [11298] = 14000,
   [8885] = 100000,
   [2519] = 8000,
   [2392] = 4000,
   [8910] = 12000,
   [8871] = 8000,
   [2393] = 20000,
   [11295] = 10000,
   [11299] = 10000,
   [2528] = 10000,
   [2195] = 40000,
   [2516] = 4000,
   [2498] = 40000,
   [2492] = 45000,
   [2656] = 12000,
   [2514] = 60000,
   [2472] = 150000,
   [2520] = 50000,
   [2470] = 50000,
   [2503] = 50000,
   [7897] = 11000,
   [2466] = 20000,
   [8873] = 3000,
   [3968] = 1000
}

function onUse(cid, item, fromPosition, itemEx, toPosition)

     local x = items[itemEx.itemid]
     if x then
         doRemoveItem(itemEx.uid, 1)
         doPlayerAddMoney(cid, x)
         local info = getItemInfo(itemEx.itemid)
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You sold "..info.article.." "..info.name.." for "..x.." gold.")
         doSendMagicEffect(getThingPos(cid), CONST_ME_FIREWORK_YELLOW)
     else
         doPlayerSendCancel(cid, "You can't sell this item.")
         doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
     end
     return true
end



I am very grateful! 😍😘🥰
 
Solution
Here is a revscript that will allow you to sell a full stack of stackable items or 1 of a single item.
Just change the itemid in the register (1337 at the bottom)
LUA:
local wandseller = Action()
local items = {
    [2466] = 20000,
    [8873] = 3000,
    [3968] = 1000,
    [2148] = 1
}

function wandseller.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local iValue = items[target.itemid]
    if iValue then
        local iCount = target:getCount() or 1
        if target:remove() then
            player:addMoney(iValue * iCount)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You sold " .. iCount .. "x " .. target:getName() .. " for " .. (iValue * iCount) .. " gold.")...
Here is a revscript that will allow you to sell a full stack of stackable items or 1 of a single item.
Just change the itemid in the register (1337 at the bottom)
LUA:
local wandseller = Action()
local items = {
    [2466] = 20000,
    [8873] = 3000,
    [3968] = 1000,
    [2148] = 1
}

function wandseller.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local iValue = items[target.itemid]
    if iValue then
        local iCount = target:getCount() or 1
        if target:remove() then
            player:addMoney(iValue * iCount)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You sold " .. iCount .. "x " .. target:getName() .. " for " .. (iValue * iCount) .. " gold.")
            player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
            return true
        end
    end
    player:sendCancelMessage("You can't sell this item.")
    player:getPosition():sendMagicEffect(CONST_ME_POFF)
    return true
end

wandseller:id(1337)
wandseller:register()

04:18 You sold 1x crown shield for 8000 gold.
04:19 You sold 1x crown shield for 8000 gold.
04:19 You sold 91x gold coin for 91 gold.
04:19 You sold 87x gold coin for 87 gold.
04:19 You sold 100x gold coin for 100 gold.
 
Solution
Here is a revscript that will allow you to sell a full stack of stackable items or 1 of a single item.
Just change the itemid in the register (1337 at the bottom)
LUA:
local wandseller = Action()
local items = {
    [2466] = 20000,
    [8873] = 3000,
    [3968] = 1000,
    [2148] = 1
}

function wandseller.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local iValue = items[target.itemid]
    if iValue then
        local iCount = target:getCount() or 1
        if target:remove() then
            player:addMoney(iValue * iCount)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You sold " .. iCount .. "x " .. target:getName() .. " for " .. (iValue * iCount) .. " gold.")
            player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
            return true
        end
    end
    player:sendCancelMessage("You can't sell this item.")
    player:getPosition():sendMagicEffect(CONST_ME_POFF)
    return true
end

wandseller:id(1337)
wandseller:register()

04:18 You sold 1x crown shield for 8000 gold.
04:19 You sold 1x crown shield for 8000 gold.
04:19 You sold 91x gold coin for 91 gold.
04:19 You sold 87x gold coin for 87 gold.
04:19 You sold 100x gold coin for 100 gold.



Thanks for responding, I just tested and I have these errors:
LUA:
Lua Script Error: [Test Interface]
data/actions/scripts/other/sellitems.lua
data/actions/scripts/other/sellitems.lua:1: attempt to call global 'Action' (a nil value)
stack traceback:
        [C]: in function 'Action'
        data/actions/scripts/other/sellitems.lua:1: in main chunk
[Warning - Event::checkScript] Can not load script: scripts/other/sellitems.lua


I have to register the wand in actions.xml don't I?
LUA:
<action itemid="xxxx" script="other/sellitems.lua"/>
Post automatically merged:

LUA:
local items = {
    [2466] = 20000,
    [8873] = 3000,
    [3968] = 1000,
    [2148] = 1
}

function wandseller.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local iValue = items[target.itemid]
    if iValue then
        local iCount = target:getCount() or 1
        if target:remove() then
            player:addMoney(iValue * iCount)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You sold " .. iCount .. "x " .. target:getName() .. " for " .. (iValue * iCount) .. " gold.")
            player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
            return true
        end
    end
    player:sendCancelMessage("You can't sell this item.")
    player:getPosition():sendMagicEffect(CONST_ME_POFF)
    return true
end
Code:

FIXED!
 
As I said, this is a revscript (actions script) not an actions script.
Just replace your onuse with the one from this one. -.-

LUA:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local iValue = items[target.itemid]
    if iValue then
        local iCount = target:getCount() or 1
        if target:remove() then
            player:addMoney(iValue * iCount)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You sold " .. iCount .. "x " .. target:getName() .. " for " .. (iValue * iCount) .. " gold.")
            player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
            return true
        end
    end
    player:sendCancelMessage("You can't sell this item.")
    player:getPosition():sendMagicEffect(CONST_ME_POFF)
    return true
end
 
As I said, this is a revscript (actions script) not an actions script.
Just replace your onuse with the one from this one. -.-

LUA:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local iValue = items[target.itemid]
    if iValue then
        local iCount = target:getCount() or 1
        if target:remove() then
            player:addMoney(iValue * iCount)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You sold " .. iCount .. "x " .. target:getName() .. " for " .. (iValue * iCount) .. " gold.")
            player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
            return true
        end
    end
    player:sendCancelMessage("You can't sell this item.")
    player:getPosition():sendMagicEffect(CONST_ME_POFF)
    return true
end

Thx very much, sry about that i dont know much yet!
Post automatically merged:

Would it be possible to add a variant to sell the item only if the item is in the player's backpack?
 
Last edited:
Back
Top