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

wand sell items

Elgenady

Veteran OT User
Joined
Aug 5, 2011
Messages
1,638
Solutions
35
Reaction score
352
Hello
i need help in script that help me sell items by wand when use wand on x items its disappear and give me money like i sell with rashid
i use 8.60
tfs 0.4-dev
sorry for my english
Id of items.. same id in rashid script
 
Code:
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 onAddItem(moveItem, tileItem, position, cid)

     if getThingfromPos(position).actionid == 8001 then
         local x = items[moveItem.itemid]
         if x then
             doRemoveItem(moveItem.uid, 1)
             doPlayerAddMoney(cid, x)
             local info = getItemInfo(moveItem.itemid)
             doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You sold "..info.article.." "..info.name.." for "..x.." gold.")
             doSendMagicEffect(position, CONST_ME_FIREAREA)
         elseif isContainer(moveItem.uid) then
             local m, size, t, xt = 0, getContainerSize(moveItem.uid), {}, {}
             if size == 0 then
                 doPlayerSendCancel(cid, "This container is empty.")
                 doRemoveItem(moveItem.uid, 1)
                 doPlayerAddItem(cid, moveItem.itemid, 1)
                 doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
                 return true
             end
             for s = 0, size do
                 local citem = getContainerItem(moveItem.uid, s)
                 local cx = items[citem.itemid]
                 if cx then
                     table.insert(t, citem)
                 else
                     table.insert(xt, citem)
                 end
             end
             if #t > 0 then
                 for r = 1, #t do
                     m = m + items[t[r].itemid]
                 end
             end           
             if m > 0 then
                 doPlayerAddMoney(cid, m)
                 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You sold your items for "..m.." gold.")
                 doSendMagicEffect(getThingPos(cid), CONST_ME_FIREWORK_YELLOW)
             else
                 doPlayerSendCancel(cid, "There is nothing in this container that is sellable.")
                 doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
             end   
             doRemoveItem(moveItem.uid)
             doSendMagicEffect(position, CONST_ME_FIREAREA)
             local bp = doPlayerAddItem(cid, moveItem.itemid, 1)
             if #xt > 0 then
                 for b = 1, #xt do
                     if xt[b].itemid > 0 then
                         doAddContainerItem(bp, xt[b].itemid, xt[b].type)
                     end
                 end
             end
         else
         doPlayerAddItem(cid, moveItem.itemid, 1)
doRemoveItem(moveItem.uid, 1)
             doPlayerSendCancel(cid, "You can't sell this item.")
             doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
         end
     end
     return true
end
 
You can add it with itemid or actionid of the tile instead of the items.
Code:
<movevent type="AddItem" tileitem="1" actionid="8001" event="script" value="sellfire.lua"/>
 
have error here its clone backpack when try to sell items with backpack it clone empty bp for me and when throw anything amount 100 or 50 or 10 its back me just one x and 99 stay in flam example if me throw 50 gp its back 1gp for me and 49 spet on flam and error in console
JKgaEAB5h.png
 
You can also just do this
Code:
doRemoveItem(moveItem.uid)
So without any count.
when do this its clone empty bp and if i throw xamount 100 in flam 99 disappear and just 1x back to me
Code:
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 onAddItem(moveItem, tileItem, position, cid)

     if getThingfromPos(position).actionid == 8001 then
         local x = items[moveItem.itemid]
         if x then
             doRemoveItem(moveItem.uid)
             doPlayerAddMoney(cid, x)
             local info = getItemInfo(moveItem.itemid)
             doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You sold "..info.article.." "..info.name.." for "..x.." gold.")
             doSendMagicEffect(position, CONST_ME_FIREAREA)
         elseif isContainer(moveItem.uid) then
             local m, size, t, xt = 0, getContainerSize(moveItem.uid), {}, {}
             if size == 0 then
                 doPlayerSendCancel(cid, "This container is empty.")
                 doRemoveItem(moveItem.uid)
                 doPlayerAddItem(cid, moveItem.itemid, 1)
                 doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
                 return true
             end
             for s = 0, size do
                 local citem = getContainerItem(moveItem.uid, s)
                 local cx = items[citem.itemid]
                 if cx then
                     table.insert(t, citem)
                 else
                     table.insert(xt, citem)
                 end
             end
             if #t > 0 then
                 for r = 1, #t do
                     m = m + items[t[r].itemid]
                 end
             end          
             if m > 0 then
                 doPlayerAddMoney(cid, m)
                 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You sold your items for "..m.." gold.")
                 doSendMagicEffect(getThingPos(cid), CONST_ME_FIREWORK_YELLOW)
             else
                 doPlayerSendCancel(cid, "There is nothing in this container that is sellable.")
                 doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
             end  
             doRemoveItem(moveItem.uid)
             doSendMagicEffect(position, CONST_ME_FIREAREA)
             local bp = doPlayerAddItem(cid, moveItem.itemid, 1)
             if #xt > 0 then
                 for b = 1, #xt do
                     if xt[b].itemid > 0 then
                         doAddContainerItem(bp, xt[b].itemid, xt[b].type)
                     end
                 end
             end
         else
         doPlayerAddItem(cid, moveItem.itemid, 1)
doRemoveItem(moveItem.uid)
             doPlayerSendCancel(cid, "You can't sell this item.")
             doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
         end
     end
     return true
end
 
Code:
doPlayerAddItem(cid, moveItem.itemid, moveItem.type)
When exactly doesn't it remove the bp, can you give the location in the script?(you can test this with print).
 
Do you have this with all bps? Only with bps? What is in the bps, is it only with empty bps or with items, do you get textmessages?
Give some more information.
 
with all bp's when i throw bp items for sale its sell items and back for me 2 empty bp's and send me msg u sold x items for x money... and if i throw bp with items not for sale its back 2 bp's but one empty and one with items and send me msg u can't sell this items
 
Code:
    <movevent type="AddItem" itemid="11350;2181;11295-11299;8885;2519;2392;8910;8871;2393;2528;2195;2516;2498;2492;2656;2514;2472;2520;2470;2503;7897;2466;8873;3968" event="script" value="sellfire.lua"/>
    <movevent type="AddItem" itemid="2000;2001;2003;2004;1999;1998;1997;1996;1995;1994;1993;1992;1991;1990;1989;1988;1987" event="script" value="sellfire.lua"/>
    <movevent type="AddItem" tileitem="1" actionid="8001" event="script" value="sellfire.lua"/>

that in my movement.xml
 
Remove this
Code:
<movevent type="AddItem" itemid="11350;2181;11295-11299;8885;2519;2392;8910;8871;2393;2528;2195;2516;2498;2492;2656;2514;2472;2520;2470;2503;7897;2466;8873;3968" event="script" value="sellfire.lua"/>
<movevent type="AddItem" itemid="2000;2001;2003;2004;1999;1998;1997;1996;1995;1994;1993;1992;1991;1990;1989;1988;1987" event="script" value="sellfire.lua"/>
 
Back
Top