Em 09/03/2019 em 22:20, gabriel28 disse:Desculpem pelo título chamativo e/ou pela área está incorreta, mas enfim, lhes trago a solução definitiva pros problemas de bug relacionados a conteiners, como ficar comprando bp's infinitamente até crashar o server, stackar várias bps dentro de bps, jogar dentro da casa e usar o comando !leavehouse (ou algo do tipo) o que causa lag (talvez crash?) por conta da database ter que processar tantos itens saindo da house pro dp ou qualquer outra merda desse tipo.
Vá em ...\data\npc\lib\npcsystem procure por: -- Handles onBuy events. If you wish to handle this yourself, use the CALLBACK_ONBUY callback.
Substitua toda a função por:
function NpcHandler:onBuy(cid, itemid, subType, amount, ignoreCap, inBackpacks) local config = { sto = 11000, --storage tempo = 60, --tempo de cooldown para comprar novamente it = {2144, 2149}, --id dos itens total = 10 --total de itens que pode ser comprado por vez } if isInArray(config.it, itemid) and amount >= config.total then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "nao pode comprar mais que "..config.total.." itens desse.") return false elseif getPlayerStorageValue(cid, config.sto) > os.time() and isInArray(config.it, itemid) and amount <= config.total then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "espere "..(getPlayerStorageValue(cid, config.sto) - os.time()).." segundo(s) para comprar novamente.") return false elseif isInArray(config.it, itemid) and amount <= config.total then setPlayerStorageValue(cid, config.sto, os.time() + config.tempo) end local callback = self:getCallback(CALLBACK_ONBUY) if(callback == nil or callback(cid, itemid, subType, amount, ignoreCap, inBackpacks)) then if(self:processModuleCallback(CALLBACK_ONBUY, cid, itemid, subType, amount, ignoreCap, inBackpacks)) then -- end end end
Explicando:
Se o player tentar comprar mais de X itens de id Y, o npc não irá vender. Quando o player comprar uma quantidade menor que X, ganhará um cooldown de Z segundos até poder comprar novamente. Tudo isso configurável na tabela.
Pra te prejudicar com esse tipo de bug agora, só se o "player" tiver com uma puta vontade de te foder.
Testado e totalmente funcional em TFS 0.4 rev 3884, mas qualquer coisa é só adaptar pra outras versões que tenho certeza que funciona.
EDIT: Não sei se já tem script similar por ai, mas esse ai é de minha autoria.
Entao acho que o meu e diferente , pode da uma olhada?
-- Advanced NPC System (Created by Jiddo),
-- Modified by Talaturen.
if(NpcSystem == nil) then
-- Loads the underlying classes of the npcsystem.
dofile(getDataDir() .. 'npc/lib/npcsystem/keywordhandler.lua')
dofile(getDataDir() .. 'npc/lib/npcsystem/queue.lua')
dofile(getDataDir() .. 'npc/lib/npcsystem/npchandler.lua')
dofile(getDataDir() .. 'npc/lib/npcsystem/modules.lua')
-- Global npc constants:
-- Keyword nestling behavior. For more information look at the top of keywordhandler.lua
KEYWORD_BEHAVIOR = BEHAVIOR_NORMAL_EXTENDED
-- Greeting and unGreeting keywords. For more information look at the top of modules.lua
FOCUS_GREETWORDS = {'hi', 'hello', 'hey'}
FOCUS_FAREWELLWORDS = {'bye', 'farewell', 'cya'}
-- The word for requesting trade window. For more information look at the top of modules.lua
SHOP_TRADEREQUEST = {'offer', 'trade'}
-- The word for accepting/declining an offer. CAN ONLY CONTAIN ONE FIELD! For more information look at the top of modules.lua
SHOP_YESWORD = {'yes'}
SHOP_NOWORD = {'no'}
-- Pattern used to get the amount of an item a player wants to buy/sell.
PATTERN_COUNT = '%d+'
-- Talkdelay behavior. For more information, look at the top of npchandler.lua.
NPCHANDLER_TALKDELAY = TALKDELAY_ONTHINK
-- Conversation behavior. For more information, look at the top of npchandler.lua.
NPCHANDLER_CONVBEHAVIOR = CONVERSATION_DEFAULT
-- Constant strings defining the keywords to replace in the default messages.
-- For more information, look at the top of npchandler.lua...
TAG_PLAYERNAME = '|PLAYERNAME|'
TAG_ITEMCOUNT = '|ITEMCOUNT|'
TAG_TOTALCOST = '|TOTALCOST|'
TAG_ITEMNAME = '|ITEMNAME|'
TAG_QUEUESIZE = '|QUEUESIZE|'
NpcSystem = {}
-- Gets an npcparameter with the specified key. Returns nil if no such parameter is found.
function NpcSystem.getParameter(key)
local ret = getNpcParameter(tostring(key))
if((type(ret) == 'number' and ret == 0) or ret == nil) then
return nil
else
return ret
end
end
-- Parses all known parameters for the npc. Also parses parseable modules.
function NpcSystem.parseParameters(npcHandler)
local ret = NpcSystem.getParameter('idletime')
if(ret ~= nil) then
npcHandler.idleTime = tonumber(ret)
end
local ret = NpcSystem.getParameter('talkradius')
if(ret ~= nil) then
npcHandler.talkRadius = tonumber(ret)
end
local ret = NpcSystem.getParameter('message_greet')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_GREET, ret)
end
local ret = NpcSystem.getParameter('message_farewell')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_FAREWELL, ret)
end
local ret = NpcSystem.getParameter('message_decline')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_DECLINE, ret)
end
local ret = NpcSystem.getParameter('message_needmorespace')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_NEEDMORESPACE, ret)
end
local ret = NpcSystem.getParameter('message_needspace')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_NEEDSPACE, ret)
end
local ret = NpcSystem.getParameter('message_sendtrade')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_SENDTRADE, ret)
end
local ret = NpcSystem.getParameter('message_noshop')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_NOSHOP, ret)
end
local ret = NpcSystem.getParameter('message_oncloseshop')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_ONCLOSESHOP, ret)
end
local ret = NpcSystem.getParameter('message_onbuy')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_ONBUY, ret)
end
local ret = NpcSystem.getParameter('message_onsell')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_ONSELL, ret)
end
local ret = NpcSystem.getParameter('message_missingmoney')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_MISSINGMONEY, ret)
end
local ret = NpcSystem.getParameter('message_needmoney')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_NEEDMONEY, ret)
end
local ret = NpcSystem.getParameter('message_missingitem')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_MISSINGITEM, ret)
end
local ret = NpcSystem.getParameter('message_needitem')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_NEEDITEM, ret)
end
local ret = NpcSystem.getParameter('message_idletimeout')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_IDLETIMEOUT, ret)
end
local ret = NpcSystem.getParameter('message_walkaway')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_WALKAWAY, ret)
end
local ret = NpcSystem.getParameter('message_alreadyfocused')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_ALREADYFOCUSED, ret)
end
local ret = NpcSystem.getParameter('message_placedinqueue')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_PLACEDINQUEUE, ret)
end
local ret = NpcSystem.getParameter('message_buy')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_BUY, ret)
end
local ret = NpcSystem.getParameter('message_sell')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_SELL, ret)
end
local ret = NpcSystem.getParameter('message_bought')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_BOUGHT, ret)
end
local ret = NpcSystem.getParameter('message_sold')
if(ret ~= nil) then
npcHandler:setMessage(MESSAGE_SOLD, ret)
end
-- Parse modules.
for parameter, module in pairs(Modules.parseableModules) do
local ret = NpcSystem.getParameter(parameter)
if(ret ~= nil) then
local number = tonumber(ret)
if(number ~= nil and number ~= 0) then
npcHandler:addModule(module:new())
end
end
end
end
end








info
Grupo: Visconde
Registrado: 26/08/10
Posts: 431
Reputação: +60
Gênero: Masculino
Char no Tibia: Gabriel Rookgaardian
Desculpem pelo título chamativo e/ou pela área está incorreta, mas enfim, lhes trago a solução definitiva pros problemas de bug relacionados a conteiners, como ficar comprando bp's infinitamente até crashar o server, stackar várias bps dentro de bps, jogar dentro da casa e usar o comando !leavehouse (ou algo do tipo) o que causa lag (talvez crash?) por conta da database ter que processar tantos itens saindo da house pro dp ou qualquer outra merda desse tipo.
Vá em ...\data\npc\lib\npcsystem procure por: -- Handles onBuy events. If you wish to handle this yourself, use the CALLBACK_ONBUY callback.
Substitua toda a função por:
Explicando:
Se o player tentar comprar mais de X itens de id Y, o npc não irá vender. Quando o player comprar uma quantidade menor que X, ganhará um cooldown de Z segundos até poder comprar novamente. Tudo isso configurável na tabela.
Pra te prejudicar com esse tipo de bug agora, só se o "player" tiver com uma puta vontade de te foder.
Testado e totalmente funcional em TFS 0.4 rev 3884, mas qualquer coisa é só adaptar pra outras versões que tenho certeza que funciona.
EDIT: Não sei se já tem script similar por ai, mas esse ai é de minha autoria.
Editado Março 9 por gabriel28