----------------------------------------------------------------------------------------------------------
-- Now for the control panels!
----------------------------------------------------------------------------------------------------------
function resetCvars()
RunConsoleCommand( "utime_outsidecolor_r", "0" )
RunConsoleCommand( "utime_outsidecolor_g", "150" )
RunConsoleCommand( "utime_outsidecolor_b", "245" )
RunConsoleCommand( "utime_outsidetext_r", "255" )
RunConsoleCommand( "utime_outsidetext_g", "255" )
RunConsoleCommand( "utime_outsidetext_b", "255" )
RunConsoleCommand( "utime_insidecolor_r", "250" )
RunConsoleCommand( "utime_insidecolor_g", "250" )
RunConsoleCommand( "utime_insidecolor_b", "245" )
RunConsoleCommand( "utime_insidetext_r", "0" )
RunConsoleCommand( "utime_insidetext_g", "0" )
RunConsoleCommand( "utime_insidetext_b", "0" )
RunConsoleCommand( "utime_pos_x", "98" )
RunConsoleCommand( "utime_pos_y", "8" )
buildCP( controlpanel.Get( "Utime" ) )
end
concommand.Add( "utime_reset", resetCvars )
function buildCP( cpanel )
(line 310) cpanel:ClearControls()
cpanel:AddControl( "Header", { Text = "UTime by Megiddo (Team Ulysses)" } )
cpanel:AddControl( "Checkbox", { Label = "Enable", Command = "utime_enable" } )
cpanel:AddControl( "Slider", { Label = "Position X", Command = "utime_pos_x", Type = "Float", Min = "0", Max = "100" } )
cpanel:AddControl( "Slider", { Label = "Position Y", Command = "utime_pos_y", Type = "Float", Min = "0", Max = "100" } )
cpanel:AddControl( "Color", { Label = "Outside Color", Red = "utime_outsidecolor_r", Green = "utime_outsidecolor_g", Blue = "utime_outsidecolor_b", ShowAlpha = "0", ShowHSV = "1", ShowRGB = "1", Multiplier = "255" } )
cpanel:AddControl( "Color", { Label = "Outside Text Color", Red = "utime_outsidetext_r", Green = "utime_outsidetext_g", Blue = "utime_outsidetext_b", ShowAlpha = "0", ShowHSV = "1", ShowRGB = "1", Multiplier = "255" } )
cpanel:AddControl( "Color", { Label = "Inside Color", Red = "utime_insidecolor_r", Green = "utime_insidecolor_g", Blue = "utime_insidecolor_b", ShowAlpha = "0", ShowHSV = "1", ShowRGB = "1", Multiplier = "255" } )
cpanel:AddControl( "Color", { Label = "Inside Text Color", Red = "utime_insidetext_r", Green = "utime_insidetext_g", Blue = "utime_insidetext_b", ShowAlpha = "0", ShowHSV = "1", ShowRGB = "1", Multiplier = "255" } )
cpanel:AddControl( "Button", { Text = "Reset", Label = "Reset colors and position", Command = "utime_reset" } )
end
function spawnMenuOpen()
buildCP( controlpanel.Get( "Utime" ) )
end
hook.Add( "SpawnMenuOpen", "UtimeSpawnMenuOpen", spawnMenuOpen )
function popToolMenu()
spawnmenu.AddToolMenuOption( "Utilities", "Utime Controls", "Utime", "Utime", "", "", buildCP )
end
hook.Add( "PopulateToolMenu", "UtimePopulateTools", popToolMenu )
function onEntCreated( ent )
if LocalPlayer():IsValid() then -- LocalPlayer was created and is valid now
if utime_outsidecolor_r:GetInt() == 256 then resetCvars() end
end
end
hook.Add( "OnEntityCreated", "UTimeLocalPlayerCheck", onEntCreated ) -- Flag server when we created LocalPlayer()