Skip to content

Commit 74b09e5

Browse files
committed
Fix #739 - l4d2_weapon_attributes
When using the changematch path (!chmatch) configs would consider modified weapon info as "vanilla", simply caused by the fact that it wouldn't finish resetting the weapon attributes before dependencies were unloaded.
1 parent 7de9919 commit 74b09e5

2 files changed

Lines changed: 32 additions & 16 deletions

File tree

160 Bytes
Binary file not shown.

addons/sourcemod/scripting/l4d2_weapon_attributes.sp

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public Plugin myinfo =
214214
{
215215
name = "L4D2 Weapon Attributes",
216216
author = "Jahze, A1m`, Forgetest",
217-
version = "3.0.1",
217+
version = "3.1.0",
218218
description = "Allowing tweaking of the attributes of all weapons"
219219
};
220220

@@ -272,11 +272,21 @@ public void OnConfigsExecuted()
272272
// Weapon info may get reloaded, and supported melees
273273
// are different between campaigns.
274274
// Here we are reloading all the attributes set by our own.
275-
276275
ResetWeaponAttributes(false);
277276
ResetMeleeAttributes(false);
278277
}
279278

279+
/*
280+
Fired by confoglcompmod before confogl_off.cfg runs and before any plugin
281+
(including left4dhooks, whose natives we need for the reset) gets unloaded.
282+
Without this, on !chmatch the engine-side weapon info keeps the previous
283+
matchmode's values
284+
*/
285+
public void LGO_OnMatchModeUnloaded()
286+
{
287+
ResetAllAttributes(false);
288+
}
289+
280290
void OnTankDamageEnableAttriChanged(bool newValue)
281291
{
282292
if (bTankDamageEnableAttri != newValue) {
@@ -506,38 +516,44 @@ Action Cmd_WeaponAttributes(int client, int args)
506516
}
507517

508518
Action Cmd_WeaponAttributesReset(int args)
519+
{
520+
ResetAllAttributes(true);
521+
return Plugin_Handled;
522+
}
523+
524+
void ResetAllAttributes(bool bVerbose)
509525
{
510526
OnTankDamageEnableAttriChanged(false);
511-
527+
512528
bool IsReset = (hTankDamageAttri.Size > 0);
513529
hTankDamageAttri.Clear();
514-
515-
if (IsReset) {
530+
531+
if (bVerbose && IsReset) {
516532
PrintToServer("Tank Damage Multiplier (tankdamagemult) attribute reset for all weapons!");
517533
}
518-
534+
535+
OnReloadDurationEnableAttriChanged(false);
536+
519537
IsReset = (hReloadDurationAttri.Size > 0);
520538
hReloadDurationAttri.Clear();
521-
522-
if (IsReset) {
539+
540+
if (bVerbose && IsReset) {
523541
PrintToServer("Reload Duration Multiplier (reloaddurationmult) attribute reset for all shotguns!");
524542
}
525-
543+
526544
int iWeaponAttrCount = ResetWeaponAttributes(true);
527-
if (iWeaponAttrCount == 0) {
545+
if (bVerbose && iWeaponAttrCount == 0) {
528546
PrintToServer("Weapon attributes were not reset, because no weapon attributes were saved!");
529547
}
530-
548+
531549
int iMeleeAttrCount = ResetMeleeAttributes(true);
532-
if (iMeleeAttrCount == 0) {
550+
if (bVerbose && iMeleeAttrCount == 0) {
533551
PrintToServer("Melee attributes were not reset, because no melee attributes were saved!");
534552
}
535-
536-
if (iWeaponAttrCount || iMeleeAttrCount) {
553+
554+
if (bVerbose && (iWeaponAttrCount || iMeleeAttrCount)) {
537555
PrintToServer("The weapon attributes for all saved weapons have been reset successfully. Number of reset weapon attributes: %d!", iWeaponAttrCount + iMeleeAttrCount);
538556
}
539-
540-
return Plugin_Handled;
541557
}
542558

543559
/*

0 commit comments

Comments
 (0)