PivityGmodStore

Inaccessible settings

This topic is needed if you want to make some settings inaccessible to normal players.




Getting Started

The addon creates a unique server-side variable svuid at first startup, which is transferred to the players when they connects. This way the addon understands which config from the data folder should be used.

If you have added / deleted / made important changes, you may need to change the svuid so that all players start using the new config (does not apply to players who first logged into the server). To do this, go to the server folder, go to garrysmod\data\sv_esclib, delete the server_uid.json file and restart the server. In this way you will update the settings of all players, resetting them to the base (from your config)




Open ehud/lua/ehud/config/ehud_advanced_config.lua

Let's do this using the modules tab as an example:


Basic modules layout

---------------
/// MODULES ///
---------------
--tab creating
local tab = settings:AddTab("modules") --uid
tab:SetNameTranslateKey("tab_modules") --key in language file
tab:SetPosition(1) --postion


--adding vars
local var = tab:AddVar("module_hud_leftbot", "bool")
var:SetNameTranslateKey("s_mainhud_name") --key in language file
var:SetValue(ehud.modules["MainHUD"])


local var = tab:AddVar("module_hud_gun", "bool")
var:SetNameTranslateKey("s_gunhud_name")
var:SetValue(ehud.modules["GunHUD"])


local var = tab:AddVar("module_hud_arrested", "bool")
var:SetNameTranslateKey("s_arrestedhud_name")
var:SetValue(ehud.modules["ArrestHUD"])


local var = tab:AddVar("module_hud_doors", "bool")
var:SetNameTranslateKey("s_doorshud_name")
var:SetValue(ehud.modules["DoorsHUD"])


local var = tab:AddVar("module_fpp", "bool")
var:SetNameTranslateKey("s_fpp_name")
var:SetDescTranslateKey("s_fpp_desc")
var:SetValue(ehud.modules["FPPHUD"])
var:CustomCheck(function(self,addon)
return DarkRP ~= nil
end)


local var = tab:AddVar("module_ply_over", "bool")
var:SetNameTranslateKey("s_plyover_name")
var:SetValue(ehud.modules["PlayerOverheadHUD"])


local var = tab:AddVar("module_agenda", "bool")
var:SetNameTranslateKey("s_agenda_name")
var:SetValue(ehud.modules["AgendaHUD"])


--you can use checks for this
if ehud.config.hitmarkers then
local var = tab:AddVar("module_hitmarker", "bool")
var:SetNameTranslateKey("s_hitmark_name")
var:SetDescTranslateKey("s_hitmark_desc")
var:SetValue(ehud.modules["HitmarkHUD"])
end


local var = tab:AddVar("module_voice", "bool")
var:SetNameTranslateKey("s_voice_name")
var:SetValue(ehud.modules["VoiceHUD"])


local var = tab:AddVar("module_lockdown", "bool")
var:SetNameTranslateKey("s_lockdown_name")
var:SetValue(ehud.modules["LockdownHUD"])


local var = tab:AddVar("module_deathscreen", "bool")
var:SetNameTranslateKey("s_deathscreen_name")
var:SetValue(ehud.modules["DeathscreenHUD"])


local var = tab:AddVar("module_notify", "bool")
var:SetNameTranslateKey("s_notify_name")
var:SetValue(ehud.modules["NotifyHUD"])


local var = tab:AddVar("module_crashscreen", "bool")
var:SetNameTranslateKey("s_crash_name")
var:SetDescTranslateKey("s_crash_desc")
var:SetValue(ehud.modules["CrashscreenHUD"])


local var = tab:AddVar("module_vehicle_hud", "bool")
var:SetNameTranslateKey("s_vehicle_name")
var:SetValue(ehud.modules["VehicleHUD"])




Added custom checks

---------------
/// MODULES ///
---------------
--who can change?
local modules_access = {
["superadmin"] = true,
}


--tab creating
local tab = settings:AddTab("modules") --uid
tab:SetNameTranslateKey("tab_modules") --key in language file
tab:SetPosition(1) --postion
tab:CustomCheck(function() --you can set up own customcheck (for tabs it only for visibility)
return modules_access[LocalPlayer():GetUserGroup()] or esclib:HasAdminAccess(LocalPlayer())
end) -- adding checks


--adding vars
local var = tab:AddVar("module_hud_leftbot", "bool")
var:SetNameTranslateKey("s_mainhud_name") --key in language file
var:SetValue(ehud.modules["MainHUD"])
var:CanChange("usergroup",modules_access) --check for it


local var = tab:AddVar("module_hud_gun", "bool")
var:SetNameTranslateKey("s_gunhud_name")
var:SetValue(ehud.modules["GunHUD"])
var:CanChange("usergroup",modules_access) -- check


local var = tab:AddVar("module_hud_arrested", "bool")
var:SetNameTranslateKey("s_arrestedhud_name")
var:SetValue(ehud.modules["ArrestHUD"])
var:CanChange("usergroup",modules_access)


local var = tab:AddVar("module_hud_doors", "bool")
var:SetNameTranslateKey("s_doorshud_name")
var:SetValue(ehud.modules["DoorsHUD"])
var:CanChange("usergroup",modules_access)


local var = tab:AddVar("module_fpp", "bool")
var:SetNameTranslateKey("s_fpp_name")
var:SetDescTranslateKey("s_fpp_desc")
var:SetValue(ehud.modules["FPPHUD"])
var:CustomCheck(function(self,addon)
return (DarkRP ~= nil) and (modules_access[LocalPlayer():GetUserGroup()] or esclib:HasAdminAccess(LocalPlayer()))
end)


local var = tab:AddVar("module_ply_over", "bool")
var:SetNameTranslateKey("s_plyover_name")
var:SetValue(ehud.modules["PlayerOverheadHUD"])
var:CanChange("usergroup",modules_access)


local var = tab:AddVar("module_agenda", "bool")
var:SetNameTranslateKey("s_agenda_name")
var:SetValue(ehud.modules["AgendaHUD"])
var:CanChange("usergroup",modules_access)


--you can use checks for this
if ehud.config.hitmarkers then
local var = tab:AddVar("module_hitmarker", "bool")
var:SetNameTranslateKey("s_hitmark_name")
var:SetDescTranslateKey("s_hitmark_desc")
var:SetValue(ehud.modules["HitmarkHUD"])
var:CanChange("usergroup",modules_access)
end


local var = tab:AddVar("module_voice", "bool")
var:SetNameTranslateKey("s_voice_name")
var:SetValue(ehud.modules["VoiceHUD"])
var:CanChange("usergroup",modules_access)


local var = tab:AddVar("module_lockdown", "bool")
var:SetNameTranslateKey("s_lockdown_name")
var:SetValue(ehud.modules["LockdownHUD"])
var:CanChange("usergroup",modules_access)


local var = tab:AddVar("module_deathscreen", "bool")
var:SetNameTranslateKey("s_deathscreen_name")
var:SetValue(ehud.modules["DeathscreenHUD"])
var:CanChange("usergroup",modules_access)


local var = tab:AddVar("module_notify", "bool")
var:SetNameTranslateKey("s_notify_name")
var:SetValue(ehud.modules["NotifyHUD"])
var:CanChange("usergroup",modules_access)


local var = tab:AddVar("module_crashscreen", "bool")
var:SetNameTranslateKey("s_crash_name")
var:SetDescTranslateKey("s_crash_desc")
var:SetValue(ehud.modules["CrashscreenHUD"])
var:CanChange("usergroup",modules_access)


local var = tab:AddVar("module_vehicle_hud", "bool")
var:SetNameTranslateKey("s_vehicle_name")
var:SetValue(ehud.modules["VehicleHUD"])
var:CanChange("usergroup",modules_access)


Can't find what you're looking for?

Contact support