Skip to content

Commit

Permalink
New ConVar: redm_hide_hostages (#134)
Browse files Browse the repository at this point in the history
* New ConVar: `redm_hide_hostages`

* Add ConVar to `*.json` config
  • Loading branch information
SergeyShorokhov authored Nov 27, 2024
1 parent d182522 commit b85ba74
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cstrike/addons/amxmodx/configs/redm/gamemode_deathmatch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
31 changes: 31 additions & 0 deletions cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_features.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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)
}
}

0 comments on commit b85ba74

Please sign in to comment.