diff --git a/addon.txt b/addon.txt new file mode 100644 index 0000000..798935b --- /dev/null +++ b/addon.txt @@ -0,0 +1,6 @@ +"AddonInfo" +{ + "name" "URS" + "author_name" "xAaron113x" + "info" "Restriction system for ULX." +} \ No newline at end of file diff --git a/lua/ulx/modules/cl/cl_urs.lua b/lua/ulx/modules/cl/cl_urs.lua new file mode 100644 index 0000000..5764950 --- /dev/null +++ b/lua/ulx/modules/cl/cl_urs.lua @@ -0,0 +1,66 @@ +--======================================================================== +--========================Used for debugging purposes.============================= +--======================================================================== + +function URSLoadouts( len ) + Msg( "=============================================================\n" ) + Msg( "URS - Loadouts:\n" ) + PrintTable( net.ReadTable() ) + Msg( "=============================================================\n" ) + LocalPlayer():ChatPrint( "* Check console for a list of your Loadouts *" ) +end +net.Receive( "URS-Loadouts", URSLoadouts ) + +function URSRestrictions( len ) + Msg( "=============================================================\n" ) + Msg( "URS - Restrictions:\n" ) + PrintTable( net.ReadTable() ) + Msg( "=============================================================\n" ) + LocalPlayer():ChatPrint( "* Check console for a list of your Restrictions *" ) +end +net.Receive( "URS-Restrictions", URSRestrictions ) + +function URSLimits( len ) + Msg( "=============================================================\n" ) + Msg( "URS - Limits:\n" ) + PrintTable( net.ReadTable() ) + Msg( "=============================================================\n" ) + LocalPlayer():ChatPrint( "* Check console for a list of your Limits *" ) +end +net.Receive( "URS-Limits", URSLimits ) + +function URSAll( len ) + Msg( "=============================================================\n" ) + Msg( "URS - Limits:\n" ) + PrintTable( net.ReadTable() ) + Msg( "=============================================================\n" ) + Msg( "URS - Restrictions:\n" ) + PrintTable( net.ReadTable() ) + Msg( "=============================================================\n" ) + Msg( "URS - Loadouts:\n" ) + PrintTable( net.ReadTable() ) + Msg( "=============================================================\n" ) + LocalPlayer():ChatPrint( "* Check console for a list of your Limits, Restrictions, and Loadouts *" ) +end +net.Receive( "URS-All", URSAll ) + +--======================================================================== +--======================================================================== +--[[ local ply = LocalPlayer() +local trace = ply:GetEyeTraceNoCursor() +function URSHelper() + -- draw.RoundedBox( 6, 2, 7, 178, 203, Color( 50, 50, 200, 200 ) ) + -- draw.RoundedBox( 6, 5, 10, 175, 200, Color( 50, 50, 50, 200 ) ) + surface.SetDrawColor( Color( 0, 0, 0, 255 ) ) + surface.DrawOutlinedRect( 5, 10, 175, 200 ) + surface.SetDrawColor( Color( 50, 50, 50, 200 ) ) + surface.DrawRect( 5, 10, 175, 200 ) + + surface.CreateFont ("DefaultBold", 20, 700, true, false, "URSHeader") + surface.SetFont( "DefaultBold" ) + surface.SetTextColor( 200, 200, 200, 255 ) + surface.SetTextPos( 10, 12 ) + surface.DrawText( "Target: ".. trace.Entity:GetModel() ) + +end +hook.Add("PostDrawHUD", "URSHelper", URSHelper) ]] \ No newline at end of file diff --git a/lua/ulx/modules/sh/urs_cmds.lua b/lua/ulx/modules/sh/urs_cmds.lua new file mode 100644 index 0000000..89327b8 --- /dev/null +++ b/lua/ulx/modules/sh/urs_cmds.lua @@ -0,0 +1,211 @@ +local restrictiontypes = { "tool","vehicle","effect","swep", "npc","ragdoll","prop","sent", "all", "advdupe", "pickup" } +local limittypes = { "vehicle","effect", "npc","ragdoll","prop","sent" } +local Echo +if SERVER then + Echo = ulx.convar( "echours", 0 ) + util.AddNetworkString("URS-Loadouts") + util.AddNetworkString("URS-Restrictions") + util.AddNetworkString("URS-All") +end + +function ulx.restrict( ply, type, what, ... ) + local groups = {...} + local removers = {} + what = string.lower( what ) + if type == "all" and !table.HasValue( {"tool","vehicle","effect","swep", "npc","ragdoll","prop","sent"}, what ) then + ULib.tsayError( ply, "Global Restrictions are limited to:\ntool, vehicle, effect, swep, npc, ragdoll, prop, sent " ) + return + end + if !restrictions[type][what] then + restrictions[type][what] = groups + else + for group, groups in pairs( groups ) do + if table.HasValue( restrictions[type][what], groups ) then + table.insert( removers, group ) + ULib.tsayError( ply, groups .." is already restricted from this rank." ) + else + if groups == "*" then + table.insert( restrictions[type][what], 1, groups ) + else + table.insert( restrictions[type][what], groups ) + end + end + end + end + xgui.sendDataTable( {}, "URSRestrictions" ) + URSSave() + table.sort( removers, function(a, b) return a > b end ) + if removers[1] then for num, nums in pairs( removers ) do table.remove( groups, nums ) end end + if groups[1] then + ulx.fancyLogAdmin( ply, Echo:GetBool(), "#A restricted #s #s from #s", type, what, table.concat( groups, ", " ) ) + end +end +local restrict = ulx.command( "URS", "ulx restrict", ulx.restrict, "!restrict" ) +restrict:addParam{ type=ULib.cmds.StringArg, hint="Type", completes=restrictiontypes, ULib.cmds.restrictToCompletes } +restrict:addParam{ type=ULib.cmds.StringArg, hint="Target Name/Model Path" } +restrict:addParam{ type=ULib.cmds.StringArg, hint="Groups", ULib.cmds.takeRestOfLine, repeat_min=1 } +restrict:defaultAccess( ULib.ACCESS_SUPERADMIN ) +restrict:help( "Add a restriction to a group." ) + +function ulx.unrestrict( ply, type, what, ... ) + local groups = {...} + local removers = {} + local removers2 = {} + what = string.lower( what ) + if not restrictions[type][what] then ULib.tsayError( ply, what .." is not a restricted ".. type ) return + elseif groups[1] == "*" then + if restrictions[type][what][1] == "*" then + if not restrictions[type][what][2] then + restrictions[type][what] = nil + else + table.remove( restrictions[type][what], 1 ) + end + else + restrictions[type][what] = nil + end + else + for k,v in pairs( groups ) do + if table.HasValue( restrictions[type][what], v ) then + for k2,v2 in pairs( restrictions[type][what] ) do + if v2 == v then + table.insert( removers, k2 ) + if not restrictions[type][what][1] then restrictions[type][what] = nil end + end + end + else + ULib.tsayError( ply, v .." is not restricted from ".. what ) + table.insert( removers2, k ) + end + end + end + table.sort( removers, function(a, b) return a > b end ) + for i=1,#removers do table.remove( restrictions[type][what], removers[i] ) end + URSSave() + xgui.sendDataTable( {}, "URSRestrictions" ) + if groups[1] then + table.sort( removers2, function(a, b) return a > b end ) + for i=1,#removers2 do table.remove( groups, removers2[i] ) end + if groups[1] == "*" and not restrictions[type][what] then + ulx.fancyLogAdmin( ply, Echo:GetBool(), "#A removed all restrictions from #s", what ) + else + ulx.fancyLogAdmin( ply, Echo:GetBool(), "#A unrestricted #s from #s", what, table.concat(groups,", ") ) + end + end +end +local unrestrict = ulx.command( "URS", "ulx unrestrict", ulx.unrestrict, "!unrestrict") +unrestrict:addParam{ type=ULib.cmds.StringArg, hint="Type", completes=restrictiontypes, ULib.cmds.restrictToCompletes } +unrestrict:addParam{ type=ULib.cmds.StringArg, hint="Target Name/Model Path" } +unrestrict:addParam{ type=ULib.cmds.StringArg, hint="Groups", ULib.cmds.takeRestOfLine, repeat_min=1 } +unrestrict:defaultAccess( ULib.ACCESS_SUPERADMIN ) +unrestrict:help( "Remove a restrictions from a group." ) + +function ulx.setlimit( ply, type, group, limit ) + if limit == -1 then limits[type][group] = nil else limits[type][group] = limit end + xgui.sendDataTable( {}, "URSLimits" ) + URSSave() + ulx.fancyLogAdmin( ply, Echo:GetBool(), "#A set the #s limit for #s to #i", type, group, limit ) +end +local limit = ulx.command( "URS", "ulx setlimit", ulx.setlimit, "!setlimit" ) +limit:addParam{ type=ULib.cmds.StringArg, ULib.cmds.restrictToCompletes, completes=limittypes, hint="Type" } +limit:addParam{ type=ULib.cmds.StringArg, hint="Group" } +limit:addParam{ type=ULib.cmds.NumArg, min=-1, default=-1, hint="Amount (-1 is default)" } +limit:defaultAccess( ULib.ACCESS_SUPERADMIN ) +limit:help( "Set limits for specific groups." ) + +local weaponlist = { "manhack_welder", "weapon_ak47", "weapon_deagle", "weapon_fiveseven", "weapon_glock", "weapon_m4", "weapon_mac10","weapon_tmp","weapon_pumpshotgun","weapon_para","weapon_mp5","harpooncannon","flechette_gun","weapon_crowbar","weapon_stunstick","weapon_physcannon","weapon_physgun","weapon_pistol","weapon_357","weapon_smg1","weapon_ar2","weapon_shotgun","weapon_crossbow", "weapon_frag", "weapon_rpg", "weapon_slam", "weapon_bugbait", "item_ml_grenade", "item_ar2_grenade", "item_ammo_ar2_altfire", "gmod_camera", "gmod_tool"} + +function ulx.loadoutadd( ply, group, ... ) + local weapons = {...} + local removers = {} + for i=1, #weapons do + if loadouts[group] and not table.HasValue( loadouts[group], weapons[i] ) then + table.insert( loadouts[group], weapons[i] ) + elseif loadouts[group] and table.HasValue( loadouts[group], weapons[i] ) then + ULib.tsayError( ply, weapons[i] .." is already in the loadout for ".. group ) + table.insert( removers, i ) + end + end + if not loadouts[group] then + loadouts[group] = weapons + end + URSSave() + xgui.sendDataTable( {}, "URSLoadouts" ) + table.sort( removers, function(a, b) return a > b end ) + for i=1,#removers do table.remove( weapons, removers[i] ) end + if weapons[1] then + ulx.fancyLogAdmin( ply, Echo:GetBool(), "#A added #s to the loadout for #s", table.concat( weapons, ", " ), group ) + end +end +local loadout = ulx.command( "URS", "ulx loadoutadd", ulx.loadoutadd, "!loadoutadd" ) +loadout:addParam{ type=ULib.cmds.StringArg, hint="Group" } +loadout:addParam{ type=ULib.cmds.StringArg, hint="Weapons", ULib.cmds.takeRestOfLine, repeat_min=1, completes=weaponlist } +loadout:defaultAccess( ULib.ACCESS_SUPERADMIN ) +loadout:help( "Create or update a loudout for a specific group." ) + +function ulx.loadoutremove( ply, group, ... ) + if not loadouts[group] then ULib.tsayError( ply, group .." does not have a loadout" ) return end + local weapons = {...} + local removers = {} + local removers2 = {} + if weapons[1] == "*" then + loadouts[group] = nil + weapons = {} + URSSave() + xgui.sendDataTable( {}, "URSLoadouts" ) + ulx.fancyLogAdmin( ply, Echo:GetBool(), "#A removed the loadout from #s", group ) + return + else + for k,v in pairs( weapons ) do + if table.HasValue( loadouts[group], v ) then + for k2,v2 in pairs( loadouts[group] ) do + if v2 == v then + table.insert( removers, k2 ) + end + end + else + ULib.tsayError( ply, v .." is not a loadout of this group" ) + table.insert( removers2, k ) + end + end + end + table.sort( removers, function(a, b) return a > b end ) + for i=1,#removers do table.remove( loadouts[group], removers[i] ) end + if not loadouts[group][1] then loadouts[group] = nil end + URSSave() + xgui.sendDataTable( {}, "URSLoadouts" ) + table.sort( removers2, function(a, b) return a > b end ) + for i=1,#removers2 do table.remove( weapons, removers2[i] ) end + if weapons and not weapons[1] then return end + ulx.fancyLogAdmin( ply, Echo:GetBool(), "#A removed #s from the loadout of #s", table.concat( weapons, ", " ), group ) +end +local loadout = ulx.command( "URS", "ulx loadoutremove", ulx.loadoutremove, "!loadoutremove" ) +loadout:addParam{ type=ULib.cmds.StringArg, hint="Group" } +loadout:addParam{ type=ULib.cmds.StringArg, hint="Weapons", ULib.cmds.takeRestOfLine, repeat_min=1 } +loadout:defaultAccess( ULib.ACCESS_SUPERADMIN ) +loadout:help( "Remove weapons from a loadout for a specific group." ) + +function ulx.print( ply, type ) + if type == "loadouts" then + net.Start("URS-Loadouts") + net.WriteTable(loadouts) + net.Send(ply) + elseif type == "restrictions" then + net.Start("URS-Restrictions") + net.WriteTable(restrictions) + net.Send(ply) + elseif type == "limits" then + net.Start("URS-Limits") + net.WriteTable(limits) + net.Send(ply) + else + net.Start("URS-All") + net.WriteTable(limits) + net.WriteTable(restrictions) + net.WriteTable(loadouts) + net.Send(ply) + end +end +local loadout = ulx.command( "URS", "ulx print", ulx.print, "!print" ) +loadout:addParam{ type=ULib.cmds.StringArg, hint="Type", completes={"restrictions","loadouts","limits","all" }, ULib.cmds.restrictToCompletes } +loadout:defaultAccess( ULib.ACCESS_SUPERADMIN ) +loadout:help( "Print Restrictions, Loadouts, or Limits from URS into your console." ) diff --git a/lua/ulx/modules/urs_server.lua b/lua/ulx/modules/urs_server.lua new file mode 100644 index 0000000..062ed52 --- /dev/null +++ b/lua/ulx/modules/urs_server.lua @@ -0,0 +1,138 @@ +AddCSLuaFile( "ulx/modules/sh/urs_cmds.lua" ) +local Pickups = ulx.convar( "urs_weaponpickups", 0 ) +local restrictiontypes = { "tool","vehicle","effect","swep", "npc","ragdoll","prop","sent", "all", "advdupe", "pickup" } +local limittypes = { "vehicle","effect", "npc","ragdoll","prop","sent" } +restrictions = {} +limits = {} +loadouts = {} + +local shoulddebug = true +local function Debug( msg ) if shoulddebug then ULib.console( nil, "[URS DEBUG] ".. msg ) Msg( "[URS DEBUG] ".. msg .."\n" ) end end + +if file.Exists( "ulx/limits.txt", "DATA" ) then limits = util.JSONToTable( file.Read( "ulx/limits.txt", "DATA" ) ) end +if file.Exists( "ulx/restrictions.txt", "DATA" ) then restrictions = util.JSONToTable( file.Read( "ulx/restrictions.txt", "DATA" ) ) end +if file.Exists( "ulx/loadouts.txt", "DATA" ) then loadouts = util.JSONToTable( file.Read( "ulx/loadouts.txt", "DATA" ) ) end + +for type, types in pairs( limittypes ) do if not limits[types] then limits[types] = {} end end +for type, types in pairs( restrictiontypes ) do if not restrictions[types] then restrictions[types] = {} end end + +function URSSave() + if limits then file.Write( "ulx/limits.txt", util.TableToJSON( limits ) ) end + if restrictions then file.Write( "ulx/restrictions.txt", util.TableToJSON( restrictions ) ) end + if loadouts then file.Write( "ulx/loadouts.txt", util.TableToJSON( loadouts ) ) end +end + +function URSCheck( ply, type, what, noecho ) + what = string.lower( what ) + local group = ply:GetUserGroup() + if restrictions[type][what] and (table.HasValue(restrictions[type][what], group) or table.HasValue(restrictions[type][what], "*") or table.HasValue(restrictions[type][what], ply:SteamID())) then + if !table.HasValue(restrictions[type][what], "*") and (!table.HasValue( restrictions[type][what], ply:SteamID()) and table.HasValue(restrictions[type][what], group)) then + if !noecho then + ulx.logSpawn( ply:Nick() .."<".. ply:SteamID() .."> spawned/used ".. type .." ".. what .." -=RESTRICTED=-" ) + ULib.tsayError( ply, "\"".. what .."\" is a restricted ".. type .." from your rank." ) + end + return false + end + elseif restrictions["all"][type] and table.HasValue(restrictions["all"][type], group) then + if !noecho then + ULib.tsayError( ply, "Your rank is restricted from all ".. type .."s" ) + end + return false + elseif table.HasValue( limittypes, type ) and limits[type][ply:SteamID()] then + if ply:GetCount( type .."s" ) >= limits[type][ply:SteamID()] then + ply:LimitHit( type .."s" ) + return false + else + return true + end + elseif table.HasValue( limittypes, type ) and limits[type][group] then + if ply:GetCount( type .."s" ) >= limits[type][group] then + ply:LimitHit( type .."s" ) + return false + else + return true + end + end +end + +function URSDupeCheck( Player, Ent, EntTable ) + return URSCheck( Player, "advdupe", EntTable.Class ) +end +function URSDupeCheckFailed( Hook ) + ULib.tsayColor( nil, false, Color( 255, 0, 0 ), "URSDupeCheck has failed. Please contact Aaron113 @\nhttp://forums.ulyssesmod.net/index.php/topic,5269.0.html" ) +end + +if AdvDupe then + timer.Simple( 0.1, function() AdvDupe.AdminSettings.AddEntCheckHook( "URSDupeCheck", URSDupeCheck, URSDupeCheckFailed ) end ) +end + +function URSCheckRestrictedSENT( ply, sent ) + return URSCheck( ply, "sent", sent ) +end +hook.Add( "PlayerSpawnSENT", "URSCheckRestrictedSENT", URSCheckRestrictedSENT, -10 ) + +function URSCheckRestrictedProp( ply, mdl ) + return URSCheck( ply, "prop", mdl ) +end +hook.Add( "PlayerSpawnProp", "URSCheckRestrictedProp", URSCheckRestrictedProp, -10 ) + +function URSCheckRestrictedTool( ply, tr, tool ) + if URSCheck( ply, "tool", tool ) == false then return false end + if tool != "inflator" then + ulx.logSpawn( ply:Nick().."<".. ply:SteamID() .."> used the tool ".. tool .." on ".. tr.Entity:GetModel() ) + end +end +hook.Add( "CanTool", "URSCheckRestrictedTool", URSCheckRestrictedTool, -10 ) + +function URSCheckRestrictedEffect( ply, mdl ) + return URSCheck( ply, "effect", mdl ) +end +hook.Add( "PlayerSpawnEffect", "URSCheckRestrictedEffect", URSCheckRestrictedEffect, -10 ) + +function URSCheckRestrictedNPC( ply, npc, weapon ) + return URSCheck( ply, "npc", npc ) +end +hook.Add( "PlayerSpawnNPC", "URSCheckRestrictedNPC", URSCheckRestrictedNPC, -10 ) + +function URSCheckRestrictedRagdoll( ply, mdl ) + return URSCheck( ply, "ragdoll", mdl ) +end +hook.Add( "PlayerSpawnRagdoll", "URSCheckRestrictedRagdoll", URSCheckRestrictedRagdoll, -10 ) + +function URSCheckRestrictedSWEP( ply, class, weapon ) + if URSCheck( ply, "swep", class ) == false then return false end + ulx.logSpawn( ply:Nick().."<".. ply:SteamID() .."> spawned/gave himself swep ".. class ) +end +hook.Add( "PlayerSpawnSWEP", "URSCheckRestrictedSWEP", URSCheckRestrictedSWEP, -10 ) +hook.Add( "PlayerGiveSWEP", "URSCheckRestrictedSWEP2", URSCheckRestrictedSWEP, -10 ) + +function URSCheckRestrictedPickUp( ply, weapon ) + if Pickups:GetInt() == 2 then + return URSCheck( ply, "pickup", weapon:GetClass(), true ) + elseif Pickups:GetInt() == 1 then + return URSCheck( ply, "swep", weapon:GetClass(), true ) + end +end +hook.Add( "PlayerCanPickupWeapon", "URSCheckRestrictedPickUp", URSCheckRestrictedPickUp, -10 ) + +function URSCheckRestrictedVehicle( ply, mdl, name, vehicle_table ) + return URSCheck( ply, "vehicle", mdl ) and URSCheck( ply, "vehicle", name ) +end +hook.Add( "PlayerSpawnVehicle", "URSCheckRestrictedVehicle", URSCheckRestrictedVehicle, -10 ) + +function URSCustomLoadouts( ply ) + if loadouts[ply:SteamID()] then + ply:StripWeapons() + for k, v in pairs( loadouts[ply:SteamID()] ) do + ply:Give( v ) + end + return true + elseif loadouts[ply:GetUserGroup()] then + ply:StripWeapons() + for k, v in pairs( loadouts[ply:GetUserGroup()] ) do + ply:Give( v ) + end + return true + end +end +hook.Add( "PlayerLoadout", "URSCustomLoadouts", URSCustomLoadouts, -10 ) \ No newline at end of file diff --git a/lua/ulx/xgui/server/sv_urs_gui.lua b/lua/ulx/xgui/server/sv_urs_gui.lua new file mode 100644 index 0000000..db2380a --- /dev/null +++ b/lua/ulx/xgui/server/sv_urs_gui.lua @@ -0,0 +1 @@ +ULib.ucl.registerAccess( "xgui_urs", "superadmin", "Access to modify URS restrictions.", "XGUI" ) local URS = {} function URS.Init() xgui.addDataType( "URSLimits", function() return limits end, "xgui_urs", 0, -10 ) xgui.addDataType( "URSRestrictions", function() return restrictions end, "xgui_urs", 0, -10 ) xgui.addDataType( "URSLoadouts", function() return loadouts end, "xgui_urs", 0, -10 ) end xgui.addSVModule( "URS", URS.Init ) \ No newline at end of file diff --git a/lua/ulx/xgui/settings/cl_urs_gui.lua b/lua/ulx/xgui/settings/cl_urs_gui.lua new file mode 100644 index 0000000..cd3d635 --- /dev/null +++ b/lua/ulx/xgui/settings/cl_urs_gui.lua @@ -0,0 +1 @@ +xgui.prepareDataType( "URSRestrictions" ) xgui.prepareDataType( "URSLimits" ) xgui.prepareDataType( "URSLoadouts" ) urs = {} urs.removers = {} urs.weapons2 = {"weapon_para","weapon_crowbar","weapon_stunstick","weapon_physcannon","weapon_physgun","weapon_pistol","weapon_357","weapon_smg1","weapon_ar2","weapon_shotgun","weapon_crossbow", "weapon_frag", "weapon_rpg", "weapon_slam", "weapon_bugbait", "item_ml_grenade", "item_ar2_grenade", "item_ammo_ar2_altfire", "gmod_camera", "gmod_tool"} urs.weapons = weapons.GetList() urs.arg1save = nil urs.back = xlib.makepanel{ parent=xgui.null } urs.restrictionlist = xlib.makelistview{ parent=urs.back, x=5, y=5, w=150, h=71 } urs.typelist = xlib.makelistview{ parent=urs.back, x=5, y=81, w=150, h=220 } urs.itemlist = xlib.makelistview{ parent=urs.back, x=160, y=5, w=425, h=295, multiselect=true } urs.addbutton = xlib.makebutton{ parent=urs.back, x=485, y=306, w=100, h=25, label="Add", disabled=true } urs.removebutton = xlib.makebutton{ parent=urs.back, x=5, y=306, w=150, h=25, label="Remove Selected Items", disabled=true } urs.arg1 = xlib.makecombobox{ parent=urs.back, x=160, y=306, w=155, h=25, disabled=true} urs.arg2 = xlib.makecombobox{ parent=urs.back, x=320, y=306, w=160, h=25, disabled=true} urs.arg3 = xlib.maketextbox{ parent=urs.back, x=320, y=306, w=160, h=25, disabled=true, visible=false} urs.arg2Old = urs.arg2 urs.restrictionlist:AddColumn( "Type of Restriction" ) urs.restrictionlist:AddLine( "Restrictions" ) urs.restrictionlist:AddLine( "Limits" ) urs.restrictionlist:AddLine( "Loadouts" ) urs.typelist:AddColumn( " " ) urs.itemlist:AddColumn( " " ) urs.itemlist:AddColumn( " " ) local function Debug( msg ) ULib.console( nil, "[URS DEBUG] ".. msg ) Msg( "[URS DEBUG] ".. msg .."\n" ) end -------------------------------------------------------------------------------------------------------------------------------------------- urs.restrictionlist.OnRowSelected = function( self, lineid, line ) urs.arg1:Clear() urs.arg2:Clear() urs.arg1save = nil if line:GetValue(1) == "Loadouts" then urs.arg2 = urs.arg2Old urs.arg2:SetVisible(true) urs.arg3:SetVisible(false) urs.addbutton:SetDisabled( false ) urs.arg1:SetDisabled( false ) urs.arg2:SetDisabled( false ) urs.arg1:SetText( "Group" ) urs.arg2:SetText( "Weapon(s)" ) for weapon, weapons in pairs( urs.weapons ) do urs.arg2:AddChoice( weapons.ClassName ) end for weapon, weapons in pairs( urs.weapons2 ) do urs.arg2:AddChoice( weapons ) end for group, groups in pairs( xgui.data.groups ) do urs.arg1:AddChoice( groups ) end else urs.arg2:SetVisible(false) urs.arg3:SetVisible(true) urs.arg2 = urs.arg3 urs.addbutton:SetDisabled( true ) urs.arg1:SetDisabled( true ) urs.arg2:SetDisabled( true ) urs.removebutton:SetDisabled( true ) if line:GetValue(1) == "Restrictions" then urs.arg1:SetText( "Group(s)" ) urs.arg2:SetText( "Target" ) --urs.arg2:AddChoice( "*" ) for group, groups in pairs( xgui.data.groups ) do urs.arg1:AddChoice( groups ) end elseif line:GetValue(1) == "Limits" then urs.arg1:SetText( "Group" ) urs.arg2:SetText( "Limit" ) for group, groups in pairs( xgui.data.groups ) do urs.arg1:AddChoice( groups ) end end end urs.itemlist:Clear() urs.typelist:Clear() if line:GetValue(1) == "Restrictions" then urs.typelist.Columns[1]:SetName( "Type" ) urs.itemlist.Columns[1]:SetName( "Target" ) urs.itemlist.Columns[2]:SetName( "Group" ) for type, types in pairs( xgui.data.URSRestrictions ) do urs.typelist:AddLine( type ) end elseif line:GetValue(1) == "Limits" then urs.typelist.Columns[1]:SetName( " " ) urs.itemlist.Columns[1]:SetName( "Group" ) urs.itemlist.Columns[2]:SetName( "Limit" ) for type, types in pairs( xgui.data.URSLimits ) do urs.typelist:AddLine( type ) end elseif line:GetValue(1) == "Loadouts" then urs.typelist.Columns[1]:SetName( "Group" ) urs.itemlist.Columns[1]:SetName( "Weapon" ) urs.itemlist.Columns[2]:SetName( " " ) for group, groups in pairs( xgui.data.URSLoadouts ) do urs.typelist:AddLine( group ) end end end urs.typelist.OnRowSelected = function( panel, lineid, line ) urs.addbutton:SetDisabled( false ) urs.arg1:SetDisabled( false ) urs.arg2:SetDisabled( false ) urs.removebutton:SetDisabled( true ) urs.itemlist:Clear() urs.arg1save = nil if urs.restrictionlist:GetSelected()[1]:GetValue(1) == "Restrictions" then for type, types in pairs( xgui.data.URSRestrictions ) do if type == line:GetValue(1) then for target, targets in pairs( types ) do for group, groups in pairs( targets ) do urs.itemlist:AddLine( target, groups ) end end end end elseif urs.restrictionlist:GetSelected()[1]:GetValue(1) == "Limits" then for type, types in pairs( xgui.data.URSLimits ) do if type == line:GetValue(1) then for group, groups in pairs( types ) do urs.itemlist:AddLine( group, groups ) end end end elseif urs.restrictionlist:GetSelected()[1]:GetValue(1) == "Loadouts" then for group, groups in pairs( xgui.data.URSLoadouts ) do if group == line:GetValue(1) then urs.arg1:SetText( line:GetValue(1) ) for weapon, weapons in pairs( xgui.data.URSLoadouts[group] ) do urs.itemlist:AddLine( weapons ) end end end end end urs.itemlist.OnRowSelected = function( self, lineid, line ) urs.removebutton:SetDisabled( false ) urs.addbutton:SetDisabled( false ) urs.arg1:SetDisabled( false ) urs.arg2:SetDisabled( false ) if urs.restrictionlist:GetSelected()[1]:GetValue(1) == "Restrictions" or urs.restrictionlist:GetSelected()[1]:GetValue(1) == "Limits" then urs.arg1:SetText( line:GetValue(1) ) end end -------------------------------------------------------------------------------------------------------------------------------------------- urs.removebutton.DoClick = function() if urs.restrictionlist:GetSelected()[1]:GetValue(1) == "Restrictions" then for item, items in pairs( urs.itemlist:GetSelected() ) do if not urs.removers[items:GetValue(1)] then urs.removers[items:GetValue(1)] = { } end table.insert( urs.removers[items:GetValue(1)], items:GetValue(2) ) end for target, targets in pairs( urs.removers ) do LocalPlayer():ConCommand( "ulx unrestrict \"".. urs.typelist:GetSelected()[1]:GetValue(1) .."\" \"".. target .."\" ".. table.concat( urs.removers[target], " " ) ) end elseif urs.restrictionlist:GetSelected()[1]:GetValue(1) == "Limits" then for item, items in pairs( urs.itemlist:GetSelected() ) do table.insert( urs.removers, urs.itemlist:GetSelected()[item]:GetValue(2) ) end for group, groups in pairs( urs.removers ) do RunConsoleCommand( "ulx", "setlimit", urs.typelist:GetSelected()[1]:GetValue(1), urs.itemlist:GetSelected()[group]:GetValue(1), "-1" ) end elseif urs.restrictionlist:GetSelected()[1]:GetValue(1) == "Loadouts" then if urs.typelist:GetSelected()[1] then for weapon, weapons in pairs( urs.itemlist:GetSelected() ) do table.insert( urs.removers, weapons:GetValue(1) ) end LocalPlayer():ConCommand( "ulx loadoutremove \"".. urs.typelist:GetSelected()[1]:GetValue(1) .."\" ".. table.concat( urs.removers, " " ) ) end end urs.removebutton:SetDisabled( true ) urs.removers = {} end urs.addbutton.DoClick = function() if urs.restrictionlist:GetSelected()[1]:GetValue(1) == "Restrictions" or urs.restrictionlist:GetSelected()[1]:GetValue(1) == "Limits" then local cmd if urs.restrictionlist:GetSelected()[1]:GetValue(1) == "Restrictions" then cmd = "restrict" else cmd = "setlimit" end if urs.arg1:GetValue() and urs.arg2:GetValue() then LocalPlayer():ConCommand( "ulx ".. cmd .." \"".. urs.typelist:GetSelected()[1]:GetValue(1) .."\" \"".. (cmd == "restrict" and urs.arg2:GetValue() or urs.arg1:GetValue()) .."\" ".. (cmd == "restrict" and urs.arg1:GetValue() or urs.arg2:GetValue()) ) else LocalPlayer():ChatPrint( "Missing Argument(s) ~ Please fill in all text boxes." ) end else if urs.arg1:GetValue() and urs.arg2:GetValue() then LocalPlayer():ConCommand( "ulx loadoutadd \"".. urs.arg1:GetValue() .."\" ".. urs.arg2:GetValue() ) else LocalPlayer():ChatPrint( "Missing Argument(s) ~ Please fill in all text boxes." ) end end end -------------------------------------------------------------------------------------------------------------------------------------------- function URSRestrictionProcess( t ) urs.itemlist:Clear() if urs.restrictionlist:GetSelectedLine() then if urs.restrictionlist:GetSelected()[1]:GetValue(1) == "Restrictions" then if urs.typelist:GetSelectedLine() then for item, items in pairs( xgui.data.URSRestrictions[ urs.typelist:GetSelected()[1]:GetValue(1) ] ) do for group, groups in pairs( items ) do urs.itemlist:AddLine( item, groups ) end end end end end end xgui.hookEvent( "URSRestrictions", "process", URSRestrictionProcess ) function URSLimitsProcess( t ) urs.itemlist:Clear() if urs.restrictionlist:GetSelectedLine() then if urs.restrictionlist:GetSelected()[1]:GetValue(1) == "Limits" then if urs.typelist:GetSelectedLine() then for group, groups in pairs( xgui.data.URSLimits[ urs.typelist:GetSelected()[1]:GetValue(1) ] ) do urs.itemlist:AddLine( group, groups ) end end end end end xgui.hookEvent( "URSLimits", "process", URSLimitsProcess ) function URSLoadoutsProcess( t ) urs.itemlist:Clear() if urs.restrictionlist:GetSelectedLine() then if urs.restrictionlist:GetSelected()[1]:GetValue(1) == "Loadouts" then local selected if urs.typelist:GetSelectedLine() then selected = urs.typelist:GetSelected()[1]:GetValue(1) if xgui.data.URSLoadouts[ selected ] then for weapon, weapons in pairs( xgui.data.URSLoadouts[ selected ] ) do urs.itemlist:AddLine( weapons ) end end end urs.typelist:Clear() for group, groups in pairs( xgui.data.URSLoadouts ) do urs.typelist:AddLine( group ) end if selected then if urs.typelist["Lines"] then for line, lines in pairs( urs.typelist["Lines"] ) do if lines:GetValue(1) == selected then lines:SetSelected( true ) end end end end end end end xgui.hookEvent( "URSLoadouts", "process", URSLoadoutsProcess ) xgui.addSettingModule( "URS", urs.back, "icon16/shield.png" ) \ No newline at end of file diff --git a/urs_changelog_and_todo.txt b/urs_changelog_and_todo.txt new file mode 100644 index 0000000..a6a6dbc --- /dev/null +++ b/urs_changelog_and_todo.txt @@ -0,0 +1,86 @@ +================================================== +================================================== +URS Todo: (No Specific Order) + [GUI] Improve Auto-Completes + Easier ways to restrict multiple things + Fix Stacker not following limits. + SQL Integration +================================================== +================================================== + +10/16/2011 Revision 14: + + Added: Player Specific Restrictions + = Fixed: Weapon list is now more extensive + * Changed: URS Commands have been put in their own Lua file + * Changed: URS Server Side functions have been put in their own Lua file + * Changed: Several Lua files were renamed to seem more professional + + [GUI] Added: A "*" will now appear in groups for auto-completes that use it + * [GUI] Changed: Weapons are now saved to a variable rather then being called each time + * [GUI] Changed: Clicking on a group/steamid in loadouts will change the textbox + * [GUI] Changed: Clicking on a target/group in restrictions/limits will change the textbox + +8/15/2011 Revision 13: + = [GUI] Fixed: Remove/Add buttons would not handle spaces well + = Added: urs_changelog_and_todo.txt + = Changed: Priority of URS hooks are now higher. + = Fixed: Removing a global restriction remove everything + = Fixed: "ulx restrict all" limiting + +7/14/2011 Revision 12 + = [GUI] Added: Auto Completes + = Added: AdvDupe Restrictions + = Added: Weapon Pickup Restrictions + = Changed: Strings in restrictions are lowercased + = Fixed: Materials for icon should now be forced to download for the clients + = Fixed: Tool Usage Logging + = Removed: Auto-Save upon shutdown + +7/7/2011 Revision 11 + = [GUI] Added: Custom URS icon + = [GUI] Fixed: Loadouts from merging all loadouts into one + = [GUI] Fixed: Loadout's data sending made everything numbers + = Fixed: Echoing a blank table in ulx restrict + = Fixed: A small mistake with SENT restrictions + +7/1/2011 Revision 10 + = Fixed a problem with creating subtables + +6/26/2011 Revision 9 + = Added GUI + = Fixed (hopefully) all errors in all commands + +5/29/2011 Revision 8 + = Added Wildcard "*" -- You can restrict groups from everything! + = Fixed an issue that may cause other things such as Prop Protectors to fail + = Removed xgui.sendDataTable() from commands -- This is for the GUI + = Removed DebugPrint() -- No longer needed + +5/28/2011 Revision 7 +- Removed some debug +- Fixed loadoutremove and unrestrict skipping +- Added some stuff for future update (wildcard "*") + +5/22/2011 Revision 6 +- Fixed a small mistake in ulx print for limits +- Commands now use repeat_min, no more commas! +- Added a complete list for loadoutadd (weapons) +- Fixed unrestrict from skipping groups, previously missed + +5/13/2011 Revision 5 +- ulx_echours updates every command again +- Added an exclude list after specifying everyone(*) as a target - forrestrictions ONLY +(Ex. "ulx restrict tool duplicator *,superadmin,admin" ) +[Everyone except superadmins and admins are restricted from the duplicator] +- Added an all option to ulx print +- Some Optimization with commands and un-needed things + +5/11/2011 Revision 4 +- Removed unneeded "if SERVER then ... end" in ULX functions +- ulx_echoURS no longer checks every command +- Added a chat notification in ursprint.lua + +5/10/2011 Revision 3 +-Added command ulx print + +5/7/2011 Revision 2 +BETA RELEASE \ No newline at end of file diff --git a/urs_readme.txt b/urs_readme.txt new file mode 100644 index 0000000..a9d5437 --- /dev/null +++ b/urs_readme.txt @@ -0,0 +1,4 @@ + +For any help you may need, please visit this topic: + +http://forums.ulyssesmod.net/index.php/topic,5269.0.html \ No newline at end of file