• Print

Author Topic: URestrict(WIP)  (Read 18743 times)

0 Members and 1 Guest are viewing this topic.

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
URestrict(WIP)
« on: September 21, 2008, 08:03:45 pm »
Looking for new gui Ideas for the script.


« Last Edit: September 24, 2008, 06:54:12 pm by jay209015 »
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Megiddo_on_unsecure_wifi

  • Guest
Re: URestrict(WIP)
« Reply #1 on: September 21, 2008, 09:50:17 pm »
I didn't check your code too closely, but I believe you're supposed to hook the checkboxes up to a cvar if you want this functionality (should be one of the provided functions for the checkbox).

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: URestrict(WIP)
« Reply #2 on: September 22, 2008, 10:46:36 am »
Ok, that makes sence, but I've never create nor used ConVars, so all I need is a simple toggled 1|0 convar for each group. I think look at the code for the vgui you can see where I'm going with this.


==EDIT==
Perhaps I'll just do it with buttons like you did with the admin menu.
« Last Edit: September 22, 2008, 10:49:52 am by jay209015 »
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline gega2202

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: URestrict(WIP)
« Reply #3 on: September 23, 2008, 03:35:40 am »
 :D :D

URestrict! I'm new to this, and I'm not sure if this is the right place to post this... But...

Finally, what I've been waiting for! I have four questions about it...

Will it count for weapons, entities, and amount of props people can have too?

Will it work for Wiremod tools and other STool addons?

Will it have a full-on GUI or will some parts have to be done by LUA?

How long do you believe it will be until release?

(If I post in the wrong place, tell me where I should have posted this please)

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: URestrict(WIP)
« Reply #4 on: September 23, 2008, 06:15:57 pm »
Quote
Will it count for weapons, entities, and amount of props people can have too?
     - First half yes, second half no. This will restrict tools, sents, and weapons.
Quote
Will it work for Wiremod tools and other STool addons?
     - Not by default, but there will be a way to add Stools do the list.
Quote
Will it have a full-on GUI or will some parts have to be done by LUA?
     - First release will be mostly lua/config based, but later it will be a full-on gui.
Quote
How long do you believe it will be until release?
     - I can't give you a time frame at the moment, but providing a list of GCombat entities will bring the first release alot faster.

Current Progress:
  • I have Stool restrictions in place for select groups.
  • Entity restrictions is a current work in progress
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: URestrict(WIP)
« Reply #5 on: September 23, 2008, 06:20:51 pm »
Jay, much of what you're doing has been discussed many times around our forum.
Personally, I'd not try to re-invent the wheel..I'd just put chrome rims on it. :)

I think MrPresident has some examples somewhere around here for some group restrictions.
As long as you give credit, I can assure you any ideas you get from him or anyone else here, they don't mind sharing.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: URestrict(WIP)
« Reply #6 on: September 23, 2008, 06:57:32 pm »
I searched around, and found some stool restrictions, but it doesn't do what I now have can do atm. I just finished the STool restrictions, and I feel that it's done in a pretty easy way to understand.

Code: Lua
  1. URestrict = {} -- Don't touch this
  2.  
  3.  
  4. -- ==Start STool Configurations==--
  5.  
  6. -- Just insert tools your want to restrict here.
  7. URestrict.tools = {
  8.         "gcombat",
  9.         "dynamite",
  10. }
  11. -- To add groups to the allowed list, just create a table below in the format of URestrict.tool = { "group here" }
  12.  
  13. URestrict.gcombat = { "admins", "superadmin" } -- Your groups allowed to use GCombat
  14. URestrict.dynamite = { } -- Groups allow to use dynamite
  15.  
  16. --====End STool Configurations====--
  17.  
  18. --==Start Entity Configurations==--
  19.  
  20.  
  21. --====End Entity Configurations====--
  22.  
  23. -- =============================End of Configuration=============================--
  24.  
  25. function URestrict.GetUserGroup( ply )
  26.         for k,v in pairs( ULib.ucl.groups ) do -- Loops through the list of all the groups
  27.                 if ply:IsUserGroup( k ) then -- Checks to see if the player in question is a member of one of these groups
  28.                         return k -- If yes, then return that group
  29.                 end
  30.         end
  31. end
  32.  
  33. function URestrict.CanTool( ply, tr, tool )
  34.         for k,v in pairs( URestrict.tools ) do -- Loops through the list of restricted tools
  35.                 if tool == v then -- Checks to see if the tool in use is restricted
  36.                         if URestrict[v] then -- Make sure that the table of groups allowed exists
  37.                                 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
  38.                                         ply:PrintMessage( HUD_PRINTTALK, "This tool is restricted to certain groups" ) -- If not then display this message
  39.                                         return false -- And deny use
  40.                                 else
  41.                                         if #URestrict[v] == 0 then
  42.                                                 ply:PrintMessage( HUD_PRINTTALK, "This tools use has been revoked" )
  43.                                                 return false
  44.                                         end
  45.                                 end
  46.                         else
  47.                                 ply:PrintMessage( HUD_PRINTTALK, "This tools use has been revoked" )
  48.                                 return false -- If no groups are specified in the allowed list, or the list doesn't exist, then deny use to everyone
  49.                         end
  50.                 end
  51.         end
  52. end
  53. hook.Add( "CanTool", "URestrict_CanTool_Hook", URestrict.CanTool )

Next step is entity restrictions.

Any suggestions or changes that should be made to the script above? When ever I get a gui going with it, configs will be extemely easy.

==EDIT==
     -Code should now be set for JamminR's specifications :P
« Last Edit: September 23, 2008, 07:33:53 pm by jay209015 »
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: URestrict(WIP)
« Reply #7 on: September 23, 2008, 07:19:13 pm »
Hard habit to get into, I know, but do it now while you still only have a small amount;
spacing!
function( variable1, variable2 )
pairs ( table1[ var ] )

Looks like you're trying on some of it.
:)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: URestrict(WIP)
« Reply #8 on: September 23, 2008, 07:27:23 pm »
Yeah, I usually do that, but I was in a hurry to get to my homework on this script, so I left some formatting out :P.
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: URestrict(WIP)
« Reply #9 on: September 23, 2008, 07:29:50 pm »
Bah. Homework-moanwork. Get your priorities straight.

(JOKING!!)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: URestrict(WIP)
« Reply #10 on: September 24, 2008, 02:35:16 pm »
Added weapon/item restriction support:

Code: Lua
  1. URestrict = {} -- Don't touch this
  2. URestrict.loadout = {} -- Don't touch this
  3.  
  4. -- ==Start STool Configurations==--
  5.  
  6. -- Just insert tools your want to restrict here.
  7. URestrict.tools = {
  8.         "gcombat",
  9.         "dynamite",
  10. }
  11. -- To add groups to the allowed list, just create a table below in the format of URestrict.tool = { "group here" }
  12.  
  13. URestrict.gcombat = { "admins", "superadmin" } -- Your groups allowed to use GCombat
  14. URestrict.dynamite = { } -- Groups allow to use dynamite
  15.  
  16. --====End STool Configurations====--
  17.  
  18. --==Start Weapon Configurations==--
  19. -- 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" }
  20.  
  21. 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)
  22. URestrict.loadout.admin = { "weapon_physgun", "weapon_physcannon", "gmod_tool", "gmod_camera", "weapon_crowbar"  } -- Loadout for admins
  23. 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
  24.  
  25. --====End Weapon Configurations====--
  26.  
  27. -- =============================End of Configuration=============================--
  28.  
  29. function URestrict.GetUserGroup( ply )
  30.         for k,v in pairs( ULib.ucl.groups ) do -- Loops through the list of all the groups
  31.                 if ply:IsUserGroup( k ) then -- Checks to see if the player in question is a member of one of these groups
  32.                         return k -- If yes, then return that group
  33.                 end
  34.         end
  35. end
  36.  
  37. function URestrict.CanTool( ply, tr, tool )
  38.         for k,v in pairs( URestrict.tools ) do -- Loops through the list of restricted tools
  39.                 if tool == v then -- Checks to see if the tool in use is restricted
  40.                         if URestrict[v] then -- Make sure that the table of groups allowed exists
  41.                                 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
  42.                                         ply:PrintMessage( HUD_PRINTTALK, "This tool is restricted to certain groups" ) -- If not then display this message
  43.                                         return false -- And deny use
  44.                                 else
  45.                                         if #URestrict[ v ] == 0 then
  46.                                                 ply:PrintMessage( HUD_PRINTTALK, "This tools use has been revoked" )
  47.                                                 return false
  48.                                         end
  49.                                 end
  50.                         else
  51.                                 ply:PrintMessage( HUD_PRINTTALK, "This tools use has been revoked" )
  52.                                 return false -- If no groups are specified in the allowed list, or the list doesn't exist, then deny use to everyone
  53.                         end
  54.                 end
  55.         end
  56. end
  57. hook.Add( "CanTool", "URestrict_CanTool_Hook", URestrict.CanTool )
  58.  
  59. function URestrict.Loadout( ply )
  60.         if URestrict.loadout[URestrict.GetUserGroup( ply )] then
  61.                 for k, v in pairs( URestrict.loadout[URestrict.GetUserGroup( ply )] ) do
  62.                         ply:Give( v )
  63.                 end
  64.                 ply:SelectWeapon( URestrict.loadout[URestrict.GetUserGroup( ply )][1] )
  65.                 return true
  66.         else
  67.                 for k, v in pairs( URestrict.loadout.default ) do
  68.                         ply:Give( v )
  69.                 end
  70.                 ply:SelectWeapon( URestrict.loadout.default[1] )
  71.                 return true
  72.         end
  73. end
  74. hook.Add( "PlayerLoadout", "URestrict_Loadout_Hook", URestrict.Loadout )  
  75.  
  76. function URestrict.PickUp( ply, weap )
  77.         if URestrict.loadout[URestrict.GetUserGroup( ply )] then
  78.                 if not(table.HasValue( URestrict.loadout[URestrict.GetUserGroup( ply )], weap:GetClass() ) ) then
  79.                         return false
  80.                 end
  81.         else
  82.                 if not(table.HasValue( URestrict.loadout.default, weap:GetClass() ) ) then
  83.                         return false
  84.                 end
  85.         end
  86. end
  87. hook.Add( "PlayerCanPickupWeapon", "RandomUniqueName", PlayerCanPickupWeapon)

Next step is entity restriction. Should entity restriction be included? If yes, what are some default entities you'd like restrictions set on?
« Last Edit: September 24, 2008, 04:27:18 pm by jay209015 »
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: URestrict(WIP)
« Reply #11 on: September 24, 2008, 07:08:09 pm »
Code: [Select]
function URestrict()
local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 350, 350 )
DermaPanel:SetTitle( "URestrict Beta Menu" )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()

local PropertySheet = vgui.Create( "DPropertySheet" )
PropertySheet:SetParent( DermaPanel )
PropertySheet:SetPos( 5, 30 )
PropertySheet:SetSize( 340, 300 )

local SheetItemOne = vgui.Create( "DPanelList" )
SheetItemOne:SetPos( 0,0 )
SheetItemOne:SetSize( 330, 290 )
SheetItemOne:EnableHorizontal( false )
SheetItemOne:SetSpacing( 5 )
SheetItemOne:EnableVerticalScrollbar( true )

local Menu = vgui.Create("DButton", SheetItemOne)
Menu:SetText( "GCombat" )
Menu:SetPos( 0, 0 )
Menu:SetSize( 100,50 )
Menu.DoClick = function ( )
local MenuButtonOptions = DermaMenu() // Creates the menu
for k,v in pairs( ULib.ucl.groups ) do
MenuButtonOptions:AddOption(k, function() Msg("You added:" ..k.. "\n") end )
end
MenuButtonOptions:Open() // Open the menu AFTER adding your options
end
SheetItemOne:AddItem( Menu )

local SheetItemTwo = vgui.Create( "DPanelList" )
SheetItemTwo:SetPos( 0,0 )
SheetItemTwo:SetSize( 330, 290 )
SheetItemTwo:EnableHorizontal( false )
SheetItemTwo:SetSpacing( 5 )
SheetItemTwo:EnableVerticalScrollbar( true )

PropertySheet:AddSheet( "Tools", SheetItemOne, "gui/silkicons/user", false, false, "Settings For Tool Restrictions" )
PropertySheet:AddSheet( "Loadout", SheetItemTwo, "gui/silkicons/group", false, false, "Settings For Loadout Restrictions" )
end
concommand.Add( "URestrict", URestrict )



What do you think of this for a gui?
« Last Edit: September 24, 2008, 09:10:05 pm by jay209015 »
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: URestrict(WIP)
« Reply #12 on: September 26, 2008, 01:26:49 pm »


New and probably final gui design. How do you all like it?
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: URestrict(WIP)
« Reply #13 on: September 26, 2008, 10:50:59 pm »
So you click the button and it pops up the gui for selecting who you want access?

Would it be possible to use DListView and show all STOOLs on the server instead of having to add them? This would give the benefit of also being able to see who has access to what in an easy to read view.
Experiencing God's grace one day at a time.

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: URestrict(WIP)
« Reply #14 on: September 26, 2008, 11:38:33 pm »
Quote
So you click the button and it pops up the gui for selecting who you want access?
     - Yes
Quote
Would it be possible to use DListView and show all STOOLs on the server instead of having to add them? This would give the benefit of also being able to see who has access to what in an easy to read view.
     - No idea, but if it had all the stools already, you'd have to set all the groups to have access to all the tools. This way you can either complete restrict a tool, or just allow a few groups.

I finally completed the Tools section of both server side and client side gui ( I hate gui's and umsg )

Now's where the last part of the statement above come in place. I'm just about finished with the loadout menu, but if you have a group in the excluded section, and move it over to a Loadout preset, it show that group twice in list. Perhaps I should explain how it works first.
     You start out with defining preset names.
     Then you set what weapons, and items that you spawn with / can carry
     The gui for it works the same as the tools, but instead of showing tools in the list, it shows the groups, and the drop down options are the presets, exclude, and remove.

Client side and Server side lua attached.
« Last Edit: September 27, 2008, 10:23:33 am by jay209015 »
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

  • Print