ConVar system thingy

This commit is contained in:
Fesiug 2023-11-29 19:03:14 -05:00
parent 98e11fda6e
commit 51557c5f0e
4 changed files with 80 additions and 9 deletions

View File

@ -157,8 +157,6 @@ function SWEP:Reload( hand )
return true return true
end end
CreateClientConVar( "benny_toggleaim", 0, true, true )
hook.Add( "PlayerButtonDown", "Benny_PlayerButtonDown_TempForAim", function( ply, button ) hook.Add( "PlayerButtonDown", "Benny_PlayerButtonDown_TempForAim", function( ply, button )
local wep = ply:BennyCheck() local wep = ply:BennyCheck()

View File

@ -0,0 +1,74 @@
-- Meanings: Default, Min, Max, Replicated, Archived, Hint
-- Replicated is Userinfo in Client.
CONVARS_SV = {}
CONVARS_SV["cam_override"] = { "", nil, nil, true, false, "X Y Z P Y R FOV" }
CONVARS_SV["cam_unlock"] = { 0, 0, 1, true, false, "First person (sort of)" }
CONVARS_SV["net_easyway"] = { 0, 0, 1, true, false, "Use a disgusting way of networking inventories for minimal desync." }
CONVARS_SV_GEN = {}
for i, v in pairs( CONVARS_SV ) do
CONVARS_SV_GEN[i] = CreateConVar( "benny_" .. i, v[1], (v[4] and FCVAR_REPLICATED or 0) + (v[5] and FCVAR_ARCHIVE or 0), v[5], v[2], v[3] )
end
function ConVarSV( name )
return CONVARS_SV_GEN[name]
end
function ConVarSV_Bool( name )
return ConVarSV( name ):GetBool()
end
function ConVarSV_String( name )
return ConVarSV( name ):GetString()
end
function ConVarSV_Int( name )
return ConVarSV( name ):GetInt()
end
function ConVarSV_Float( name )
return ConVarSV( name ):GetFloat()
end
if CLIENT then -- CL CL CL
CONVARS_CL = {}
CONVARS_CL["hud_scale"] = { 2, 1, 4, false, true, "HUD integer scaling" }
CONVARS_CL["hud_tempactive"] = { "benny", nil, nil, false, true, "HUD color scheme temporary" }
CONVARS_CL["wep_toggleaim"] = { 1, 0, 1, true, true, "Hold or toggle to aim weapon." }
CONVARS_CL["wep_toolgun"] = { "", nil, nil, true, true, "Toolgun tool." }
CONVARS_CL_GEN = {}
for i, v in pairs( CONVARS_CL ) do
CONVARS_CL_GEN[i] = CreateConVar( "benny_" .. i, v[1], (v[4] and FCVAR_USERINFO or 0) + (v[5] and FCVAR_ARCHIVE or 0), v[5], v[2], v[3] )
end
function ConVarCL( name )
return CONVARS_CL_GEN[name]
end
function ConVarCL_Bool( name )
return ConVarCL( name ):GetBool()
end
function ConVarCL_String( name )
return ConVarCL( name ):GetString()
end
function ConVarCL_Int( name )
return ConVarCL( name ):GetInt()
end
function ConVarCL_Float( name )
return ConVarCL( name ):GetFloat()
end
end -- CL end CL end CL end

View File

@ -17,10 +17,8 @@ hook.Add( "HUDShouldDraw", "Benny_HUDShouldDraw", function( name )
if ( hide[ name ] ) then return false end if ( hide[ name ] ) then return false end
end ) end )
local HSCALE = CreateClientConVar( "benny_hud_scale", 2, true, false, "HUD scaling", 0, 4 )
function ss( scale ) function ss( scale )
return scale*HSCALE:GetInt()--math.Round( scale * ( ScrH() / 480 ) * HSCALE:GetFloat() ) return scale*ConVarCL_Int("hud_scale")--math.Round( scale * ( ScrH() / 480 ) * HSCALE:GetFloat() )
end end
local function genfonts() local function genfonts()
@ -220,15 +218,13 @@ local mat_long = Material("benny/hud/xhair/long.png", "")
local mat_dot_s = Material("benny/hud/xhair/dot_s.png", "mips smooth") local mat_dot_s = Material("benny/hud/xhair/dot_s.png", "mips smooth")
local mat_long_s = Material("benny/hud/xhair/long_s.png", "mips smooth") local mat_long_s = Material("benny/hud/xhair/long_s.png", "mips smooth")
local spacer_long = 2 -- screenscaled local spacer_long = 2 -- screenscaled
local gap = 24 local gap = 8
local trash_vec, trash_ang = Vector(), Angle() local trash_vec, trash_ang = Vector(), Angle()
bucket_selected = bucket_selected or 1 bucket_selected = bucket_selected or 1
item_selected = item_selected or 1 item_selected = item_selected or 1
CreateClientConVar( "benny_hud_tempactive", "benny", true, false )
hook.Add( "HUDPaint", "Benny_HUDPaint", function() hook.Add( "HUDPaint", "Benny_HUDPaint", function()
local sw, sh = ScrW(), ScrH() local sw, sh = ScrW(), ScrH()
local Wb = ss(20) local Wb = ss(20)
@ -719,6 +715,10 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
local inv = p:INV_Get() local inv = p:INV_Get()
local b_x, b_y = Wb, Hb local b_x, b_y = Wb, Hb
for i, v in ipairs( inv ) do
surface.SetDrawColor( scheme["bg"] )
end
end end
do -- Captions do -- Captions

View File

@ -150,7 +150,6 @@ AddSound( "Common.NoAmmo", "benny/weapons/noammo.ogg", 70, 100, 0.5, CHAN_STATIC
do -- Toolgun do -- Toolgun
CreateClientConVar( "benny_toolgun", "", true, true )
local ToolGunTools = { local ToolGunTools = {
["ammocrate"] = function( self, p, tr ) ["ammocrate"] = function( self, p, tr )
if SERVER then if SERVER then