Author Topic: Banning Larger Props  (Read 18661 times)

0 Members and 2 Guests are viewing this topic.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Banning Larger Props
« Reply #15 on: February 04, 2007, 09:11:52 AM »
Bah. So ent:Remove would error out, and the hook would be removed.
Sorry Dr. Roxor.
I learn as I go.

Garry's mod wiki (and seemingly, all other www (not forum) sites of GMod) was down when I tried visiting, so I couldn't check the passed information.
(Yes, I could have tested, but it was ~4am my time, and I had work to do from home @ noon today. App Server upgrades, gotta love them)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline spbogie

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 456
  • Karma: 41
Re: Banning Larger Props
« Reply #16 on: February 04, 2007, 12:11:09 PM »
Ok, I've had time to sit down and test a little and have come up with a working script.

Code: [Select]
local models = { "models/Effects/splode.mdl", "crane_frame.mdl" } --All or part of model name.
local function blockPropsEffects( ply, mdl )
for _, v in pairs( models ) do
if string.find( mdl, v ) then
return false
end
end
end
hook.Add( "PlayerSpawnProp", "blockProps", blockPropsEffects )
hook.Add( "PlayerSpawnEffect", "blockEffects", blockPropsEffects )

Essentaily the same as the origional one I posted, but effects need a seperate hook. It also now accepts any part of the model name, so you don't need the full. If you wanted you could block an entire folder.
I have not failed. I've just found 10,000 ways that won't work. - Thomas A. Edison
I reject your reality and substitute my own. - Adam Savage

Offline Dr.Roxor

  • Newbie
  • *
  • Posts: 10
  • Karma: 2
Re: Banning Larger Props
« Reply #17 on: February 16, 2007, 05:51:26 PM »
Hi Guys!

Thanks for the effort on this. Sorry, work has had me doing other things besides GMOD stuff lately, hence the delay to respond.

Maybe now we can ban the use of huge-assed buildings and other server-crashers that spammers like to use in our Fight servers.

I will go try this code right now and then let you know my results. How Exciting!!!

Regards-

Offline Dr.Roxor

  • Newbie
  • *
  • Posts: 10
  • Karma: 2
Re: Banning Larger Props
« Reply #18 on: February 16, 2007, 06:33:00 PM »
Implemented, tested, passed!

This method seems fairly lightweight being under what, 25 lines or so. My next question is regarding the use of this in high-slot public GMOD servers, particularly when I am blocking dozens of props. I am concerned that if I declare 100+ props in the model table, I will be making the script overhead begin to impact performance. Is this me just being paranoid? Maybe I can eliminate some of the overhead from parsing a huge model table by taking your advice and add entire folders. Thoughts?

An example of the server environment:

24 player slots
Sandbox mode
ULX v3.02 (of course)
WCA SoundPak v1.1
BlockProps.lua (authored by you guys, thanks again!)
No other scripts running.

PS- I also wanted to ask your permission to share this script with others, maintaining your credits of course. I am certain that many of our regular players would like to try the script on their servers.  :)

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Banning Larger Props
« Reply #19 on: February 16, 2007, 06:50:26 PM »
Lua for loops and tables are (as many other code languages are) well optimized.

Though blocking folders would give you better performance over all, I'm thinking only micro, or at worst milli, seconds in time would be saved.

It's really up to you though.

I'll let spbogie speak as to sharing. I'm 98% sure he won't mind, as it's not ground breaking, it just fits our motto "Strinving for Simplicity"
« Last Edit: February 16, 2007, 06:55:08 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline spbogie

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 456
  • Karma: 41
Re: Banning Larger Props
« Reply #20 on: February 17, 2007, 06:29:09 AM »
>:( Don't you dare steal my script!  >:(

;D JK, feel free to share it, modify it, claim it's yours, whatever. A script like this most any GMod scripter could have put together. It's just a matter of taking a little time to figure out the undocumented hooks. I think I'm actually going to use this for the example in the wiki documentation.
I have not failed. I've just found 10,000 ways that won't work. - Thomas A. Edison
I reject your reality and substitute my own. - Adam Savage

Offline Dr.Roxor

  • Newbie
  • *
  • Posts: 10
  • Karma: 2
Re: Banning Larger Props
« Reply #21 on: February 19, 2007, 04:24:28 AM »
Hi,

Thanks for the grant. I know it is a small script, but it wasn't authored by me so I was compelled to ask.  ;D

I'll try this in larger scale and let you know how it does with a full server. Thanks again for your help!

Regards-

Offline DrTight

  • Newbie
  • *
  • Posts: 4
  • Karma: 2
Re: Banning Larger Props
« Reply #22 on: July 06, 2008, 06:54:50 AM »
Hi, i try to block the Naquada Bomb Entity.
Code: [Select]
local models = { "bomb.mdl" }

local function blockmodels( ply, mdl, ent )
 
entmdl = ent:GetModel()
for _,v in ipairs( models ) do
        if  string.find(entmdl, v, 1, true ) then
          ent:Remove()
        end
    end
end
hook.Add( "PlayerSpawnedProp", "blockprops", blockmodels )
hook.Add( "PlayerSpawnedEffect", "blockeffects", blockmodels )
hook.Add( "PlayerSpawnedVehicle", "blockvehicles", blockmodels )
hook.Add( "PlayerSpawnedSENT", "blocksents", blockmodels )
hook.Add( "PlayerSpawnedRagdoll", "blockragdoll", blockmodels )

Its a Sent who is spawnable with a Stool.
I want restrict, that nonadmins cant spawn this Sent with the Adv Dupe.
But i didnt found the hook.
PlayerSpawnedSENT didnt worked.

Sry, bad English, im german.

Thanks DrTight

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Banning Larger Props
« Reply #23 on: July 06, 2008, 07:00:23 AM »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline DrTight

  • Newbie
  • *
  • Posts: 4
  • Karma: 2
Re: Banning Larger Props
« Reply #24 on: July 06, 2008, 07:37:32 AM »
Doesnt work. Uppl and Targetfinder crashed the Server.

I need the Hook, whos called when a player spawn the Sent Naquadah Bomb.

DrTight