URestrict = {} -- Don't touch this
URestrict.loadout = {} -- Don't touch this
-- ==Start STool Configurations==--
-- Just insert tools your want to restrict here.
URestrict.tools = {
"gcombat",
"dynamite",
}
-- To add groups to the allowed list, just create a table below in the format of URestrict.tool = { "group here" }
URestrict.gcombat = { "admins", "superadmin" } -- Your groups allowed to use GCombat
URestrict.dynamite = { } -- Groups allow to use dynamite
--====End STool Configurations====--
--==Start Weapon Configurations==--
-- To add groups that you want to have a different load out than default, just create a table in the format of: URestrict.loadout_group = { "items here" }
URestrict.loadout.default = { "weapon_physgun", "weapon_physcannon", "gmod_tool", "gmod_camera" } -- Default Starting loadout.(First Item in the list will be selected by default at spawn)
URestrict.loadout.admin = { "weapon_physgun", "weapon_physcannon", "gmod_tool", "gmod_camera", "weapon_crowbar" } -- Loadout for admins
URestrict.loadout.superadmin = { "weapon_physgun", "weapon_physcannon", "gmod_tool", "gmod_camera", "weapon_crowbar", "weapon_pistol", "weapon_357", "weapon_smg1", "weapon_ar2", "weapon_shotgun", "weapon_crossbow", "weapon_frag", "weapon_rpg" } -- Loadout for superadmins
--====End Weapon Configurations====--
-- =============================End of Configuration=============================--
function URestrict.GetUserGroup( ply )
for k,v in pairs( ULib.ucl.groups ) do -- Loops through the list of all the groups
if ply:IsUserGroup( k ) then -- Checks to see if the player in question is a member of one of these groups
return k -- If yes, then return that group
end
end
end
function URestrict.CanTool( ply, tr, tool )
for k,v in pairs( URestrict.tools ) do -- Loops through the list of restricted tools
if tool == v then -- Checks to see if the tool in use is restricted
if URestrict[v] then -- Make sure that the table of groups allowed exists
if not(table.HasValue( URestrict[ v ], URestrict.GetUserGroup( ply ))) and ( #URestrict[ v ] > 0 ) then -- Checks to see if the player is a member of one of the allowed groups
ply:PrintMessage( HUD_PRINTTALK, "This tool is restricted to certain groups" ) -- If not then display this message
return false -- And deny use
else
if #URestrict[ v ] == 0 then
ply:PrintMessage( HUD_PRINTTALK, "This tools use has been revoked" )
return false
end
end
else
ply:PrintMessage( HUD_PRINTTALK, "This tools use has been revoked" )
return false -- If no groups are specified in the allowed list, or the list doesn't exist, then deny use to everyone
end
end
end
end
hook.Add( "CanTool", "URestrict_CanTool_Hook", URestrict.CanTool )
function URestrict.Loadout( ply )
if URestrict.loadout[URestrict.GetUserGroup( ply )] then
for k, v in pairs( URestrict.loadout[URestrict.GetUserGroup( ply )] ) do
ply:Give( v )
end
ply:SelectWeapon( URestrict.loadout[URestrict.GetUserGroup( ply )][1] )
return true
else
for k, v in pairs( URestrict.loadout.default ) do
ply:Give( v )
end
ply:SelectWeapon( URestrict.loadout.default[1] )
return true
end
end
hook.Add( "PlayerLoadout", "URestrict_Loadout_Hook", URestrict.Loadout )
function URestrict.PickUp( ply, weap )
if URestrict.loadout[URestrict.GetUserGroup( ply )] then
if not(table.HasValue( URestrict.loadout[URestrict.GetUserGroup( ply )], weap:GetClass() ) ) then
return false
end
else
if not(table.HasValue( URestrict.loadout.default, weap:GetClass() ) ) then
return false
end
end
end
hook.Add( "PlayerCanPickupWeapon", "RandomUniqueName", PlayerCanPickupWeapon)