Hey! I'm LOT, and I'm extreamly new to FacePunch. (Registured 5 minutes ago)
Anyways, I'm in inquiring about a fix for this problem I'm having. (and I cannot find anything about this anywhere)
Occasionally I'll see a Mingypoo or two rejoin my server multiple times, over and over in unison.
This is quite annoying due to the fact that I have a light weight addon that prints a message in chat & console consisting of: [Server] playername is joining the server!
As you can already tell, this is very spammy.
It's not a huge problem. I'm just wondering if it's a possability to have a small script temp ban players who take advantage of this.
Thanks in advance to anyone who might know how to fix this predicament of mine . Maybe in lua/autorun/server/example.lua?
- Also, sorry if I've posted this in the wrong section. Very new to FacePunch! :D
The only thing I can think of is calling the messages on PlayerInitialSpawn. If they're loading in, you could check their SteamID, where on disconnect, it adds a point that's only removed after 20 seconds? And if the point is still there when a player leaves, add a temp ban. This is buggy though because they could have GMod issues, etc..
True, definitally sounds like it could be buggy. Maybe configuring it to temp ban for 2 minutes or something after 3-5 rejoin attempts in "x" amount of time for stability? Idk how exactly it'd be done though, I'm a derp XD
[code]
local LeftPlayerData = {}
hook.Add("PlayerInitialSpawn", "ConnectPLY", function(ply) --add event for first spawn
if type(LeftPlayerData[ply].steamid) == "string" then --if their id is in the table then
if LeftPlayerData[ply].points["active"] >= 5 then --and if they have 5 or more points then
ply:Ban(5, "Too many connects") --5 min ban
ply:Kick("Too many connects") --kick
LeftPlayerData[ply] = nil --reset it, we already banned them
end
end
end )
--[[the reason we make the PlayerDisconnected hook and PlayerInitialSpawn hook is
because we can't check if they rejoined or if it was their first time joining the server
]]
hook.Add("PlayerDisconnected", "DCPly", function(ply) --add event for disconnect
if LeftPlayerData[ply].steamid == ply:SteamID() then --if data exists already for this player, load it
local activePoints = LeftPlayerData[ply].points["active"] --their current points
LeftPlayerData[ply].points = {curtime = CurTime() + 15, active = activePoints+1} --add a point and set the expiry time to curtime()+15
else
LeftPlayerData[ply].points["active"] = 0 --if it doesn't, make new data
LeftPlayerData[ply].steamid = ply:SteamID() --set their id
local activePoints = LeftPlayerData[ply].points["active"] --their active points
LeftPlayerData[ply].points = {curtime = CurTime() + 15, active = activePoints+1} --add one to their points (0+1)
end
end )
hook.Add("Think", "ThinkCode", function() --add event every milisecond
for k,v in pairs(LeftPlayerData) do --loop through leftplayerdata
if CurTime() >= LeftPlayer[v]["points"].curtime then --if curtime is over their expiry time
LeftPlayerData[v]["points"].curtime = nil --delete their curtime
if LeftPlayerData[v]["points"].active > 0 then --if they have more than 0 points..
LeftPlayerData[v]["points"].active = LeftPlayerData[v]["points"].active - 1 --take one
else --if they have 0 points..
LeftPlayerData[v] = nil --delete them
print("// reset data for "..LeftPlayerData[v].steamid) --reset them
end
end
end
end
end )
[/code]
it's something like that anyway, try it out (place in autorun/server)
harder to reset each time they leave
You could make a table storing the Steam IDs of the last x players who joined (3-5?). Have so that the Steam ID is the key, and the value would be 1. If a player joins with an ID that's already in that table, add +1 to the value. If the value goes above x, temporarily ban him. Remember to reset the value for players who disconnect a certain amount of time after they joined. Could that work?
Edit: Ninjad, the above post should work well
give my post a go, if it doesn't work let me know and i'll fix it. it's untested but generally should work?
[QUOTE=tyguy;48106014][code]
local LeftPlayerData = {}
hook.Add("PlayerInitialSpawn", "ConnectPLY", function(ply) --add event for first spawn
if type(LeftPlayerData[ply].steamid) == "string" then --if their id is in the table then
if LeftPlayerData[ply].points["active"] >= 5 then --and if they have 5 or more points then
ply:Ban(5, "Too many connects") --5 min ban
ply:Kick("Too many connects") --kick
LeftPlayerData[ply] = nil --reset it, we already banned them
end
end
end )
--[[the reason we make the PlayerDisconnected hook and PlayerInitialSpawn hook is
because we can't check if they rejoined or if it was their first time joining the server
]]
hook.Add("PlayerDisconnected", "DCPly", function(ply) --add event for disconnect
if LeftPlayerData[ply].steamid == ply:SteamID() then --if data exists already for this player, load it
local activePoints = LeftPlayerData[ply].points["active"] --their current points
LeftPlayerData[ply].points = {curtime = CurTime() + 15, active = activePoints+1} --add a point and set the expiry time to curtime()+15
else
LeftPlayerData[ply].points["active"] = 0 --if it doesn't, make new data
LeftPlayerData[ply].steamid = ply:SteamID() --set their id
local activePoints = LeftPlayerData[ply].points["active"] --their active points
LeftPlayerData[ply].points = {curtime = CurTime() + 15, active = activePoints+1} --add one to their points (0+1)
end
end )
hook.Add("Think", "ThinkCode", function() --add event every milisecond
for k,v in pairs(LeftPlayerData) do --loop through leftplayerdata
if CurTime() >= LeftPlayer[v]["points"].curtime then --if curtime is over their expiry time
LeftPlayerData[v]["points"].curtime = nil --delete their curtime
if LeftPlayerData[v]["points"].active > 0 then --if they have more than 0 points..
LeftPlayerData[v]["points"].active = LeftPlayerData[v]["points"].active - 1 --take one
else --if they have 0 points..
LeftPlayerData[v] = nil --delete them
print("// reset data for "..LeftPlayerData[v].steamid) --reset them
end
end
end
end
end )
[/code]
it's something like that anyway, try it out (place in autorun/server)
harder to reset each time they leave[/QUOTE]
Just inplemented this in autorun/server then restarted. I had a friend test this. Sadly doesn't look like it's working :/ he's still able to spam [SERVER] playername is joing the server!
[QUOTE=LOT;48106972]Just inplemented this in autorun/server then restarted. I had a friend test this. Sadly doesn't look like it's working :/ he's still able to spam [SERVER] playername is joing the server![/QUOTE]
Any errors in console?
Instead of banning players, you could save their steam ids and choose not to display the join message again if they recently joined. Using timers would be the simplest way to remove the ID over time.
[QUOTE=AK to Spray;48107387]Instead of banning players, you could save their steam ids and choose not to display the join message again if they recently joined. Using timers would be the simplest way to remove the ID over time.[/QUOTE]
I believe timers would be the worst way, as they are global and wouldn't work for this.
i.e: every 15 sec on timer it removes ID from players, timer on 8 seconds, player has to only wait 7 seconds
unless of course you mean adding a variable each second on the timer but that would be crazy :P
[QUOTE=tyguy;48107311]Any errors in console?[/QUOTE]
No errors in console, just doesn't temp ban the "Minge."
Show your code for the addon that prints the name when they join.
[QUOTE=Kogitsune;48107886]Show your code for the addon that prints the name when they join.[/QUOTE][code]
if CLIENT then
CreateClientConVar( "cl_connectsound", "1", true, false )
local function DispatchChatJoinMSG(um)
local ply = um:ReadString()
local mode = um:ReadString()
local id = um:ReadString()
if mode == "1" then
chat.AddText(Color(72,72,72),"[SERVER] ",Color(145,145,145),ply,Color(235, 235, 235),", is",Color(0, 127, 127)," joining ",Color(235, 235, 235),"the server!")
if GetConVarNumber( "cl_connectsound" ) == 1 then
surface.PlaySound("buttons/combine_button3.wav")
end
elseif mode == "2" then
chat.AddText(Color(72,72,72),"[SERVER] ",Color(145,145,145),ply,Color(235, 235, 235),", has",Color(0, 127, 31)," finished loading")
print("("..id..")")
elseif mode == "3" then
chat.AddText(Color(72,72,72),"[SERVER] ",Color(145,145,145),ply,Color(235, 235, 235),",",Color(255, 30, 30)," left ",Color(235, 235, 235),"the server!")
print("("..id..")")
if GetConVarNumber( "cl_connectsound" ) == 1 then
surface.PlaySound("buttons/combine_button2.wav")
end
end
end
usermessage.Hook("DispatchChatJoin", DispatchChatJoinMSG)
end
if SERVER then
local function PlyConnectMSG( name )
umsg.Start("DispatchChatJoin")
umsg.String(name)
umsg.String("1")
umsg.End()
end
hook.Add( "PlayerConnect", "PlyConnectMSG", PlyConnectMSG )
local function PlyLoadedMSG( ply )
timer.Simple(5, function() --Let the player load you noodle!
if ply:IsValid() then
umsg.Start("DispatchChatJoin")
umsg.String(ply:GetName())
umsg.String("2")
umsg.String(ply:SteamID())
umsg.End()
end
end)
end
hook.Add( "PlayerInitialSpawn", "PlyLoadedMSG", PlyLoadedMSG )
local function PlyDisconnectMSG( ply )
umsg.Start("DispatchChatJoin")
umsg.String(ply:GetName())
umsg.String("3")
umsg.String(ply:SteamID())
umsg.End()
end
hook.Add( "PlayerDisconnected", "PlyDisconnectMSG", PlyDisconnectMSG )
end
[/code]
Something like this:
[code]
if SERVER then
local MIN_INTERVAL = 10
local DELAYS = { { }, { }, { } }
local function PlyConnectMSG( name )
DELAYS[ 1 ][ name ] = DELAYS[ 1 ][ name ] or 0
if DELAYS[ 1 ][ name ] > CurTime( ) then
return
end
DELAYS[ 1 ][ name ] = CurTime( ) + MIN_INTERVAL
umsg.Start("DispatchChatJoin")
umsg.String(name)
umsg.String("1")
umsg.End()
end
hook.Add( "PlayerConnect", "PlyConnectMSG", PlyConnectMSG )
local function PlyLoadedMSG( ply )
timer.Simple(5, function() --Let the player load you noodle!
if ply:IsValid() then
DELAYS[ 2 ][ ply:GetName() ] = DELAYS[ 2 ][ ply:GetName() ] or 0
if DELAYS[ 2 ][ ply:GetName() ] > CurTime( ) then
return
end
DELAYS[ 2 ][ ply:GetName() ] = CurTime( ) + MIN_INTERVAL
umsg.Start("DispatchChatJoin")
umsg.String(ply:GetName())
umsg.String("2")
umsg.String(ply:SteamID())
umsg.End()
end
end)
end
hook.Add( "PlayerInitialSpawn", "PlyLoadedMSG", PlyLoadedMSG )
local function PlyDisconnectMSG( ply )
DELAYS[ 3 ][ ply:GetName() ] = DELAYS[ 3 ][ ply:GetName() ] or 0
if DELAYS[ 3 ][ ply:GetName() ] > CurTime( ) then
return
end
DELAYS[ 3 ][ ply:GetName() ] = CurTime( ) + MIN_INTERVAL
umsg.Start("DispatchChatJoin")
umsg.String(ply:GetName())
umsg.String("3")
umsg.String(ply:SteamID())
umsg.End()
end
hook.Add( "PlayerDisconnected", "PlyDisconnectMSG", PlyDisconnectMSG )
end[/code]
It'd be better to work off IP address as that's more time consuming to change than their name, but the concept is the same - if a player with their name tripped a message in the last MIN_INTERVAL seconds, suppress the message.
[QUOTE=Kogitsune;48107993]Something like this:
[code]
if SERVER then
local MIN_INTERVAL = 10
local DELAYS = { { }, { }, { } }
local function PlyConnectMSG( name )
DELAYS[ 1 ][ name ] = DELAYS[ 1 ][ name ] or 0
if DELAYS[ 1 ][ name ] > CurTime( ) then
return
end
DELAYS[ 1 ][ name ] = CurTime( ) + MIN_INTERVAL
umsg.Start("DispatchChatJoin")
umsg.String(name)
umsg.String("1")
umsg.End()
end
hook.Add( "PlayerConnect", "PlyConnectMSG", PlyConnectMSG )
local function PlyLoadedMSG( ply )
timer.Simple(5, function() --Let the player load you noodle!
if ply:IsValid() then
DELAYS[ 2 ][ ply:GetName() ] = DELAYS[ 2 ][ ply:GetName() ] or 0
if DELAYS[ 2 ][ ply:GetName() ] > CurTime( ) then
return
end
DELAYS[ 2 ][ ply:GetName() ] = CurTime( ) + MIN_INTERVAL
umsg.Start("DispatchChatJoin")
umsg.String(ply:GetName())
umsg.String("2")
umsg.String(ply:SteamID())
umsg.End()
end
end)
end
hook.Add( "PlayerInitialSpawn", "PlyLoadedMSG", PlyLoadedMSG )
local function PlyDisconnectMSG( ply )
DELAYS[ 3 ][ ply:GetName() ] = DELAYS[ 3 ][ ply:GetName() ] or 0
if DELAYS[ 3 ][ ply:GetName() ] > CurTime( ) then
return
end
DELAYS[ 3 ][ ply:GetName() ] = CurTime( ) + MIN_INTERVAL
umsg.Start("DispatchChatJoin")
umsg.String(ply:GetName())
umsg.String("3")
umsg.String(ply:SteamID())
umsg.End()
end
hook.Add( "PlayerDisconnected", "PlyDisconnectMSG", PlyDisconnectMSG )
end[/code]
It'd be better to work off IP address as that's more time consuming to change than their name, but the concept is the same - if a player with their name tripped a message in the last MIN_INTERVAL seconds, suppress the message.[/QUOTE]
sweet, Ill test this when I get home from work. {Tested and working}
[side note] how would I configure this to check spam joining player's IP & SteamID then temp ban SteamID & IP?
PlayerConnect has a second argument of the ip, and Player:IPAddress( ) returns their address.
Banning their IP address is kinda pointless though since they can change it fairly easily. The idea is just to suppress the message if they decide to be annoying - let them waste their own time trying to connect and epic troll you.
[QUOTE=Kogitsune;48115121]PlayerConnect has a second argument of the ip, and Player:IPAddress( ) returns their address.
Banning their IP address is kinda pointless though since they can change it fairly easily. The idea is just to suppress the message if they decide to be annoying - let them waste their own time trying to connect and epic troll you.[/QUOTE]
your code is really nice <3
Sorry, you need to Log In to post a reply to this thread.