Skip to content

Commit

Permalink
new CVar redm_block_drop_weapon (#44)
Browse files Browse the repository at this point in the history
* new CVar `redm_block_drop_weapon`

* Add description to `.json` config
  • Loading branch information
SergeyShorokhov authored Sep 20, 2023
1 parent 7f44a67 commit d045fb1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 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 @@ -50,6 +50,9 @@
"redm_spawn_preset": "preset",

// ReDM: Features
// Block the ability to drop the weapon.
"redm_block_drop_weapon": "1",

// Restore weapon slot on respawn.
"redm_keep_weapon_slot": "1",

Expand Down
28 changes: 21 additions & 7 deletions cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_features.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ static g_gunsEventsId
static g_oldGroupinfo[MAX_PLAYERS + 1]
static bool: g_protectionState[MAX_PLAYERS + 1]

static bool: redm_block_drop_weapon
static Float: redm_sounds_distance
static Float: redm_healer
static Float: redm_healer_hs
Expand Down Expand Up @@ -34,10 +35,19 @@ Features_Init() {

RegisterHookChain(RG_CBasePlayer_TakeDamage, "CBasePlayer_TakeDamage_Post", .post = true)
RegisterHookChain(RG_CBasePlayer_TraceAttack, "CBasePlayer_TraceAttack", .post = false)
// RegisterHookChain(RH_SV_StartSound, "SV_StartSound", .post = false)
RegisterHookChain(RG_CBasePlayer_SetSpawnProtection, "CBasePlayer_SetSpawnProtection_Post", .post = true)
RegisterHookChain(RG_CBasePlayer_RemoveSpawnProtection, "CBasePlayer_RemoveSpawnProtection", .post = true)
RegisterHookChain(RG_CBasePlayer_DropPlayerItem, "CBasePlayer_DropPlayerItem", .post = false)

bind_pcvar_num(
create_cvar(
"redm_block_drop_weapon", "1",
.has_min = true, .min_val = 0.0,
.has_max = true, .max_val = 1.0,
.description = "Block the ability to drop the weapon."
),
redm_block_drop_weapon
)
bind_pcvar_float(
create_cvar(
"redm_healer", "10.0",
Expand Down Expand Up @@ -382,6 +392,16 @@ public CBasePlayer_RemoveSpawnProtection(const player) {
fm_set_rendering(player)
}

public CBasePlayer_DropPlayerItem(const player, const itemName[]) {
if (!redm_block_drop_weapon)
return HC_CONTINUE

client_printex(player, print_center, "#Weapon_Cannot_Be_Dropped")

SetHookChainReturn(ATYPE_INTEGER, 0)
return HC_SUPERCEDE
}

stock WeaponIdType: GetCurrentWeapon(const player) {
new activeItem = get_member(player, m_pActiveItem)
if (!activeItem)
Expand All @@ -390,12 +410,6 @@ stock WeaponIdType: GetCurrentWeapon(const player) {
return WeaponIdType: get_member(activeItem, m_iId)
}

public SV_StartSound(const recipients, const entity, const channel, const sample[], const volume, Float:attenuation, const fFlags, const pitch) {
/* server_print("s:`%s`, r:%i, att:%.2f, pitch:%i",
sample, recipients, attenuation, pitch
) */
}

static stock UTIL_DeathMsg(const dest, const receiver, const killer, const victim, const headshot, const weaponName[]) {
static msg_deathMsg
if(!msg_deathMsg)
Expand Down

0 comments on commit d045fb1

Please sign in to comment.