• Print

Author Topic: My idea for a new anti-spam protection....  (Read 14848 times)

0 Members and 1 Guest are viewing this topic.

Offline the_fool

  • Newbie
  • *
  • Posts: 12
  • Karma: 2
My idea for a new anti-spam protection....
« on: July 14, 2006, 09:05:54 pm »
This is my idea for a new and improved anti-spam protection.

The current anti-spam that is out to all of my knowledge only blocks a player from spamming too many items in the given time and puts a message up that says you can only spawn a prop every (number of seconds here) and then when that time is up they can continue putting more and more props.This is not a big deal if they are spamming the server with a prop such as the smoke stack because the admin can catch the player and kick them before they mess up the server but if they are spamming the server with a prop such as the explosive barrel and they are doing this in a room that no one is currently in so no one knows they are spawning these items with the intension of spawning as many as possible and then blowing them up to crash the server it becomes a problem.My idea is that everytime a player gets the anti-spam message,in the message area of the server a warning will come up that states that the player has been warned for spamming so this way the admin can monitor the console to make sure they are not spawning many items that could crash the server.Spamming is a big problem and i think this would fix it.


Keep in mind:

I would make this mod myself but I dont know much about programming.If a mod like this is allready out please give me a link so I can download it.
« Last Edit: July 14, 2006, 09:07:59 pm by the_fool »

Offline the_fool

  • Newbie
  • *
  • Posts: 12
  • Karma: 2
Re: My idea for a new anti-spam protection....
« Reply #1 on: July 14, 2006, 09:12:18 pm »
I just noticed I posted this in the wrong section.Sorry.

Offline Golden-Death

  • Hero Member
  • *****
  • Posts: 751
  • Karma: 0
  • Honored Lua Scripter
    • BlueFire
Re: My idea for a new anti-spam protection....
« Reply #2 on: July 14, 2006, 09:27:55 pm »
I didn't test it, but what I made here should do the job.

Replace ulx_props.lua with this:

Code: Lua
  1. gProps = {}
  2. gUserProps = {}
  3. gUserPropTimes = {}
  4. gPropids = {}
  5. gRestrictedProps = {}
  6.  
  7. function ulx_playerSpawnProp( userid, propname )
  8.         if hasAccess( userid, ACCESS_PROP_PROTECT ) == true then -- If they have access to avoid this, let them spawn
  9.                 return true
  10.         end
  11.        
  12.         propname = string.lower( propname )
  13.         local steamid = _PlayerInfo( userid, "networkid" ) -- We'll track the users by steamid, not userid
  14.  
  15.         if gUserProps[ steamid ] == nil then -- They're new, set up their information
  16.                 gUserProps[ steamid ] = {}
  17.                 gUserPropTimes[ steamid ] = List.new()
  18.                 for i=1, tonumber( ulx_sv_antispamprops ) do
  19.                         List.pushright( gUserPropTimes[ steamid ], 0 )
  20.                 end
  21.                 gUserPropTimes[ steamid ].wait_till = nil
  22.         end
  23.        
  24.         --debug( "antispamenabled=" .. ulx_sv_antispamenabled )
  25.         if ulx_sv_antispamenabled == "1" then
  26.                 if gUserPropTimes[ steamid ].wait_till ~= nil then
  27.                         if _CurTime() > gUserPropTimes[ steamid ].wait_till then -- If it's over
  28.                                 gUserPropTimes[ steamid ].wait_till = nil
  29.                         else
  30.                                 ulx_tsay( userid, "Stop spamming!" )   
  31.                                 local pname = _PlayerInfo(userid, "name")
  32.                                 _PrintMessageAll(HUD_PRINTTALK, "Player "..pname.." has been warned for spamming")
  33.                                 _PrintMessageAll(HUD_CONSOLETALK, "Player "..pname.." has been warned for spamming")
  34.                                 return false
  35.                         end
  36.                 else
  37.                         local first = gUserPropTimes[ steamid ][ gUserPropTimes[ steamid ].first ]
  38.                         local last = gUserPropTimes[ steamid ][ gUserPropTimes[ steamid ].last ]
  39.                         if last - first < tonumber( ulx_sv_antispamtime ) and first + last > 0 then
  40.                                 gUserPropTimes[ steamid ].wait_till = _CurTime() + tonumber( ulx_sv_antispamblocktime )
  41.                                 ulx_tsay( userid, "You may not spawn more than " .. ulx_sv_antispamprops .. " props in " .. ulx_sv_antispamtime .. " seconds, blocked for the next " .. ulx_sv_antispamblocktime .. " seconds" )
  42.                                 local pname = _PlayerInfo(userid, "name")
  43.                                 _PrintMessageAll(HUD_PRINTTALK, "Player "..pname.." has been warned for spamming")
  44.                                 _PrintMessageAll(HUD_CONSOLETALK, "Player "..pname.." has been warned for spamming")
  45.                                 return false
  46.                         end
  47.                 end
  48.         end
  49.        
  50.         if gRestrictedProps[ propname ] == nil then
  51.                 List.pushright( gUserPropTimes[ steamid ] , _CurTime() )
  52.                 List.popleft( gUserPropTimes[ steamid ] )
  53.                 return true -- They're allowed to spawn it
  54.         end
  55.        
  56.         if gUserProps[ steamid ][ propname ] == nil then
  57.                 gUserProps[ steamid ][ propname ] = 0
  58.         end
  59.        
  60.         if gUserProps[ steamid ][ propname ] < gRestrictedProps[ propname ] then -- If they've spawned less than the max
  61.                 gUserProps[ steamid ][ propname ] = gUserProps[ steamid ][ propname ] + 1
  62.                 gUserProps[ steamid ].next_prop = propname -- This helps us track the entids
  63.                 List.pushright( gUserPropTimes[ steamid ] , _CurTime() )
  64.                 List.popleft( gUserPropTimes[ steamid ] )              
  65.                 return true
  66.         else
  67.                 ulx_tsay( userid, "You can only spawn " .. gRestrictedProps[ propname ] .. " copy of this prop!" )     
  68.                 local pname = _PlayerInfo(userid, "name")
  69.                 _PrintMessageAll(HUD_PRINTTALK, "Player "..pname.." has tried to copy a prop past its allowed number of copies")
  70.                 _PrintMessageAll(HUD_CONSOLETALK, "Player "..pname.." has tried to copy a prop past its allowed number of copies")
  71.                 return false
  72.         end
  73. end
  74.  
  75. function eventPlayerSpawnProp( userid, propname ) -- We want this to be able to be overridden.
  76.         return ulx_playerSpawnProp( userid, propname )
  77. end
  78.  
  79. function eventPlayerSpawnRagdoll( userid, propname )
  80.         return ulx_playerSpawnProp( userid, propname )
  81. end
  82.  
  83. function ulx_playerDuplicateProp( userid, propid )
  84.         local steamid = _PlayerInfo( userid, "networkid" ) -- We'll track the users by steamid, not userid
  85.        
  86.         if gRestrictedProps[ string.lower( _EntGetModel( propid ) ) ] ~= nil and hasAccess( userid, ACCESS_PROP_PROTECT ) == false then
  87.                 ulx_tsay( userid, "Sorry, due to a security issue, you can't duplicate this prop." )
  88.                 return false
  89.         else
  90.                 return true
  91.         end
  92. end
  93.  
  94. function eventPlayerDuplicateProp( userid, propid )
  95.         return ulx_playerDuplicateProp( userid, propid )
  96. end
  97.  
  98. function eventPlayerDuplicateRagdoll( userid, propid )
  99.         return ulx_playerDuplicateProp( userid, propid )
  100. end
  101.  
  102. function ulx_playerPropSpawned( userid, propid )
  103.         gProps[ propid ] = { spawner=userid } -- This is for global use, gPropids is only for anti spam and prop protection
  104.        
  105.         if hasAccess( userid, ACCESS_PROP_PROTECT ) == true then -- Protect their prop if they have access
  106.                 gPropids[ propid ] = "protected"
  107.                 return
  108.         end
  109.  
  110.         local steamid = _PlayerInfo( userid, "networkid" ) -- We'll track the users by steamid, not userid
  111.  
  112.         if gUserProps[ steamid ].next_prop == nil then -- If this isn't a prop we're looking out for, return
  113.                 return
  114.         end
  115.        
  116.         gPropids[ propid ] = { spawner=steamid, prop_name=gUserProps[ steamid ].next_prop } -- Register this ID
  117.         return
  118. end
  119.  
  120. -- Here's where we can get the propid from the spawned prop
  121. function eventPlayerPropSpawned( userid, propid )
  122.         return ulx_playerPropSpawned( userid, propid )
  123. end
  124.  
  125. function eventPlayerRagdollSpawned( userid, propid )
  126.         return ulx_playerPropSpawned( userid, propid )
  127. end
  128.  
  129. function ulx_playerRemove( userid, propid )    
  130.         if gPropids[ propid ] == nil then -- Not one we're concerned about
  131.                 gProps[ propid ] = nil
  132.                 return true
  133.         elseif gPropids[ propid ] == "protected" then -- If this is protected
  134.                 if hasAccess( userid, ACCESS_PROP_PROTECT ) == true then
  135.                         gPropids[ propid ] = nil -- It's no longer, the id will be recycled
  136.                         gProps[ propid ] = nil
  137.                         return true    
  138.                 else
  139.                         ulx_tsay( userid, "This prop is protected, you may not delete it!" )
  140.                         local pname = _PlayerInfo(userid, "name")
  141.                         _PrintMessageAll(HUD_PRINTTALK, "Player "..pname.." has tried to delete a protected prop")
  142.                         _PrintMessageAll(HUD_CONSOLETALK, "Player "..pname.." has tried to delete a protected prop")
  143.                         return false
  144.                 end
  145.         end
  146.        
  147.         local steamid = _PlayerInfo( userid, "networkid" ) -- We'll track the users by steamid, not userid
  148.        
  149.         gUserProps[ gPropids[ propid ].spawner ][ gPropids[ propid ].prop_name ] = gUserProps[ gPropids[ propid ].spawner ][ gPropids[ propid ].prop_name ] - 1 -- Decrement their ( original spawner ) count by one
  150.         gPropids[ propid ] = nil -- It's no longer, the id will be recycled
  151.         gProps[ propid ] = nil
  152.         return true
  153. end
  154.  
  155. function onPlayerRemove( userid, propid )
  156.         return ulx_playerRemove( userid, propid )
  157. end
  158.  
  159. function ulx_playerMoveProp( userid, propid )
  160.         if gPropids[ propid ] == nil then -- Not one we're concerned about
  161.                 return true
  162.         end
  163.  
  164.         if gPropids[ propid ] ~= "protected" then
  165.                 return true
  166.         end
  167.        
  168.         if hasAccess( userid, ACCESS_PROP_PROTECT ) == true then
  169.                 return true    
  170.         else
  171.                 ulx_tsay( userid, "This prop is protected, you may not move it!" )
  172.                 return false
  173.         end
  174. end
  175.  
  176. function onGravGunPunt( userid, propid )
  177.         return ulx_playerMoveProp( userid, propid )
  178. end
  179.  
  180. function onGravGunPickup( userid, propid )
  181.         return ulx_playerMoveProp( userid, propid )
  182. end
  183.  
  184. function onPhysPickup( userid, propid )
  185.         return ulx_playerMoveProp( userid, propid )
  186. end
  187.  
  188. function onPhysFreeze( userid, propid )
  189.         return ulx_playerMoveProp( userid, propid )
  190. end
  191.  
  192. function addRestrictedProp( model, max )
  193.         -- Add error checking here?
  194.         gRestrictedProps[ string.lower( model ) ] = max
  195. end
  196.  
  197.  
  198. -- Add props to our restricted list ( USE LINUX DIRECTORY NOTATION '/' AND NOT WINDOWS NOTATION '\' )
  199. -- addRestrictedProp( model, max_copies_allowed )
  200. -- Please note that this will disable duplication of these models due to security issues
  201.  
  202. addRestrictedProp( "models/props_animated_breakable/smokestack.mdl", 0 ) --Completely block this
  203. addRestrictedProp( "models/props_docks/prefab_piling01a.mdl", 0 )
  204. addRestrictedProp( "models/props_wasteland/cargo_container01.mdl", 1 )
  205. addRestrictedProp( "models/props_wasteland/cargo_container01b.mdl", 1 )
  206. addRestrictedProp( "models/props_wasteland/cargo_container01c.mdl", 1 )
  207. addRestrictedProp( "models/props_c17/TrapPropeller_Blade.mdl", 1 )
  208. addRestrictedProp( "models/props_combine/combine_train02a.mdl", 1 )
  209. addRestrictedProp( "models/props_combine/combine_train02b.mdl", 1 )
  210. addRestrictedProp( "models/props_combine/CombineTrain01a.mdl", 1 )
  211. addRestrictedProp( "models/props_trainstation/train001.mdl", 1 )
  212. addRestrictedProp( "models/props_trainstation/train002.mdl", 1 )
  213. addRestrictedProp( "models/props_trainstation/train003.mdl", 1 )
  214. addRestrictedProp( "models/props_trainstation/train005.mdl", 1 )
  215. addRestrictedProp( "models/props_trainstation/train004.mdl", 1 )
  216. addRestrictedProp( "models/props_combine/stasisfield.mdl", 1 )
  217. addRestrictedProp( "models/props_combine/strut_array_01.mdl", 1 )
  218. addRestrictedProp( "models/Cranes/crane_docks.mdl", 1 )
  219. addRestrictedProp( "models/props_c17/statue_horse.mdl", 1 )
  220.  
  221.  


Offline the_fool

  • Newbie
  • *
  • Posts: 12
  • Karma: 2
Re: My idea for a new anti-spam protection....
« Reply #3 on: July 15, 2006, 12:49:30 pm »
What will this do exactly?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: My idea for a new anti-spam protection....
« Reply #4 on: July 15, 2006, 01:49:54 pm »
Just a quick look, it has extra _PrintMessageAll lines that tell everyone that someone has attempted to go past a limit.
However, as its not been tested, I don't know if it corrects a problem I've been having with anti-spam not working at all, even though enabled, and limits set low

Does the anti-spam work for you?
Perhaps I have a conflict somewhere/somehow
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Golden-Death

  • Hero Member
  • *****
  • Posts: 751
  • Karma: 0
  • Honored Lua Scripter
    • BlueFire
Re: My idea for a new anti-spam protection....
« Reply #5 on: July 15, 2006, 05:07:59 pm »
Yeah, it'l do exactly what you wanted it to do in your original post. And as I said, I don't use it because it was buggy, I just deleted it


Offline MehMegahurtz

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: My idea for a new anti-spam protection....
« Reply #6 on: July 24, 2006, 09:42:55 pm »
Where is the ulx_props.lua?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: My idea for a new anti-spam protection....
« Reply #7 on: July 25, 2006, 03:12:51 am »
In ULX V1.x, ulx_props.lua is in your gmod9/lua/ulx folder

It doesn't exist in ULX v2.
(And pasting the above into a file in the ULX v2 directory would not work)

Perhaps someone will convert a prop/anti-spam protect in the future for Ulib
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline aschmack

  • Newbie
  • *
  • Posts: 13
  • Karma: 2
Re: My idea for a new anti-spam protection....
« Reply #8 on: July 27, 2006, 08:23:40 pm »
In ULX V1.x, ulx_props.lua is in your gmod9/lua/ulx folder

It doesn't exist in ULX v2.
(And pasting the above into a file in the ULX v2 directory would not work)

Perhaps someone will convert a prop/anti-spam protect in the future for Ulib

I'm working on it JamminR, once this menu situation is taken care of, you'll be able to use prop protector with ULib Admin integration.

  • Print