Banned Props Script

This is a very simple add-on I created because I would go to a lot of build servers, and in the rules it would say “don’t spawn explosives” or “don’t spawn this prop”. Some of them even had Lua Coders, yet no Prop Ban Script. It is a very easy thing to create, so I made it. Add props to the Ban List in “ban_list.lua”

What I may add:
-Banned Vehicles
-Banned SENTS
-Banned SWEPS
-Banned NPCS

http://www.garrysmod.org/img/?t=dll&id=85463

P.S. Ignore BanProp( “models/door.mdl” ) it’s a custom model I created, it shouldn’t affect your game.

thanks man gunna try it out

You shouldn’t call your banned props table “props”, it could cause some conflicts with other addons because it is such a general name, something like “BannedProps” would be better. Also you don’t need to loop through your banned props table every time someone spawns a prop, something like this would be better:

[lua]BannedProps = {}

BannedProps = {
“models/props_c17/oildrum001_explosive.mdl” = true,
“models/door.mdl” = true
}

hook.Add(“PlayerSpawnProp”, “CheckBannedProps”, function(ply, prop)
return BannedProps[prop];
end);[/lua]

I try to keep every thing cleaner to allow others to modify it.

Just a piece of advice; instead of adding a single prop to the list, why not filter it by prop class and by singe props? It would make adding props much easier.

Here’s a snip from my sandbox gamemode:
[lua]
SB09.BannedProps = {}

function PropsBlackList(pl, model)
for k, v in pairs( SB09.BannedProps ) do
if string.find( string.lower(model), string.lower(v) ) and !pl:IsSuperAdmin() then
Notify( pl, 3, “That prop is banned!!!” )
return false
end
end
– return true – COULD CONFLICT WITH OTHER PlayerSpawnProp HOOKS!!!
end
hook.Add( “PlayerSpawnProp”, “PropsBlackList”, PropsBlackList )

function AddBannedProp( mdl )
table.insert( SB09.BannedProps, mdl )
end

AddBannedProp( “bridge” ) – any prop that is in the class bridge
AddBannedProp( “explo” )
AddBannedProp( “silo_” )
AddBannedProp( “cell_” )
AddBannedProp( “prison01” )
AddBannedProp( “combine_citadel” )
AddBannedProp( “tower” )
AddBannedProp( “cs_fix” )
AddBannedProp( “rockcliff_” )
AddBannedProp( “amraam” )
AddBannedProp( “cannon” )
AddBannedProp( “huge” ) – LAWLZORZZZZZZZZ
AddBannedProp( “bomb” )
AddBannedProp( “torpedo” )
AddBannedProp( “buildings” )
AddBannedProp( “props_lab/jar01b” ) – just a single prop
[/lua]

[lua]
local banned = {
“models/prop1.mdl”,
“models/prop2.mdl”,
}

hook.Add(“PlayerSpawnProp”,“BanProps”,function(pl,mdl) return pl:IsAdmin() || not table.HasValue(banned,mdl) end)
[/lua]

Yeah, this is how I’d do it.

Poorly named globals and global-scope tables are common practice for most people here. Some people don’t really understand the language, or scopes, or table collisions. Anywho, nice work, just needs some cleanup.

I am not sure how Garry’s Mod does it but once the scripts are converted into opcodes, it doesn’t matter because all the variable names would be changed to memory locations.

EDIT: Ok I tested it out, I created another add-on using a table with the same name and nothing happened. So Garry’s Mod does operate this way.