Hello,
So within my code, I was wondering how I would make it so only if the user is the group superadmin the sheet in my DPropertySheet 'Admin Settings' would appear. Here is the code:
[LUA]
if CLIENT then
usermessage.Hook( "Openpls", function()
local base = vgui.Create( 'DFrame' )
base:SetSize( 550, 650 )
base:Center()
base:ShowCloseButton( true )
base:SetVisible( true )
base:MakePopup()
function base:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 18, 18, 18, 250 ) )
end
local bsheet = vgui.Create( 'DPropertySheet', base )
bsheet:Dock( FILL )
-- Main menu sheet
local main = vgui.Create( 'DPanel', bsheet )
function main:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 18, 18, 18, 250 ) )
end
-- Client settings sheet
local cset = vgui.Create( 'DPanel', bsheet )
function cset:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 18, 18, 18, 250 ) )
end
-- Admin settings sheet
local aset = vgui.Create( 'DPanel', asheet )
function aset:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 18, 18, 18, 250 ) )
end
-- Sheet configuration
bsheet:AddSheet( "Main", main, "icon16/user.png" )
bsheet:AddSheet( "Client Settings", cset, "icon16/cog.png" )
bsheet:AddSheet( "Admin Settings", aset, "icon16/shield.png" )
end )
end
if SERVER then
hook.Add( "PlayerSay", "Openpls", function( ply, text, public )
text = string.lower( text )
if ( string.sub( text, 1, 8 ) == "!jukebox" ) then
umsg.Start( "Openpls", ply )
umsg.End()
end
end )
end
[/LUA]
Essentially if the user is any group besides superadmin the sheet 'Admin Settings' will not appear. If they're superadmin then it will.
Thanks, Munch
[CODE]if CLIENT then
usermessage.Hook( "Openpls", function()
local base = vgui.Create( 'DFrame' )
base:SetSize( 550, 650 )
base:Center()
base:ShowCloseButton( true )
base:SetVisible( true )
base:MakePopup()
function base:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 18, 18, 18, 250 ) )
end
local bsheet = vgui.Create( 'DPropertySheet', base )
bsheet:Dock( FILL )
-- Main menu sheet
local main = vgui.Create( 'DPanel', bsheet )
function main:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 18, 18, 18, 250 ) )
end
-- Client settings sheet
local cset = vgui.Create( 'DPanel', bsheet )
function cset:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 18, 18, 18, 250 ) )
end
-- Admin settings sheet
local aset = vgui.Create( 'DPanel', asheet ) -- Are you sure about this? asheet is nil, according to the code.
function aset:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 18, 18, 18, 250 ) )
end
-- Sheet configuration
bsheet:AddSheet( "Main", main, "icon16/user.png" )
bsheet:AddSheet( "Client Settings", cset, "icon16/cog.png" )
if LocalPlayer():IsSuperAdmin() then
bsheet:AddSheet( "Admin Settings", aset, "icon16/shield.png" )
else
aset:Remove()
end
end )
end[/CODE]
[QUOTE=krekeris;48375190][CODE]if CLIENT then
usermessage.Hook( "Openpls", function()
local base = vgui.Create( 'DFrame' )
base:SetSize( 550, 650 )
base:Center()
base:ShowCloseButton( true )
base:SetVisible( true )
base:MakePopup()
function base:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 18, 18, 18, 250 ) )
end
local bsheet = vgui.Create( 'DPropertySheet', base )
bsheet:Dock( FILL )
-- Main menu sheet
local main = vgui.Create( 'DPanel', bsheet )
function main:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 18, 18, 18, 250 ) )
end
-- Client settings sheet
local cset = vgui.Create( 'DPanel', bsheet )
function cset:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 18, 18, 18, 250 ) )
end
-- Admin settings sheet
local aset = vgui.Create( 'DPanel', asheet ) -- Are you sure about this? asheet is nil, according to the code.
function aset:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 18, 18, 18, 250 ) )
end
-- Sheet configuration
bsheet:AddSheet( "Main", main, "icon16/user.png" )
bsheet:AddSheet( "Client Settings", cset, "icon16/cog.png" )
if LocalPlayer():IsSuperAdmin() then
bsheet:AddSheet( "Admin Settings", aset, "icon16/shield.png" )
else
aset:Remove()
end
end )
end[/CODE][/QUOTE]
What if I wanted to add another group?
[LUA]
if LocalPlayer():IsSuperAdmin() or IsAdmin() then
[/LUA]
Would that work?
Just use the same LocalPlayer(): in front of it and it should work, but I believe IsAdmin calls for SuperAdmin as well so you'd only need one
You can use this instead:
[CODE]if LocalPlayer():IsUserGroup("yourgrouphere") then[/CODE]
Sorry, you need to Log In to post a reply to this thread.