diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bd379a..ec9ce17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Version 6.0 (June 18, 2018) + +1. Bug fixes: + +- Fixed the nff_enabledgamemodes and nff_disabledgamemodes convars not working properly. + ## Version 5.5 (June 16, 2018) 1. Bug fixes: diff --git a/addons/sourcemod/plugins/no_friendly-fire.smx b/addons/sourcemod/plugins/no_friendly-fire.smx index f10cf12..fa0b3ea 100644 Binary files a/addons/sourcemod/plugins/no_friendly-fire.smx and b/addons/sourcemod/plugins/no_friendly-fire.smx differ diff --git a/addons/sourcemod/scripting/no_friendly-fire.sp b/addons/sourcemod/scripting/no_friendly-fire.sp index f00ca7c..26a7ab0 100644 --- a/addons/sourcemod/scripting/no_friendly-fire.sp +++ b/addons/sourcemod/scripting/no_friendly-fire.sp @@ -3,7 +3,7 @@ #include #pragma semicolon 1 #pragma newdecls required -#define NFF_VERSION "5.5" +#define NFF_VERSION "6.0" public Plugin myinfo = { @@ -15,9 +15,20 @@ public Plugin myinfo = }; char g_sGameName[32]; +ConVar g_cvNFFAdvanced; +ConVar g_cvNFFBurnAdvanced; +ConVar g_cvNFFBurnEasy; +ConVar g_cvNFFBurnExpert; +ConVar g_cvNFFBurnNormal; ConVar g_cvNFFDisabledGameModes; ConVar g_cvNFFEnabledGameModes; ConVar g_cvNFFEnable; +ConVar g_cvNFFEasy; +ConVar g_cvNFFExpert; +ConVar g_cvNFFGameMode; +ConVar g_cvNFFGLScale; +ConVar g_cvNFFGLScaleSelf; +ConVar g_cvNFFNormal; public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) { @@ -31,9 +42,20 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max public void OnPluginStart() { + g_cvNFFAdvanced = FindConVar("survivor_friendly_fire_factor_hard"); + g_cvNFFBurnAdvanced = FindConVar("survivor_burn_factor_hard"); + g_cvNFFBurnEasy = FindConVar("survivor_burn_factor_easy"); + g_cvNFFBurnExpert = FindConVar("survivor_burn_factor_expert"); + g_cvNFFBurnNormal = FindConVar("survivor_burn_factor_normal"); g_cvNFFDisabledGameModes = CreateConVar("nff_disabledgamemodes", "", "Disable the plugin in these game modes.\nGame mode limit: 64\nCharacter limit for each game mode: 32\n(Empty: None)\n(Not empty: Disabled in these game modes.)"); g_cvNFFEnabledGameModes = CreateConVar("nff_enabledgamemodes", "", "Enable the plugin in these game modes.\nGame mode limit: 64\nCharacter limit for each game mode: 32\n(Empty: None)\n(Not empty: Enabled in these game modes.)"); g_cvNFFEnable = CreateConVar("nff_enable", "1", "Enable the plugin?\n(0: OFF)\n(1: ON)"); + g_cvNFFEasy = FindConVar("survivor_friendly_fire_factor_easy"); + g_cvNFFExpert = FindConVar("survivor_friendly_fire_factor_expert"); + g_cvNFFGameMode = FindConVar("mp_gamemode"); + g_cvNFFGLScale = FindConVar("grenadelauncher_ff_scale"); + g_cvNFFGLScaleSelf = FindConVar("grenadelauncher_ff_scale_self"); + g_cvNFFNormal = FindConVar("survivor_friendly_fire_factor_normal"); CreateConVar("nff_pluginversion", NFF_VERSION, "No Friendly Fire version", FCVAR_NOTIFY|FCVAR_DONTRECORD); g_cvNFFDisabledGameModes.AddChangeHook(vNFFCvarChanges); g_cvNFFEnabledGameModes.AddChangeHook(vNFFCvarChanges); @@ -51,34 +73,34 @@ void vChangeCvars() { if (g_cvNFFEnable.BoolValue && bIsSystemValid()) { - FindConVar("survivor_friendly_fire_factor_easy").SetString("0"); - FindConVar("survivor_friendly_fire_factor_normal").SetString("0"); - FindConVar("survivor_friendly_fire_factor_hard").SetString("0"); - FindConVar("survivor_friendly_fire_factor_expert").SetString("0"); - FindConVar("survivor_burn_factor_easy").SetString("0"); - FindConVar("survivor_burn_factor_normal").SetString("0"); - FindConVar("survivor_burn_factor_hard").SetString("0"); - FindConVar("survivor_burn_factor_expert").SetString("0"); + g_cvNFFEasy.SetString("0"); + g_cvNFFNormal.SetString("0"); + g_cvNFFAdvanced.SetString("0"); + g_cvNFFExpert.SetString("0"); + g_cvNFFBurnEasy.SetString("0"); + g_cvNFFBurnNormal.SetString("0"); + g_cvNFFBurnAdvanced.SetString("0"); + g_cvNFFBurnExpert.SetString("0"); if (bIsL4D2Game()) { - FindConVar("grenadelauncher_ff_scale").SetString("0"); - FindConVar("grenadelauncher_ff_scale_self").SetString("0"); + g_cvNFFGLScale.SetString("0"); + g_cvNFFGLScaleSelf.SetString("0"); } } else if (!g_cvNFFEnable.BoolValue || !bIsSystemValid()) { - FindConVar("survivor_friendly_fire_factor_easy").SetString("0"); - FindConVar("survivor_friendly_fire_factor_normal").SetString("0.1"); - FindConVar("survivor_friendly_fire_factor_hard").SetString("0.3"); - FindConVar("survivor_friendly_fire_factor_expert").SetString("0.5"); - FindConVar("survivor_burn_factor_easy").SetString("0.2"); - FindConVar("survivor_burn_factor_normal").SetString("0.2"); - FindConVar("survivor_burn_factor_hard").SetString("0.4"); - FindConVar("survivor_burn_factor_expert").SetString("1"); + g_cvNFFEasy.SetString("0"); + g_cvNFFNormal.SetString("0.1"); + g_cvNFFAdvanced.SetString("0.3"); + g_cvNFFExpert.SetString("0.5"); + g_cvNFFBurnEasy.SetString("0.2"); + g_cvNFFBurnNormal.SetString("0.2"); + g_cvNFFBurnAdvanced.SetString("0.4"); + g_cvNFFBurnExpert.SetString("1"); if (bIsL4D2Game()) { - FindConVar("grenadelauncher_ff_scale").SetString("0.12"); - FindConVar("grenadelauncher_ff_scale_self").SetString("0.12"); + g_cvNFFGLScale.SetString("0.12"); + g_cvNFFGLScaleSelf.SetString("0.12"); } } } @@ -92,26 +114,26 @@ stock bool bIsL4D2Game() stock bool bIsSystemValid() { char sGameMode[32]; - char sConVarModes[2049]; - char sModeName[64][32]; - FindConVar("mp_gamemode").GetString(sGameMode, sizeof(sGameMode)); + char sConVarModes[32]; + g_cvNFFGameMode.GetString(sGameMode, sizeof(sGameMode)); + Format(sGameMode, sizeof(sGameMode), ",%s,", sGameMode); g_cvNFFEnabledGameModes.GetString(sConVarModes, sizeof(sConVarModes)); - ExplodeString(sConVarModes, ",", sModeName, sizeof(sModeName), sizeof(sModeName[])); - for (int iMode = 0; iMode < sizeof(sModeName); iMode++) + if (strcmp(sConVarModes, "")) { - if (StrContains(sGameMode, sModeName[iMode], false) != -1 && sModeName[iMode][0] != '\0') + Format(sConVarModes, sizeof(sConVarModes), ",%s,", sConVarModes); + if (StrContains(sConVarModes, sGameMode, false) == -1) { - return true; + return false; } } g_cvNFFDisabledGameModes.GetString(sConVarModes, sizeof(sConVarModes)); - ExplodeString(sConVarModes, ",", sModeName, sizeof(sModeName), sizeof(sModeName[])); - for (int iMode = 0; iMode < sizeof(sModeName); iMode++) + if (strcmp(sConVarModes, "")) { - if (StrContains(sGameMode, sModeName[iMode], false) == -1 && sModeName[iMode][0] != '\0') + Format(sConVarModes, sizeof(sConVarModes), ",%s,", sConVarModes); + if (StrContains(sConVarModes, sGameMode, false) != -1) { - return true; + return false; } } - return false; + return true; } \ No newline at end of file