darkmu
Well-Known Member
TFS 1.X
Can anyone help with this solution?
The player is going to the NPC (hi, trade) and disconnecting wifi and connecting very fast this makes him able to infinitely buy/sell all items using "sell all".
Can anyone help with this solution?
The player is going to the NPC (hi, trade) and disconnecting wifi and connecting very fast this makes him able to infinitely buy/sell all items using "sell all".
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local shop = {
{id=10503, buy=45, sell=0, name='veteran surprise box'},
{id=30882, buy=0, sell=15, name='gnome helmet'},
{id=30883, buy=0, sell=15, name='gnome armor'},
{id=30884, buy=0, sell=15, name='gnome legs'},
{id=30885, buy=0, sell=15, name='gnome shield'},
{id=30886, buy=0, sell=15, name='gnome sword'},
{id=37451, buy=0, sell=15, name='phantasmal axe'},
{id=36449, buy=0, sell=15, name='tagralt blade'},
{id=36418, buy=0, sell=15, name='toga mortis'},
{id=36417, buy=0, sell=15, name='galea mortis'},
{id=36416, buy=0, sell=15, name='bow of cataclysm'},
{id=36415, buy=0, sell=15, name='mortal mace'},
{id=36414, buy=0, sell=15, name='embrace of nature'},
{id=36413, buy=0, sell=15, name='bear skin'},
{id=34069, buy=0, sell=15, name='spirit guide'},
{id=34068, buy=0, sell=15, name='ectoplasmic shield'},
{id=34067, buy=0, sell=15, name='pendulet'},
{id=34065, buy=0, sell=15, name='dark whispers'},
{id=34063, buy=0, sell=15, name='energized limb'},
{id=34062, buy=0, sell=15, name='pair of dreamwalkers'},
{id=34061, buy=0, sell=15, name='dream shroud'},
{id=34060, buy=0, sell=15, name='winterblade'},
{id=34059, buy=0, sell=15, name='summerblade'},
{id=34058, buy=0, sell=15, name='shoulder plate'},
{id=34056, buy=0, sell=15, name='living armor'},
{id=34055, buy=0, sell=15, name='living vine bow'},
{id=40349, buy=0, sell=15, name='jungle flail'},
{id=40350, buy=0, sell=15, name='throwing axe'},
{id=40351, buy=0, sell=15, name='exotic legs'},
{id=40352, buy=0, sell=15, name='bast legs'},
{id=40353, buy=0, sell=15, name='jungle bow'},
{id=40354, buy=0, sell=15, name='makeshift boots'},
{id=40355, buy=0, sell=15, name='make-do boots'},
{id=40356, buy=0, sell=15, name='jungle rod'},
{id=40357, buy=0, sell=15, name='jungle wand'},
{id=40358, buy=0, sell=15, name='exotic amulet'},
{id=40359, buy=0, sell=15, name='jungle quiver'},
{id=38985, buy=0, sell=35, name='lion longbow'},
{id=38992, buy=0, sell=35, name='lion plate'},
{id=38991, buy=0, sell=35, name='lion spangenhelm'},
{id=39088, buy=0, sell=35, name='lion axe'},
{id=38989, buy=0, sell=35, name='lion shield'},
{id=38986, buy=0, sell=35, name='lion rod'},
{id=38987, buy=0, sell=35, name='lion wand'},
{id=38990, buy=0, sell=35, name='lion longsword'},
{id=39089, buy=0, sell=35, name='lion hammer'},
{id=38988, buy=0, sell=35, name='lion spellbook'},
{id=36466, buy=0, sell=35, name='the cobra amulet'},
{id=35228, buy=0, sell=35, name='cobra crossbow'},
{id=35229, buy=0, sell=35, name='cobra boots'},
{id=35230, buy=0, sell=35, name='cobra club'},
{id=35231, buy=0, sell=35, name='cobra axe'},
{id=35232, buy=0, sell=35, name='cobra hood'},
{id=35233, buy=0, sell=35, name='cobra sword'},
{id=35234, buy=0, sell=35, name='cobra wand'},
{id=35235, buy=0, sell=35, name='cobra rod'},
{id=32414, buy=0, sell=65, name='falcon circlet'},
{id=32415, buy=0, sell=65, name='falcon coif'},
{id=32416, buy=0, sell=65, name='falcon rod'},
{id=32417, buy=0, sell=65, name='falcon wand'},
{id=32418, buy=0, sell=65, name='falcon bow'},
{id=32419, buy=0, sell=65, name='falcon plate'},
{id=32420, buy=0, sell=65, name='falcon greaves'},
{id=32421, buy=0, sell=65, name='falcon shield'},
{id=32422, buy=0, sell=65, name='falcon escutcheon'},
{id=32423, buy=0, sell=65, name='falcon longsword'},
{id=32424, buy=0, sell=65, name='falcon battleaxe'},
{id=32425, buy=0, sell=65, name='falcon mace'},
{id=38917, buy=0, sell=85, name='soulcutter'},
{id=38918, buy=0, sell=85, name='soulshredder'},
{id=38919, buy=0, sell=85, name='soulbiter'},
{id=38920, buy=0, sell=85, name='souleater'},
{id=38921, buy=0, sell=85, name='soulcrusher'},
{id=38922, buy=0, sell=85, name='soulmaimer'},
{id=38923, buy=0, sell=85, name='soulbleeder'},
{id=38924, buy=0, sell=85, name='soulpiercer'},
{id=38925, buy=0, sell=85, name='soultainter'},
{id=38926, buy=0, sell=85, name='soulhexer'},
{id=38929, buy=0, sell=85, name='soulshell'},
{id=38930, buy=0, sell=85, name='soulmantle'},
{id=38931, buy=0, sell=85, name='soulshroud'},
{id=38928, buy=0, sell=85, name='soulstrider'},
{id=38927, buy=0, sell=85, name='soulshanks'},
{id=41530, buy=0, sell=180, name='eldritch shield'},
{id=41531, buy=0, sell=180, name='eldritch claymore'},
{id=41532, buy=0, sell=180, name='gilded eldritch claymore'},
{id=41533, buy=0, sell=180, name='eldritch warmace'},
{id=41534, buy=0, sell=180, name='gilded eldritch warmace'},
{id=41535, buy=0, sell=180, name='eldritch greataxe'},
{id=41536, buy=0, sell=180, name='gilded eldritch greataxe'},
{id=41537, buy=0, sell=180, name='eldritch cuirass'},
{id=41538, buy=0, sell=180, name='eldritch bow'},
{id=41539, buy=0, sell=180, name='gilded eldritch bow'},
{id=41540, buy=0, sell=180, name='eldritch quiver'},
{id=41541, buy=0, sell=180, name='eldritch breeches'},
{id=41542, buy=0, sell=180, name='eldritch wand'},
{id=41543, buy=0, sell=180, name='gilded eldritch wand'},
{id=41544, buy=0, sell=180, name='eldritch cowl'},
{id=41545, buy=0, sell=180, name='eldritch hood'},
{id=41546, buy=0, sell=180, name='eldritch folio'},
{id=41547, buy=0, sell=180, name='eldritch tome'},
{id=41548, buy=0, sell=180, name='eldritch rod'},
{id=41549, buy=0, sell=180, name='gilded eldritch rod'},
}
local function setNewTradeTable(table)
local items, item = {}
for i = 1, #table do
item = table[i]
items[item.id] = {id = item.id, buy = item.buy, sell = item.sell, subType = 0, name = item.name}
end
return items
end
local function onBuy(cid, item, subType, amount, ignoreCap, inBackpacks)
local player = Player(cid)
local itemsTable = setNewTradeTable(shop)
if not ignoreCap and player:getFreeCapacity() < ItemType(itemsTable[item].id):getWeight(amount) then
return player:sendTextMessage(MESSAGE_FAILURE, "You don't have enough cap.")
end
if itemsTable[item].buy then
if player:removeItem(Npc():getCurrencyTrading(), amount * itemsTable[item].buy) then
if amount > 1 then
currencyName = ItemType(Npc():getCurrencyTrading()):getPluralName():lower()
else
currencyName = ItemType(Npc():getCurrencyTrading()):getName():lower()
end
player:addItem(itemsTable[item].id, amount)
return player:sendTextMessage(MESSAGE_TRADE,
"Bought "..amount.."x "..itemsTable[item].name.." for "..itemsTable[item].buy * amount.." "..currencyName..".")
else
return player:sendTextMessage(MESSAGE_TRADE, "You don't have enough "..currencyName..".")
end
end
return true
end
local function onSell(cid, item, subType, amount, ignoreCap, inBackpacks)
local player = Player(cid)
local itemsTable = setNewTradeTable(shop)
if itemsTable[item].sell then
player:addItem(Npc():getCurrencyTrading(), itemsTable[item].sell * amount)
player:removeItem(itemsTable[item].id, amount)
return player:sendTextMessage(MESSAGE_INFO_DESCR, 'Sold '..amount..'x '..ItemType(itemsTable[item].id):getName() ..' for '..itemsTable[item].sell * amount..' gold tokens.')
end
return true
end
function onCreatureAppear(cid)
npcHandler:onCreatureAppear(cid)
end
function onCreatureDisappear(cid)
npcHandler:onCreatureDisappear(cid)
end
function onCreatureSay(cid, type, msg)
npcHandler:onCreatureSay(cid, type, msg)
end
function onThink()
npcHandler:onThink()
end
local function greetCallback(cid)
npcHandler.topic[cid] = 0
return true
end
local function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
local player = Player(cid)
if msgcontains(msg, "tokens") then
openShopWindow(cid, shop, onBuy, onSell)
npcHandler:say("Aqui esta as ofertas, venda os itens e compre as box para ter novas chances.", cid)
end
return true
end
local voices = { {text = 'Troco itens de bosses por platinum token e vendo veteranos surprise box!'} }
npcHandler:addModule(VoiceModule:new(voices))
npcHandler:setCallback(CALLBACK_ONADDFOCUS, onAddFocus)
npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus)
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())