mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-08 18:53:20 +00:00
Auto turn on/off hud on cvar change
This commit is contained in:
parent
107649bddb
commit
d05c8435f4
2 changed files with 21 additions and 0 deletions
Binary file not shown.
|
@ -120,6 +120,9 @@ public void OnPluginStart() {
|
||||||
hSaferoomDoorWaitSeconds = CreateConVar("l4d2_extraitems_doorunlock_wait", "55", "How many seconds after to unlock saferoom door. 0 to disable", FCVAR_NONE, true, 0.0);
|
hSaferoomDoorWaitSeconds = CreateConVar("l4d2_extraitems_doorunlock_wait", "55", "How many seconds after to unlock saferoom door. 0 to disable", FCVAR_NONE, true, 0.0);
|
||||||
hSaferoomDoorAutoOpen = CreateConVar("l4d2_extraitems_doorunlock_open", "0", "Controls when the door automatically opens after unlocked. Add bits together.\n0 = Never, 1 = When timer expires, 2 = When all players loaded in", FCVAR_NONE, true, 0.0);
|
hSaferoomDoorAutoOpen = CreateConVar("l4d2_extraitems_doorunlock_open", "0", "Controls when the door automatically opens after unlocked. Add bits together.\n0 = Never, 1 = When timer expires, 2 = When all players loaded in", FCVAR_NONE, true, 0.0);
|
||||||
hEPIHudState = CreateConVar("l4d2_extraitems_hudstate", "1", "Controls when the hud displays.\n0 -> OFF, 1 = When 5+ players, 2 = ALWAYS", FCVAR_NONE, true, 0.0, true, 2.0);
|
hEPIHudState = CreateConVar("l4d2_extraitems_hudstate", "1", "Controls when the hud displays.\n0 -> OFF, 1 = When 5+ players, 2 = ALWAYS", FCVAR_NONE, true, 0.0, true, 2.0);
|
||||||
|
|
||||||
|
hEPIHudState.AddChangeHook(Cvar_HudStateChange);
|
||||||
|
|
||||||
if(hUpdateMinPlayers.BoolValue) {
|
if(hUpdateMinPlayers.BoolValue) {
|
||||||
hMinPlayers = FindConVar("abm_minplayers");
|
hMinPlayers = FindConVar("abm_minplayers");
|
||||||
if(hMinPlayers != null) PrintDebug(DEBUG_INFO, "Found convar abm_minplayers");
|
if(hMinPlayers != null) PrintDebug(DEBUG_INFO, "Found convar abm_minplayers");
|
||||||
|
@ -133,6 +136,7 @@ public void OnPluginStart() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int count = GetRealSurvivorsCount();
|
int count = GetRealSurvivorsCount();
|
||||||
|
abmExtraCount = count;
|
||||||
int threshold = hEPIHudState.IntValue == 1 ? 5 : 0;
|
int threshold = hEPIHudState.IntValue == 1 ? 5 : 0;
|
||||||
if(hEPIHudState.IntValue > 0 && count > threshold && updateHudTimer == null) {
|
if(hEPIHudState.IntValue > 0 && count > threshold && updateHudTimer == null) {
|
||||||
updateHudTimer = CreateTimer(EXTRA_PLAYER_HUD_UPDATE_INTERVAL, Timer_UpdateHud, _, TIMER_REPEAT);
|
updateHudTimer = CreateTimer(EXTRA_PLAYER_HUD_UPDATE_INTERVAL, Timer_UpdateHud, _, TIMER_REPEAT);
|
||||||
|
@ -160,6 +164,23 @@ public void OnPluginEnd() {
|
||||||
L4D2_RunScript("ModeHUD <- { Fields = { } }; HUDSetLayout(ModeHUD); HUDPlace( g_ModeScript.HUD_RIGHT_BOT, 0.72, 0.79, 0.25, 0.2 ); g_ModeScript");
|
L4D2_RunScript("ModeHUD <- { Fields = { } }; HUDSetLayout(ModeHUD); HUDPlace( g_ModeScript.HUD_RIGHT_BOT, 0.72, 0.79, 0.25, 0.2 ); g_ModeScript");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// CVAR HOOKS
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
public void Cvar_HudStateChange(ConVar convar, const char[] oldValue, const char[] newValue) {
|
||||||
|
if(convar.IntValue == 0 && updateHudTimer != null) {
|
||||||
|
CloseHandle(updateHudTimer);
|
||||||
|
updateHudTimer = null;
|
||||||
|
}else {
|
||||||
|
int count = GetRealSurvivorsCount();
|
||||||
|
int threshold = hEPIHudState.IntValue == 1 ? 5 : 0;
|
||||||
|
if(convar.IntValue > 0 && count > threshold && updateHudTimer == null) {
|
||||||
|
updateHudTimer = CreateTimer(EXTRA_PLAYER_HUD_UPDATE_INTERVAL, Timer_UpdateHud, _, TIMER_REPEAT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
/// COMMANDS
|
/// COMMANDS
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue