Skip to content

Commit

Permalink
Merge pull request #85 from RGLgg/config-checker
Browse files Browse the repository at this point in the history
  • Loading branch information
l-Aad-l committed Mar 12, 2024
2 parents 4b1fa37 + 2afacde commit d535dc0
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jobs:

- name: Compile RGL Suite Plugins against SM ${{ steps.setup-sp.outputs.version }}
run: |
for plugin in "rglqol" "rglupdater" "tf2Halftime" "improved_match_timer" "disabled/roundtimer_override"
for plugin in "rglqol" "rglupdater" "config_checker" "tf2Halftime" "improved_match_timer" "disabled/roundtimer_override"
do
echo -e "\nCompiling $plugin.sp..."
spcomp -E -w234 -O2 -v2 -i $SCRIPTS_PATH/include $plugin.sp
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:

- name: Compile RGL Suite Plugins against SM ${{ steps.setup-sp.outputs.version }}
run: |
for plugin in "rglqol" "rglupdater" "improved_match_timer" "disabled/roundtimer_override"
for plugin in "rglqol" "rglupdater" "config_checker" "improved_match_timer" "disabled/roundtimer_override"
do
echo -e "\nCompiling $plugin.sp..."
spcomp -E -w234 -O2 -v2 -i $SCRIPTS_PATH/include $plugin.sp
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:

- name: Compile RGL Suite Plugins against SM ${{ steps.setup-sp.outputs.version }}
run: |
for plugin in "rglqol" "rglupdater" "tf2Halftime" "improved_match_timer" "disabled/roundtimer_override"
for plugin in "rglqol" "rglupdater" "config_checker" "tf2Halftime" "improved_match_timer" "disabled/roundtimer_override"
do
echo -e "\nCompiling $plugin.sp..."
spcomp -E -w234 -O2 -v2 -i $SCRIPTS_PATH/include $plugin.sp
Expand Down
72 changes: 72 additions & 0 deletions addons/sourcemod/scripting/config_checker.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#pragma newdecls required
#pragma semicolon 1

#include <sourcemod>

#define PLUGIN_NAME "Config Checker"
#define PLUGIN_VERSION "1.0.0"
char cfgVal[128];

public Plugin myinfo =
{
name = PLUGIN_NAME,
author = "Aad",
description = "Prints executed config file to client and chat",
version = PLUGIN_VERSION,
url = "https://github.com/RGLgg/server-resources-updater"
}

public void OnPluginStart()
{
LogMessage("[CC] version %s has been loaded.", PLUGIN_VERSION);
PrintToChatAll("[CC] version %s has been loaded.", PLUGIN_VERSION);
RegConsoleCmd("cc", Config_Info, "!cc - Prints Config name to client");
GetConVarString(FindConVar("servercfgfile"), cfgVal, sizeof(cfgVal));
HookConVarChange(FindConVar("servercfgfile"), OnServerCfgChanged);
HookEvent("teamplay_round_start", EventRoundStart);
}

public Action Config_Info(int client, int args)
{
ReplyToCommand(client, "[CC] This server is running config: %s", cfgVal);
return Plugin_Handled;
}

public Action EventRoundStart(Handle event, const char[] name, bool dontBroadcast)
{
PrintToAll();
return Plugin_Continue;
}

public void OnServerCfgChanged(ConVar convar, char[] oldValue, char[] newValue)
{
PrintToAll();
}

public void OnClientPostAdminCheck(int client)
{
GetConVarString(FindConVar("servercfgfile"), cfgVal, sizeof(cfgVal));
CreateTimer(15.0, prWelcomeClient, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
}

public Action prWelcomeClient(Handle timer, int userid)
{
int client = GetClientOfUserId(userid);
if (client)
{
PrintToChat(client, "[CC] This server is running config: %s", cfgVal);
}

return Plugin_Continue;
}

public void PrintToAll() {
GetConVarString(FindConVar("servercfgfile"), cfgVal, sizeof(cfgVal));
PrintToChatAll("[CC] This server is running config: %s", cfgVal);
}

public void OnPluginEnd()
{
LogMessage("[CC] version %s has been unloaded.", PLUGIN_VERSION);
PrintToChatAll("[CC] version %s has been unloaded.", PLUGIN_VERSION);
}

0 comments on commit d535dc0

Please sign in to comment.