Ok, this is completely untested (I just wrote it in 5 min), but you can try it out and see if it works.
Admins should be able to spawn anything from the list, and players can spawn anything that is in the SENTBlocker.defaultAllowed table, or anything that they have been allowed by another admin using the concommand.
Just paste the code into a file and save as lua in the autorun/server folder.
SENTBlocker = {}
SENTBlocker.defaultAllowed = {}
--Default table of allowed SENTs
--Commands:
-- allowSENT <player name> <SENT name>
-- Allow a player to spawn the specified SENT
-- denySENT <player name> <SENT name>
-- take away a player's ability to spawn the specified SENT
function SENTBlocker.BlockSENT( ply, name )
if not ply:IsAdmin() then
for _, v in ipairs( ply:GetTable().AllowedSENTs ) do
if v == name then
return true
end
end
ply:PrintMessage( HUD_PRINTTALK, "You are not allowed to spawn this SENT." )
return false
end
end
hook.Add( "PlayerSpawnSENT", "SENTBlocker.BlockSENT", SENTBlocker.BlockSENT )
function SENTBlocker.PlayerInit( ply )
ply:GetTable().AllowedSENTs = SENTBlocker.defaultAllowed
end
hook.Add( "PlayerInitialSpawn", "SENTBlocker.PlayerInit", SENTBlocker.PlayerInit )
function SENTBlocker.AllowSENT( ply, cmd, args )
if not ply:IsAdmin() then
ply:PrintMessage( HUD_PRINTCONSOLE, "You do not have access to this command." )
return
end
if args.getn < 2 then
ply:PrintMessage( HUD_PRINTCONSOLE, "Too few arguments spefified." )
end
found = false
for _, v in pairs( player.GetAll() ) do
if ply:Name():find( args[1] ) then
if not table.HasValue( ply:GetTable().AllowedSENTs, args[2] ) then
found = true
table.insert( ply:GetTable().AllowedSENTs, args[2] )
else
ply:PrintMessage( HUD_PRINTCONSOLE, ply:Name() .. " already has access to " .. args[2] )
end
end
end
if not found then
ply:PrintMessage( HUD_PRINTCONSOLE, "No targets found." )
end
end
concommand.Add( "allowSENT", SENTBlocker.AllowSENT )
--Usage: allowSENT <player name> <SENT name>
function SENTBlocker.DenySENT( ply, cmd, args )
if not ply:IsAdmin() then
ply:PrintMessage( HUD_PRINTCONSOLE, "You do not have access to this command." )
return
end
if args.getn < 2 then
ply:PrintMessage( HUD_PRINTCONSOLE, "Too few arguments spefified." )
end
found = false
for _, v in pairs( player.GetAll() ) do
if ply:Name():find( args[1] ) then
if table.HasValue( ply:GetTable().AllowedSENTs, args[2] ) then
found = true
table.remove( ply:GetTable().AllowedSENTs, args[2] )
else
ply:PrintMessage( HUD_PRINTCONSOLE, ply:Name() .. " doesn't have access to " .. args[2] )
end
end
end
if not found then
ply:PrintMessage( HUD_PRINTCONSOLE, "No targets found." )
end
end
concommand.Add( "denySENT", SENTBlocker.DenySENT )
--Usage: denySENT <player name> <SENT name>
Try it out, and let me know if it works.