From b85ba745fe72b0e9bdff5dc3a9151c05638e2b2b Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Wed, 27 Nov 2024 21:12:03 +0300 Subject: [PATCH] New ConVar: `redm_hide_hostages` (#134) * New ConVar: `redm_hide_hostages` * Add ConVar to `*.json` config --- .../configs/redm/gamemode_deathmatch.json | 3 ++ .../scripting/ReDeathmatch/ReDM_features.inc | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/cstrike/addons/amxmodx/configs/redm/gamemode_deathmatch.json b/cstrike/addons/amxmodx/configs/redm/gamemode_deathmatch.json index b6d2e33..03cc1ca 100644 --- a/cstrike/addons/amxmodx/configs/redm/gamemode_deathmatch.json +++ b/cstrike/addons/amxmodx/configs/redm/gamemode_deathmatch.json @@ -127,6 +127,9 @@ In seconds. */ "redm_changeteam_freq": "2.0", + // Hide hostages. + "redm_hide_hostages": 1, + /* Number of times a team can have players respawn before they stop being able to respawn. diff --git a/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_features.inc b/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_features.inc index 9aef7ec..72de84f 100644 --- a/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_features.inc +++ b/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_features.inc @@ -22,6 +22,7 @@ static redm_protection_color_ct[32] static bool: mp_respawn_immunity_effects static bool: redm_changeteam_unlimited static Float: redm_changeteam_freq +static bool: redm_hide_hostages Features_Precache() { AimBarriers_Precache() @@ -49,6 +50,7 @@ Features_Init() { RegisterHookChain(RG_ShowVGUIMenu, "ShowVGUIMenu_Pre", .post = false) RegisterHookChain(RG_HandleMenu_ChooseTeam, "HandleMenu_ChooseTeam_Pre", .post = false) RegisterHookChain(RG_HandleMenu_ChooseTeam, "HandleMenu_ChooseTeam", .post = true) + RegisterHookChain(RG_CSGameRules_RestartRound, "CSGameRules_RestartRound_Post", .post = true) AimBarriers_Init() Tickets_Init() @@ -190,6 +192,17 @@ Features_Init() { ), redm_changeteam_freq ) + bind_pcvar_num( + create_cvar( + "redm_hide_hostages", + "1", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 1.0, + .flags = _FCVAR_BOOLEAN, + .description = "Hide hostages." + ), + redm_hide_hostages + ) } public MsgHook_HudTextArgs() { @@ -538,3 +551,21 @@ stock WeaponIdType: GetCurrentWeapon(const player) { return WeaponIdType: get_member(activeItem, m_iId) } + +public CSGameRules_RestartRound_Post() { + if (!IsActive()) + return + + if (redm_hide_hostages) + HideHostages() +} + +HideHostages() { + new entity = NULLENT + while ((entity = fm_find_ent_by_class(entity, "hostage_entity"))) { + new Float: origin[3] + get_entvar(entity, var_origin, origin) + xs_vec_add(origin, Float: {0.0, 0.0, -8192.0}, origin) + set_entvar(entity, var_origin, origin) + } +}