2012-12-18 16:12:43 -05:00
-- Written by Team Ulysses, http://ulyssesmod.net/
module ( " Utime " , package.seeall )
if not CLIENT then return end
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
local gpanel
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
--Now convars!
2012-12-18 16:26:40 -05:00
local utime_enable = CreateClientConVar ( " utime_enable " , " 1.0 " , true , false )
local utime_outsidecolor_r = CreateClientConVar ( " utime_outsidecolor_r " , " 256.0 " , true , false )
local utime_outsidecolor_g = CreateClientConVar ( " utime_outsidecolor_g " , " 256.0 " , true , false )
local utime_outsidecolor_b = CreateClientConVar ( " utime_outsidecolor_b " , " 256.0 " , true , false )
local utime_outsidetext_r = CreateClientConVar ( " utime_outsidetext_r " , " 0.0 " , true , false )
local utime_outsidetext_g = CreateClientConVar ( " utime_outsidetext_g " , " 0.0 " , true , false )
local utime_outsidetext_b = CreateClientConVar ( " utime_outsidetext_b " , " 0.0 " , true , false )
2013-07-27 14:29:51 -04:00
2012-12-18 16:26:40 -05:00
local utime_insidecolor_r = CreateClientConVar ( " utime_insidecolor_r " , " 256.0 " , true , false )
local utime_insidecolor_g = CreateClientConVar ( " utime_insidecolor_g " , " 256.0 " , true , false )
local utime_insidecolor_b = CreateClientConVar ( " utime_insidecolor_b " , " 256.0 " , true , false )
local utime_insidetext_r = CreateClientConVar ( " utime_insidetext_r " , " 0 " , true , false )
local utime_insidetext_g = CreateClientConVar ( " utime_insidetext_g " , " 0 " , true , false )
local utime_insidetext_b = CreateClientConVar ( " utime_insidetext_b " , " 0 " , true , false )
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
local utime_pos_x = CreateClientConVar ( " utime_pos_x " , " 0.0 " , true , false )
local utime_pos_y = CreateClientConVar ( " utime_pos_y " , " 0.0 " , true , false )
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
local PANEL = { }
PANEL.Small = 40
PANEL.TargetSize = PANEL.Small
PANEL.Large = 100
PANEL.Wide = 160
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
function initialize ( )
gpanel = vgui.Create ( " UTimeMain " )
gpanel : SetSize ( gpanel.Wide , gpanel.Small )
hook.Remove ( " OnEntityCreated " , " UtimeInitialize " )
end
hook.Add ( " InitPostEntity " , " UtimeInitialize " , initialize )
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
function think ( )
2013-07-27 14:39:11 -04:00
if not LocalPlayer ( ) : IsValid ( ) or gpanel == nil then return end
2013-07-27 14:29:51 -04:00
if not utime_enable : GetBool ( ) or not IsValid ( LocalPlayer ( ) ) or
2013-01-07 19:45:56 -05:00
( IsValid ( LocalPlayer ( ) : GetActiveWeapon ( ) ) and LocalPlayer ( ) : GetActiveWeapon ( ) : GetClass ( ) == " gmod_camera " ) then
gpanel : SetVisible ( false )
2012-12-18 16:12:43 -05:00
else
2013-01-07 19:45:56 -05:00
gpanel : SetVisible ( true )
2012-12-18 16:12:43 -05:00
end
2013-07-27 14:29:51 -04:00
--gpanel:SetPos( ScrW() - gpanel:GetWide() - 20, 20 )
gpanel : SetPos ( ( ScrW ( ) - gpanel : GetWide ( ) ) * utime_pos_x : GetFloat ( ) / 100 , ( ScrH ( ) - gpanel.Large ) * utime_pos_y : GetFloat ( ) / 100 )
2012-12-18 16:26:40 -05:00
2012-12-18 16:12:43 -05:00
local textColor = Color ( utime_outsidetext_r : GetInt ( ) , utime_outsidetext_g : GetInt ( ) , utime_outsidetext_b : GetInt ( ) , 255 )
2012-12-18 16:26:40 -05:00
gpanel.lblTotalTime : SetTextColor ( textColor )
2013-07-27 14:29:51 -04:00
gpanel.lblSessionTime : SetTextColor ( textColor )
2012-12-18 16:26:40 -05:00
gpanel.total : SetTextColor ( textColor )
2013-07-27 14:29:51 -04:00
gpanel.session : SetTextColor ( textColor )
2012-12-18 16:26:40 -05:00
2013-07-27 14:29:51 -04:00
local insideTextColor = Color ( utime_insidetext_r : GetInt ( ) , utime_insidetext_g : GetInt ( ) , utime_insidetext_b : GetInt ( ) , 255 )
2012-12-18 16:26:40 -05:00
gpanel.playerInfo . lblTotalTime : SetTextColor ( insideTextColor )
gpanel.playerInfo . lblSessionTime : SetTextColor ( insideTextColor )
gpanel.playerInfo . lblNick : SetTextColor ( insideTextColor )
gpanel.playerInfo . total : SetTextColor ( insideTextColor )
gpanel.playerInfo . session : SetTextColor ( insideTextColor )
gpanel.playerInfo . nick : SetTextColor ( insideTextColor )
2012-12-18 16:12:43 -05:00
end
2012-12-18 16:26:40 -05:00
timer.Create ( " UTimeThink " , 0.6 , 0 , think )
2013-07-27 14:29:51 -04:00
2016-11-14 23:48:39 -05:00
local texGradient = surface.GetTextureID ( " gui/gradient " )
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
--PANEL.InnerColor = Color( 250, 250, 245, 255 )
--PANEL.OuterColor = Color( 0, 150, 245, 200 )
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
2012-12-18 16:26:40 -05:00
-- Name: Paint
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
2013-07-27 14:29:51 -04:00
function PANEL : Paint ( w , h )
2012-12-18 16:26:40 -05:00
local wide = self : GetWide ( )
local tall = self : GetTall ( )
2013-07-27 14:29:51 -04:00
2012-12-18 16:26:40 -05:00
local outerColor = Color ( utime_outsidecolor_r : GetInt ( ) , utime_outsidecolor_g : GetInt ( ) , utime_outsidecolor_b : GetInt ( ) , 200 )
draw.RoundedBox ( 4 , 0 , 0 , wide , tall , outerColor ) -- Draw our base
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
surface.SetTexture ( texGradient )
2012-12-18 16:26:40 -05:00
surface.SetDrawColor ( 255 , 255 , 255 , 50 )
surface.SetDrawColor ( outerColor )
2013-07-27 14:29:51 -04:00
surface.DrawTexturedRect ( 0 , 0 , wide , tall ) -- Draw gradient overlay
2012-12-18 16:26:40 -05:00
if self : GetTall ( ) > self.Small + 4 then -- Draw the white background for another player's info
local innerColor = Color ( utime_insidecolor_r : GetInt ( ) , utime_insidecolor_g : GetInt ( ) , utime_insidecolor_b : GetInt ( ) , 255 )
draw.RoundedBox ( 4 , 2 , self.Small , wide - 4 , tall - self.Small - 2 , innerColor )
2013-07-27 14:29:51 -04:00
2012-12-18 16:26:40 -05:00
surface.SetTexture ( texGradient )
surface.SetDrawColor ( color_white )
surface.SetDrawColor ( innerColor )
2013-07-27 14:29:51 -04:00
surface.DrawTexturedRect ( 2 , self.Small , wide - 4 , tall - self.Small - 2 ) -- Gradient overlay
2012-12-18 16:26:40 -05:00
end
2013-07-27 14:29:51 -04:00
2012-12-18 16:26:40 -05:00
return true
2012-12-18 16:12:43 -05:00
end
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
2012-12-18 16:26:40 -05:00
-- Name: Init
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
function PANEL : Init ( )
2012-12-18 16:26:40 -05:00
self.Size = self.Small
2013-07-27 14:29:51 -04:00
2012-12-18 16:26:40 -05:00
self.playerInfo = vgui.Create ( " UTimePlayerInfo " , self )
2013-07-27 14:29:51 -04:00
2012-12-18 16:26:40 -05:00
self.lblTotalTime = vgui.Create ( " DLabel " , self )
self.lblSessionTime = vgui.Create ( " DLabel " , self )
2013-07-27 14:29:51 -04:00
2012-12-18 16:26:40 -05:00
self.total = vgui.Create ( " DLabel " , self )
2013-07-27 14:29:51 -04:00
self.session = vgui.Create ( " DLabel " , self )
2012-12-18 16:12:43 -05:00
end
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
2012-12-18 16:26:40 -05:00
-- Name: ApplySchemeSettings
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
function PANEL : ApplySchemeSettings ( )
2012-12-18 16:26:40 -05:00
self.lblTotalTime : SetFont ( " DermaDefault " )
self.lblSessionTime : SetFont ( " DermaDefault " )
self.total : SetFont ( " DermaDefault " )
2013-07-27 14:29:51 -04:00
self.session : SetFont ( " DermaDefault " )
2012-12-18 16:26:40 -05:00
self.lblTotalTime : SetTextColor ( color_black )
self.lblSessionTime : SetTextColor ( color_black )
self.total : SetTextColor ( color_black )
2013-07-27 14:29:51 -04:00
self.session : SetTextColor ( color_black )
2012-12-18 16:12:43 -05:00
end
2013-07-27 14:29:51 -04:00
2016-01-24 08:28:33 -05:00
-----------------------------------------------------------
-- Name: ShouldRevealPlayer
-----------------------------------------------------------
function PANEL : ShouldRevealPlayer ( ply )
if ply : GetNWBool ( " disguised " , false ) then -- TTT disguiser
return false
end
if engine.ActiveGamemode ( ) == " murder " and not LocalPlayer ( ) : IsAdmin ( ) then
return false
end
2017-08-10 19:30:58 -04:00
if engine.ActiveGamemode ( ) == " zombiesurvival " then
local wraith = GAMEMODE.ZombieClasses [ " Wraith " ] . Index
if ply : Team ( ) == TEAM_UNDEAD and ply : GetZombieClass ( ) == wraith then
return false
end
end
2016-01-24 08:28:33 -05:00
return true
end
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
2012-12-18 16:26:40 -05:00
-- Name: Think
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
local locktime = 0
2013-07-27 14:29:51 -04:00
function PANEL : Think ( )
2012-12-18 16:12:43 -05:00
if self.Size == self.Small then
self.playerInfo : SetVisible ( false )
else
self.playerInfo : SetVisible ( true )
2013-07-27 14:29:51 -04:00
end
2015-12-16 19:42:02 -05:00
if not IsValid ( LocalPlayer ( ) ) then return end
2016-01-24 08:28:33 -05:00
2012-12-18 16:26:40 -05:00
local tr = util.GetPlayerTrace ( LocalPlayer ( ) , LocalPlayer ( ) : GetAimVector ( ) )
2013-07-27 14:29:51 -04:00
local trace = util.TraceLine ( tr )
2016-01-24 08:28:33 -05:00
local ply = trace.Entity
if ply and ply : IsValid ( ) and ply : IsPlayer ( ) and self : ShouldRevealPlayer ( ply ) then
2012-12-18 16:12:43 -05:00
self.TargetSize = self.Large
self.playerInfo : SetPlayer ( trace.Entity )
locktime = CurTime ( )
end
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
if locktime + 2 < CurTime ( ) then
self.TargetSize = self.Small
end
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
if self.Size ~= self.TargetSize then
self.Size = math.Approach ( self.Size , self.TargetSize , ( math.abs ( self.Size - self.TargetSize ) + 1 ) * 8 * FrameTime ( ) )
self : PerformLayout ( )
end
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
self.total : SetText ( timeToStr ( LocalPlayer ( ) : GetUTimeTotalTime ( ) ) )
self.session : SetText ( timeToStr ( LocalPlayer ( ) : GetUTimeSessionTime ( ) ) )
end
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
2012-12-18 16:26:40 -05:00
-- Name: PerformLayout
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
function PANEL : PerformLayout ( )
self : SetSize ( self : GetWide ( ) , self.Size )
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
self.lblTotalTime : SetSize ( 52 , 18 )
self.lblTotalTime : SetPos ( 8 , 2 )
2013-07-27 14:29:51 -04:00
self.lblTotalTime : SetText ( " Total: " )
2012-12-18 16:12:43 -05:00
self.lblSessionTime : SetSize ( 52 , 18 )
self.lblSessionTime : SetPos ( 8 , 20 )
self.lblSessionTime : SetText ( " Session: " )
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
self.total : SetSize ( self : GetWide ( ) - 52 , 18 )
self.total : SetPos ( 52 , 2 )
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
self.session : SetSize ( self : GetWide ( ) - 52 , 18 )
2013-07-27 14:29:51 -04:00
self.session : SetPos ( 52 , 20 )
2012-12-18 16:12:43 -05:00
self.playerInfo : SetPos ( 0 , 42 )
self.playerInfo : SetSize ( self : GetWide ( ) - 8 , self : GetTall ( ) - 42 )
end
vgui.Register ( " UTimeMain " , PANEL , " Panel " )
local INFOPANEL = { }
-----------------------------------------------------------
2012-12-18 16:26:40 -05:00
-- Name: Init
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
function INFOPANEL : Init ( )
2012-12-18 16:26:40 -05:00
self.lblTotalTime = vgui.Create ( " DLabel " , self )
self.lblSessionTime = vgui.Create ( " DLabel " , self )
self.lblNick = vgui.Create ( " DLabel " , self )
2013-07-27 14:29:51 -04:00
2012-12-18 16:26:40 -05:00
self.total = vgui.Create ( " DLabel " , self )
2013-07-27 14:29:51 -04:00
self.session = vgui.Create ( " DLabel " , self )
self.nick = vgui.Create ( " DLabel " , self )
2012-12-18 16:12:43 -05:00
end
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
2012-12-18 16:26:40 -05:00
-- Name: SetPlayer
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
function INFOPANEL : SetPlayer ( ply )
2012-12-18 16:26:40 -05:00
self.Player = ply
2012-12-18 16:12:43 -05:00
end
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
2012-12-18 16:26:40 -05:00
-- Name: ApplySchemeSettings
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
function INFOPANEL : ApplySchemeSettings ( )
2012-12-18 16:26:40 -05:00
self.lblTotalTime : SetFont ( " DermaDefault " )
self.lblSessionTime : SetFont ( " DermaDefault " )
self.lblNick : SetFont ( " DermaDefault " )
self.total : SetFont ( " DermaDefault " )
2013-07-27 14:29:51 -04:00
self.session : SetFont ( " DermaDefault " )
self.nick : SetFont ( " DermaDefault " )
2012-12-18 16:26:40 -05:00
self.lblTotalTime : SetTextColor ( color_black )
self.lblSessionTime : SetTextColor ( color_black )
self.lblNick : SetTextColor ( color_black )
self.total : SetTextColor ( color_black )
2013-07-27 14:29:51 -04:00
self.session : SetTextColor ( color_black )
self.nick : SetTextColor ( color_black )
2012-12-18 16:12:43 -05:00
end
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
2012-12-18 16:26:40 -05:00
-- Name: Think
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
function INFOPANEL : Think ( )
2012-12-18 16:26:40 -05:00
local ply = self.Player
if not ply or not ply : IsValid ( ) or not ply : IsPlayer ( ) then -- Disconnected
self : GetParent ( ) . TargetSize = self : GetParent ( ) . Small
return
end
2013-07-27 14:29:51 -04:00
2012-12-18 16:26:40 -05:00
self.total : SetText ( timeToStr ( ply : GetUTime ( ) + CurTime ( ) - ply : GetUTimeStart ( ) ) )
self.session : SetText ( timeToStr ( CurTime ( ) - ply : GetUTimeStart ( ) ) )
self.nick : SetText ( ply : Nick ( ) )
2012-12-18 16:12:43 -05:00
end
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
2012-12-18 16:26:40 -05:00
-- Name: PerformLayout
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
function INFOPANEL : PerformLayout ( )
2012-12-18 16:26:40 -05:00
self.lblNick : SetSize ( 52 , 18 )
self.lblNick : SetPos ( 8 , 0 )
self.lblNick : SetText ( " Nick: " )
2013-07-27 14:29:51 -04:00
2012-12-18 16:26:40 -05:00
self.lblTotalTime : SetSize ( 52 , 18 )
self.lblTotalTime : SetPos ( 8 , 18 )
2013-07-27 14:29:51 -04:00
self.lblTotalTime : SetText ( " Total: " )
2012-12-18 16:26:40 -05:00
self.lblSessionTime : SetSize ( 52 , 18 )
self.lblSessionTime : SetPos ( 8 , 36 )
self.lblSessionTime : SetText ( " Session: " )
2013-07-27 14:29:51 -04:00
2012-12-18 16:26:40 -05:00
self.nick : SetSize ( self : GetWide ( ) - 52 , 18 )
self.nick : SetPos ( 52 , 0 )
2013-07-27 14:29:51 -04:00
2012-12-18 16:26:40 -05:00
self.total : SetSize ( self : GetWide ( ) - 52 , 18 )
self.total : SetPos ( 52 , 18 )
2013-07-27 14:29:51 -04:00
2012-12-18 16:26:40 -05:00
self.session : SetSize ( self : GetWide ( ) - 52 , 18 )
2013-07-27 14:29:51 -04:00
self.session : SetPos ( 52 , 36 )
2012-12-18 16:12:43 -05:00
end
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
2012-12-18 16:26:40 -05:00
-- Name: Paint
2012-12-18 16:12:43 -05:00
-----------------------------------------------------------
function INFOPANEL : Paint ( )
2012-12-18 16:26:40 -05:00
return true
2012-12-18 16:12:43 -05:00
end
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
vgui.Register ( " UTimePlayerInfo " , INFOPANEL , " Panel " )
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
----------------------------------------------------------------------------------------------------------
-- Now for the control panels!
----------------------------------------------------------------------------------------------------------
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
function resetCvars ( )
2012-12-18 16:26:40 -05:00
RunConsoleCommand ( " utime_outsidecolor_r " , " 0 " )
RunConsoleCommand ( " utime_outsidecolor_g " , " 150 " )
RunConsoleCommand ( " utime_outsidecolor_b " , " 245 " )
2013-07-27 14:29:51 -04:00
2012-12-18 16:26:40 -05:00
RunConsoleCommand ( " utime_outsidetext_r " , " 255 " )
RunConsoleCommand ( " utime_outsidetext_g " , " 255 " )
RunConsoleCommand ( " utime_outsidetext_b " , " 255 " )
2013-07-27 14:29:51 -04:00
2012-12-18 16:26:40 -05:00
RunConsoleCommand ( " utime_insidecolor_r " , " 250 " )
RunConsoleCommand ( " utime_insidecolor_g " , " 250 " )
RunConsoleCommand ( " utime_insidecolor_b " , " 245 " )
2013-07-27 14:29:51 -04:00
2012-12-18 16:26:40 -05:00
RunConsoleCommand ( " utime_insidetext_r " , " 0 " )
RunConsoleCommand ( " utime_insidetext_g " , " 0 " )
RunConsoleCommand ( " utime_insidetext_b " , " 0 " )
2013-07-27 14:29:51 -04:00
2012-12-18 16:26:40 -05:00
RunConsoleCommand ( " utime_pos_x " , " 98 " )
RunConsoleCommand ( " utime_pos_y " , " 8 " )
buildCP ( controlpanel.Get ( " Utime " ) )
2012-12-18 16:12:43 -05:00
end
concommand.Add ( " utime_reset " , resetCvars )
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
function buildCP ( cpanel )
2015-08-20 13:32:01 -04:00
if not cpanel then return end
2012-12-18 16:26:40 -05:00
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 " } )
2013-07-27 14:29:51 -04:00
cpanel : AddControl ( " Slider " , { Label = " Position Y " , Command = " utime_pos_y " , Type = " Float " , Min = " 0 " , Max = " 100 " } )
2012-12-18 16:26:40 -05:00
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 " } )
2013-07-27 14:29:51 -04:00
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 " } )
2012-12-18 16:26:40 -05:00
cpanel : AddControl ( " Button " , { Text = " Reset " , Label = " Reset colors and position " , Command = " utime_reset " } )
2012-12-18 16:12:43 -05:00
end
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
function spawnMenuOpen ( )
2012-12-18 16:26:40 -05:00
buildCP ( controlpanel.Get ( " Utime " ) )
2012-12-18 16:12:43 -05:00
end
hook.Add ( " SpawnMenuOpen " , " UtimeSpawnMenuOpen " , spawnMenuOpen )
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
function popToolMenu ( )
2025-01-16 13:08:24 -05:00
spawnmenu.AddToolMenuOption ( " Options " , " Utime Controls " , " Utime " , " Utime " , " " , " " , buildCP )
2012-12-18 16:12:43 -05:00
end
hook.Add ( " PopulateToolMenu " , " UtimePopulateTools " , popToolMenu )
2013-07-27 14:29:51 -04:00
2012-12-18 16:12:43 -05:00
function onEntCreated ( ent )
2012-12-18 16:26:40 -05:00
if LocalPlayer ( ) : IsValid ( ) then -- LocalPlayer was created and is valid now
if utime_outsidecolor_r : GetInt ( ) == 256 then resetCvars ( ) end
end
2012-12-18 16:12:43 -05:00
end
hook.Add ( " OnEntityCreated " , " UTimeLocalPlayerCheck " , onEntCreated ) -- Flag server when we created LocalPlayer()