Postado Dezembro 23, 2014 10 anos Para quem não sabe, o sistema de notificação serve para alertar o jogador e punir sem precisar dar ban* *só insistir, ele será banido automaticamente, mas para isso terá que notificar 3 vezes. primeiramente executa isso no seu banco de dados CREATE TABLE `account_not` ( `id` int(11) NOT NULL AUTO_INCREMENT, `idacc` int(11) NOT NULL, `comment` varchar(255) NOT NULL, `not_by` int(11) NOT NULL, `not_at` bigint(20) NOT NULL, PRIMARY KEY (`id`,`idacc`) ); e depois isso ALTER TABLE accounts ADD qntnot INT(11) NOT NULL DEFAULT 0 Agora vai na pasta do seu servidor, abre o compat.lua e coloca isso: function getNots(name) local accountId = getAccountNumberByPlayerName(name) local resultId = db.storeQuery("SELECT `qntnot` FROM `accounts` WHERE `id` = " .. accountId .." LIMIT 1") if resultId ~= false then local nots = result.getDataInt(resultId, "qntnot") result.free(resultId) return nots end return 0 end function setNots(name, amount) return db:query("UPDATE `accounts` SET `qntnot` = ".. (getNots(name) + amount) .." WHERE `id` ="..getAccountNumberByPlayerName(name).."") end Feito o que foi falo acima, vai em talkaction/script e cria um arquivo em lua e coloca isso function onSay(cid, words, param, channel) local t = string.explode(tostring(param), ",") local player = Player(cid) if not player:getGroup():getAccess() then return true end local accountId = getAccountNumberByPlayerName(t[1]) if (accountId == 0) or (not t[1]) then doPlayerSendCancel(cid,"Insira um nome valido") return true end local resultId = db.storeQuery("SELECT 1 FROM `account_bans` WHERE `account_id` = " .. accountId) if resultId ~= false then result.free(resultId) Player(cid):sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,"Jogador já está banido.") return false end local coment = t[2] if (t[2] == "") or (t[2] == nil) or (coment == "") or (coment == nil) then coment = "Quebra de regra" end local tempo = not t[3] and 1 or t[3] setNots(t[1], tempo) db:query("INSERT INTO `account_not` (`idacc`, `comment`, `not_by`, `not_at`) VALUES (".. accountId .. ", " .. db.escapeString(coment) .. ", ".. player:getGuid() ..", "..os.time()..") ") for _, pid in ipairs(Game.getPlayers()) do pid:sendTextMessage(MESSAGE_STATUS_WARNING, "" .. getPlayerName(cid) .. ": A conta do jogador ".. t[1].. " foi notificada por "..getPlayerName(cid)..". Notificações setadas de "..getNots(t[1]) - tempo .." para ".. getNots(t[1])..". Motivo: "..tostring(coment)..".") end if getNots(t[1]) >= 3 then local target = Player(t[1]) if target then target:remove() end local banDays = 7 local tn = os.time() local comment = "Banido por conter 3 notificações." db:query("INSERT INTO `account_bans` (`account_id`, `reason`, `banned_at`, `expires_at`, `banned_by`) VALUES (" .. accountId .. ", " .. db.escapeString(comment) .. ", " .. tn .. ", " .. tn + (banDays * 86400) .. ", " .. player:getGuid() .. ")") db:query("DELETE FROM `account_not` WHERE `idacc` = " .. accountId.."") for _, pid in ipairs(Game.getPlayers()) do pid:sendTextMessage(MESSAGE_STATUS_WARNING, t[1].." foi banido por conter "..getNots(t[1]).." notificações.") end db:query("UPDATE `accounts` SET `qntnot` = ".. (getNots(t[1]) * 0) .." WHERE `id` ="..getAccountNumberByPlayerName(t[1]).."") end return true end Se ele não tiver a função string.explode só colocar isso no global.lua depois do dofile string.trim = function (str) return str:gsub("^%s*(.-)%s*$", "%1") end string.explode = function (str, sep, limit) if(type(sep) ~= 'string' or isInArray({tostring(str):len(), sep:len()}, 0)) then return {} end local i, pos, tmp, t = 0, 1, "", {} for s, e in function() return string.find(str, sep, pos) end do tmp = str:sub(pos, s - 1):trim() table.insert(t, tmp) pos = e + 1 i = i + 1 if(limit ~= nil and i == limit) then break end end tmp = str:sub(pos):trim() table.insert(t, tmp) return t end Por fim vai em talkaction.xml e coloque isso: <talkaction words="/not" separator=" " script="NOMEDOARQUIVO.lua" /> Como usar /not nome,comentario (opcional), quantidade(opcional) /not nome @edit Erro de nao gravar na db, corrigido. Créditos: narazaky (eu) Editado Dezembro 24, 2014 10 anos por narazaky (veja o histórico de edições) Te ajudei? Então Rep +
Postado Dezembro 24, 2014 10 anos Muito bom mesmo... TFS 0.4 DEV Página no facebook: https://www.facebook.com/Suporterking Skype: fabinhodias01 愛"A almapermanece em suas criações" 平 (Dou suporte apenas em tópicos..)
Postado Dezembro 24, 2014 10 anos Autor Muito bom cara, é de sua autoria? recebi um pedido por pm e fiz vou colocar os creditos All Valeuuu Editado Dezembro 24, 2014 10 anos por narazaky (veja o histórico de edições) Te ajudei? Então Rep +
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.