General > Developers Corner

Groups, Props, and Tools

<< < (3/4) > >>

Avien:
Alright fine.  I start to use my brain a little.  I applicate all that you guys have done, don't get me wrong.  I get in a mood when i get home after fixing a game server all day, i just get tired of working.  I will start to work on it, and hopefully learn lua while i am at it.  Thanks for your help guys, i mean it.

Golden-Death:
Ok, here you go, tested.

Also made it come with a cvar you can use to turn it on and off, gd_propblock. Set to 1 for on, 0 for off.


--- Code: -----Prop Blocker by Golden-Death--


local groups = { "superadmin", "admin" } --These groups here are allowed to spawn anything, defined in gmod/settings/users.txt
local models = { ""} --All or part of model name that is to be banned



local function block_build( ply, mdl )
if GetConVarString("gd_propblock") == "0" then return; end
for _, v in pairs( models ) do
if string.find( mdl, v ) then
    for _,v in ipairs( groups ) do
        if ply:IsUserGroup( v ) then
            return
        end
    end
    ULib.tsay( ply, "Non-admins are not allowed to spawn this prop. ("..mdl..")." )
    return false
end
    end
end


hook.Add( "PlayerSpawnProp", "block_prop", block_build )
ULib.convar("gd_propblock", 1, "1 = Prop Block On, 0 = Prop Block Off", ULib.ACCESS_ADMIN)
--- End code ---

Avien:
I am assuming we just put into a .lua and place that file in garrysmod/lua/includes/modules/?

Golden-Death:
addons/ulib/lua/ulib/modules or something to that effect, i dont remember exactly :P

Avien:
Well i added it to where i said earlier and to the lua/ulib/modules but now i get an error when i start the server:


This server is running ULib version 2.04.
-- Error running file ------------------------------------
- File: ULib/modules/blocker.lua
- ULib/modules/blocker.lua:26: attempt to call field 'convar' (a nil value)
----------------------------------------------------------
ULX version 3.10 loaded.

Thought you should know.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version