Postado Março 29, 2015 10 anos Este é um post popular. Esse sistema consiste em criar um log .txt em data/logs/trades mostrando quais itens foram passados entre os jogadores dentro do seu servidor! Em data/creaturescripts/scripts/ crie um arquivo .lua chamado: checktrades.lua e dentro coloque: local servers = {[0] = 'server1', [1] = 'server2', [2] = 'server3'} local function getType(item) return (item.type > 0) and item.type or 1 end Log = {} Log.__index = Log function Log.create() local t = {} setmetatable(t, Log) t.file = servers[getConfigValue("worldId")] .. "/" .. os.date("%B-%d-%Y", os.time()) .. ".txt" t.str, t.cstr, t.con = '', '', 0 return t end function Log:write() local f = io.open("data/logs/trades/" .. self.file, "a+") if not f then return false end f:write(self.str) f:close() end function Log:containerString() self.cstr = '' for i = 1, self.con do self.cstr = self.cstr .. '-> ' end end function Log:addContainer() self.con = self.con + 1 self:containerString() end function Log:closeContainer() self.con = self.con - 1 self:containerString() end function Log:setLine(txt) self.str = self.str .. self.cstr .. txt .. '\n' end function Log:kill() self.file, self.cstr, self.str, self.con = "", "", "", -1 end function onTradeAccept(cid, target, item, targetItem) local this = Log.create() local name, tname = getCreatureName(cid), getCreatureName(target) this:setLine("Trade between " .. name .. " and " .. tname .. " || [" .. os.date("%d/%m/%Y %H:%M:%S") .. "]") local function logging(cid, item) this:setLine(getCreatureName(cid) .. " traded:") local function scanContainer(cid, uid) for k = (getContainerSize(uid) - 1), 0, -1 do local tmp = getContainerItem(uid, k) this:setLine(getItemNameById(tmp.itemid) .. " x " .. getType(tmp) .. " || itemid: " .. tmp.itemid) if isContainer(tmp.uid) then this:addContainer() scanContainer(cid, tmp.uid) this:closeContainer() end end end this:setLine(getItemNameById(item.itemid) .. " x " .. getType(item) .. " || itemid: " .. item.itemid) if isContainer(item.uid) then this:addContainer() scanContainer(cid, item.uid) this:closeContainer() end end logging(cid, item) logging(target, targetItem) this:setLine("END OF THIS TRADE --------------\n") this:write() this:kill() return true end Em data/creaturescripts adicione no creaturescripts.xml a seguinte linha: <event type="trade" name="tradeCheck" event="script" value="checktrades.lua"/> Em data/creaturescripts/scripts/ abra o arquivo login.lua e adicione: registerCreatureEvent(cid, "tradeCheck") Pronto, agora você poderá monitorar os trades em seu servidor! Créditos: Anonimo
Postado Março 30, 2015 10 anos Seu tutorial foi aprovado, você recebeu um ponto de reputação e o tópico será movido para a área correta. Te ajudei?? REP + e ficamos quites... http://www.tibiaking.com/forum/uploads/emoticons/default_happyy.png' alt=';D'> Atenciosamente, Daniel. Abraços! Meus tutoriais: Programação: Resolvendo QUALQUER erro na data base. Scripts (system's, creaturescripts, mod's, NPC's, etc): (Sistema) GOD Ambient Light Full. Adicionando novas mounts ao servidor [NPC] Papai Noel que dá presente todo ano. Web-site: Resolvendo problema de caracteres especiais em PHP Formatando textos em PHP! Mudando a cor, tamanho, fonte, etc. Criando e configurando tabelas para paginas PHP
Postado Março 31, 2015 10 anos Bem eficiente esse script, obrigado por compartilhar ... STYLLER OT 2022
Postado Março 31, 2015 10 anos Obrigado por compartilhar, irei adicionar no meu futuro server. @edit Caso eu queira mudar o nome desse "chat" para NEGOCIOS onde eu mudaria? local f = io.open("data/logs/trades/ AQUIII ? Editado Março 31, 2015 10 anos por brendoonh (veja o histórico de edições)
Postado Outubro 30, 2017 7 anos Em 29/03/2015 em 15:44, One Punch Man disse: Esse sistema consiste em criar um log .txt em data/logs/trades mostrando quais itens foram passados entre os jogadores dentro do seu servidor! Em data/creaturescripts/scripts/ crie um arquivo .lua chamado: checktrades.lua e dentro coloque: local servers = {[0] = 'server1', [1] = 'server2', [2] = 'server3'} local function getType(item) return (item.type > 0) and item.type or 1 end Log = {} Log.__index = Log function Log.create() local t = {} setmetatable(t, Log) t.file = servers[getConfigValue("worldId")] .. "/" .. os.date("%B-%d-%Y", os.time()) .. ".txt" t.str, t.cstr, t.con = '', '', 0 return t end function Log:write() local f = io.open("data/logs/trades/" .. self.file, "a+") if not f then return false end f:write(self.str) f:close() end function Log:containerString() self.cstr = '' for i = 1, self.con do self.cstr = self.cstr .. '-> ' end end function Log:addContainer() self.con = self.con + 1 self:containerString() end function Log:closeContainer() self.con = self.con - 1 self:containerString() end function Log:setLine(txt) self.str = self.str .. self.cstr .. txt .. '\n' end function Log:kill() self.file, self.cstr, self.str, self.con = "", "", "", -1 end function onTradeAccept(cid, target, item, targetItem) local this = Log.create() local name, tname = getCreatureName(cid), getCreatureName(target) this:setLine("Trade between " .. name .. " and " .. tname .. " || [" .. os.date("%d/%m/%Y %H:%M:%S") .. "]") local function logging(cid, item) this:setLine(getCreatureName(cid) .. " traded:") local function scanContainer(cid, uid) for k = (getContainerSize(uid) - 1), 0, -1 do local tmp = getContainerItem(uid, k) this:setLine(getItemNameById(tmp.itemid) .. " x " .. getType(tmp) .. " || itemid: " .. tmp.itemid) if isContainer(tmp.uid) then this:addContainer() scanContainer(cid, tmp.uid) this:closeContainer() end end end this:setLine(getItemNameById(item.itemid) .. " x " .. getType(item) .. " || itemid: " .. item.itemid) if isContainer(item.uid) then this:addContainer() scanContainer(cid, item.uid) this:closeContainer() end end logging(cid, item) logging(target, targetItem) this:setLine("END OF THIS TRADE --------------\n") this:write() this:kill() return true end Em data/creaturescripts adicione no creaturescripts.xml a seguinte linha: <event type="trade" name="tradeCheck" event="script" value="checktrades.lua"/> Em data/creaturescripts/scripts/ abra o arquivo login.lua e adicione: registerCreatureEvent(cid, "tradeCheck") Pronto, agora você poderá monitorar os trades em seu servidor! Créditos: Anonimo Desculpa reviver o tópico, achei esse sistema interessante, mas retorna um erro na distro por causa do <event type="trade" uso tfs 0.4 cliente 8.60 poderia me dar uma ajudinha? kkk
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.