Skip to content
Permalink
Browse files

Unload/Remove old plugins

This remove automatically old/obsolete plugins like CustomPlayerSkins.
  • Loading branch information...
Bara committed Mar 14, 2019
1 parent d54baf3 commit 2edc2149c25aa249183ffb722a714f73c55f078a
@@ -146,6 +146,8 @@ void SetupConfig()
g_cStartMelee = AutoExecConfig_CreateConVar("ttt_start_melee_weapon", "fists", "Spawn with which melee weapon?");
g_cAdditionalMeleeRole = AutoExecConfig_CreateConVar("ttt_additional_melee_role", "14", "Who gets the additional melee weapon? (Useful: https://github.com/Bara/TroubleinTerroristTown/wiki/CVAR-Masks )", _, true, 0.0, true, 14.0);
g_cAdditionalMeleeWeapon = AutoExecConfig_CreateConVar("ttt_additional_melee_weapon", "knife", "Which additional weapon?");
g_cUnloadPlugins = AutoExecConfig_CreateConVar("ttt_Unload_plugins", "1", "Unload old/obsolete plugins?", _, true, 0.0, true, 1.0);
g_cRemovePlugins = AutoExecConfig_CreateConVar("ttt_remove_plugins", "1", "Remove old/obsolete plugins?", _, true, 0.0, true, 1.0);

g_cpluginTag.AddChangeHook(OnConVarChanged);
g_ckickImmunity.AddChangeHook(OnConVarChanged);
@@ -305,6 +305,8 @@ ConVar g_cDisableRounds = null;
ConVar g_cStartMelee = null;
ConVar g_cAdditionalMeleeRole = null;
ConVar g_cAdditionalMeleeWeapon = null;
ConVar g_cUnloadPlugins = null;
ConVar g_cRemovePlugins = null;

Handle g_hRules = null;
bool g_bRules[MAXPLAYERS + 1] = { false, ... };
@@ -221,6 +221,7 @@ public void OnConfigsExecuted()
}

GetLatestVersion();
CheckCPS();
}

public void TTT_OnSQLConnect(Database db)
@@ -4633,4 +4634,38 @@ public void Frame_GiveSecondary(int userid)
{
GivePlayerItem(client, g_sDefaultSecondary);
}
}
}

void CheckCPS()
{
char sPath[PLATFORM_MAX_PATH + 1];
BuildPath(Path_SM, sPath, sizeof(sPath), "plugins/CustomPlayerSkins.smx");

if (!FileExists(sPath))
{
return;
}

Handle hPlugin = FindPluginByFile("CustomPlayerSkins.smx");

if (hPlugin == null)
{
return;
}

PluginStatus pStatus = GetPluginStatus(hPlugin);

if (pStatus == Plugin_Running)
{
if (g_cUnloadPlugins.BoolValue)
{
ServerCommand("sm plugins unload CustomPlayerSkins");
LogMessage("CustomPlayerSkins unloaded, no longer required.");

if (g_cRemovePlugins.BoolValue)
{
DeleteFile(sPath);
}
}
}
}

0 comments on commit 2edc214

Please sign in to comment.
You can’t perform that action at this time.