Witam przychodz? z pytaniem jakich funkcji u?y? by zabezpieczy? serwer przed reklamami chodzi o to, ?e jak kto? wy?le ip innego serwera dostaje kicka tak samo z linkami do discorda
W funkcji podpi?tej do komendy odpowiedzialnej za prywatne wiadomo?ci wykonaj r?wnie? sprawdzanie za pomoc? tej funkcji (checkBannedWords). Je?li masz domy?lny prywatny czat (/msg), u?yj eventu:
W funkcji podpi?tej do komendy odpowiedzialnej za prywatne wiadomo?ci wykonaj r?wnie? sprawdzanie za pomoc? tej funkcji (checkBannedWords). Je?li masz domy?lny prywatny czat (/msg), u?yj eventu:
function onPrivateMessage(plr, cmd, target, ...)
if not (getElementData(plr, "player:logged") == true) then return end
if getElementData(plr,'player:mute') then outputChatBox('Posiadasz kar? wyciszenia! Uwa?asz ?e kara jest nies?uszna? Zaapeluj na discordzie.',plr) return end
if not target or not {...} then
outputChatBox('Poprawne u?ycie: #FFFF00/pm <nick/ID> <tre??>', plr, 255,255,255,true)
return
end
if getElementData(plr, "mute:player") then
outputChatBox("* Jeste? wyciszony!", plr)
return
end
if getElementData(plr, "antyspam:pw") == 2 then return end
setElementData(plr, "antyspam:pw", 2)
setTimer(function()
setElementData(plr, "antyspam:pw", false)
end, 3000, 1)
if checkBannedWords(msg) then return end
local text=table.concat({...}, ' ')
local target=findPlayer(plr, target)
if not target then
outputChatBox("Nie znaleziono podanego gracza.", plr, 255,0,0,true)
return
end
if not (getElementData(target, "player:logged") == true) then
outputChatBox("Podany gracz nie jest zalogowany.", plr, 255,0,0,true)
return end
local pmoff=getElementData(target,"pmoff")
if (pmoff) then
outputChatBox("Gracz: "..getPlayerName(target):gsub("#%x%x%x%x%x%x","").." posiada w??czony tryb ignorowania wiadomo?ci prywatnych.", plr, 255,0,0,true)
if (type(pmoff)=="string") then
outputChatBox("Pow?d ignorowania: " .. pmoff, plr, 255,0,0,true)
end
return
end
if getElementData(plr,"pmoff") then
outputChatBox("Posiadasz w??czony tryb ignorowania wiadomo?ci prywatnych. Osoba do kt?rej napisa?e?/a? nie b?dzie mog?a Ci odpisa?.", plr, 0,255,0, true)
end
if getElementData(target, "mute:player") then
outputChatBox("Ten gracz jest wyciszony, nie odpisze Ci!", plr, 255,0,0)
return
end
outputChatBox("#FFFFFF[#FFFF00Wys?ane] #FFFFFF(#FFFF00"..getElementData(target,"id").."#FFFFFF) #FFFF00"..getPlayerName(target):gsub("#%x%x%x%x%x%x","").."#FFFFFF: "..text.."", plr, 245, 219, 0, true)
outputChatBox("#FFFFFF[#FFFF00Odebrane] #FFFFFF(#FFFF00"..getElementData(plr,"id").."#FFFFFF) #FFFF00"..getPlayerName(plr):gsub("#%x%x%x%x%x%x","").."#FFFFFF: "..text.."", target, 225, 199, 0, true)
playSoundFrontEnd(target, 12)
local pm_text=('[PM] [%d]%s(sid:%d) >> [%d]%s(sid:%d): %s'):format(getElementData(plr,"id"), getPlayerName(plr):gsub("#%x%x%x%x%x%x",""), getElementData(plr,"player:sid"), getElementData(target,"id"), getPlayerName(target):gsub("#%x%x%x%x%x%x",""), getElementData(target,"player:sid"), text)
triggerEvent("admin:addText", resourceRoot, RGBToHex(255,0,0)..pm_text..RGBToHex(255,255,255),math.random(0,99))
triggerEvent("admin:logs", root, pm_text)
--triggerClientEvent(root, "onDebugMessage", resourceRoot, pm_text:gsub("#%x%x%x%x%x%x",""),1, "PM")
outputServerLog(pm_text)
exports["np-discord"]:connectWeb(('[PM] [%d]%s(sid:%d) >> [%d]%s(sid:%d): %s'):format(getElementData(plr,"id"), getPlayerName(plr):gsub("#%x%x%x%x%x%x",""), getElementData(plr,"player:sid"), getElementData(target,"id"), getPlayerName(target):gsub("#%x%x%x%x%x%x",""), getElementData(target,"player:sid"), text), "logipw")
end
addCommandHandler('pw', onPrivateMessage)
local BannedWords = {"22003", ":22", "22010", "22005", "tasa:", "discord.gg"}
addEventHandler("onPlayerChat",root,
function(msg)
function checkBannedWords(Message)
for _, BannedWord in ipairs(BannedWords) do
if (Message:lower()):find(BannedWord:lower()) then
return 2
end
end
local Chunks = {(Message:gsub("%s+", "")):match("(%d+)%.(%d+)%.(%d+)%.(%d+)")}
if (#Chunks == 4) then
return 1
end
return 0
end
-- Definitions
-- 1 = Might be an advert
-- 2 = Confirmed advert
local result = checkBannedWords(msg)
if (result == 1) then
cancelEvent()
outputChatBox("Your Message was detected as potential server advert and you're in trouble now if true.", source, 255, 0, 0)
outputServerLog("[SUSPECT-ADVERTISING] " .. getPlayerName(source) .. " (tried to) output '" .. msg .. "'")
local _players = getElementsByType("player")
for _, v in pairs(_players) do
if (getPlayerAccount(v)) then
if ((isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(v)), aclGetGroup("Admin")))) then
outputChatBox("[SUSPECT-ADVERTISING] " .. getPlayerName(source) .. " (tried to) output '" .. msg .. "'", v)
end
end
end
elseif (result == 2) then
cancelEvent()
local g_Name = getPlayerName(source)
local _r,_g,_b = getPlayerNametagColor(source)
outputChatBox( g_Name .. ":server-advertiser " .. ' was detected and temporarily banned' , g_Root, _r, _g, _b, false)
--banPlayer ( source, false, false, true, nil, "Don't advertise other servers, you got an 1-day ban for it now.", 86400 )
end
end
)
attempt to call global 'checkBannedWords' (a nil value)
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach