|
@@ -0,0 +1,64 @@
|
|
|
+/**
|
|
|
+ * Sourcemod 1.7 Plugin Template
|
|
|
+ */
|
|
|
+#pragma semicolon 1
|
|
|
+#include <sourcemod>
|
|
|
+
|
|
|
+#pragma newdecls required
|
|
|
+
|
|
|
+#define PLUGIN_VERSION "0.0.1"
|
|
|
+public Plugin myinfo = {
|
|
|
+ name = "[ANY] Plugin Configs",
|
|
|
+ author = "nosoop",
|
|
|
+ description = "For those of us that are too lazy to recompile plugins with AutoExecConfig.",
|
|
|
+ version = PLUGIN_VERSION,
|
|
|
+ url = "https://github.com/nosoop/"
|
|
|
+}
|
|
|
+
|
|
|
+#define CONFIG_DIRECTORY "cfg/sourcemod/pluginconfigs"
|
|
|
+
|
|
|
+ArrayList g_PluginNames;
|
|
|
+
|
|
|
+public void OnPluginStart() {
|
|
|
+ g_PluginNames = new ArrayList(PLATFORM_MAX_PATH);
|
|
|
+
|
|
|
+ ReloadPluginConfigList();
|
|
|
+}
|
|
|
+
|
|
|
+public void OnAutoConfigsBuffered() {
|
|
|
+ char fileName[PLATFORM_MAX_PATH];
|
|
|
+ for (int i = 0; i < g_PluginNames.Length; i++) {
|
|
|
+ g_PluginNames.GetString(i, fileName, sizeof(fileName));
|
|
|
+ Handle plugin = FindPluginByFile(fileName);
|
|
|
+
|
|
|
+ if (plugin != INVALID_HANDLE && GetPluginStatus(plugin) == Plugin_Running) {
|
|
|
+ char filePath[PLATFORM_MAX_PATH];
|
|
|
+ strcopy(filePath, sizeof(filePath), CONFIG_DIRECTORY);
|
|
|
+ StrCat(filePath, sizeof(filePath), fileName);
|
|
|
+ // ExecuteConfig() ...
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void ReloadPluginConfigList() {
|
|
|
+ g_PluginNames.Clear();
|
|
|
+
|
|
|
+ if (!DirExists(CONFIG_DIRECTORY, false)) {
|
|
|
+ CreateDirectory(CONFIG_DIRECTORY,
|
|
|
+ FPERM_U_READ + FPERM_U_WRITE + FPERM_U_EXEC + FPERM_G_READ + FPERM_G_EXEC +
|
|
|
+ FPERM_O_READ + FPERM_O_EXEC);
|
|
|
+ }
|
|
|
+ DirectoryListing configDirectory = OpenDirectory("cfg/sourcemod/pluginconfigs", false);
|
|
|
+
|
|
|
+ char buffer[PLATFORM_MAX_PATH];
|
|
|
+ FileType fileType;
|
|
|
+ while (configDirectory.GetNext(buffer, sizeof(buffer), fileType)) {
|
|
|
+ if (fileType == FileType_File) {
|
|
|
+ g_PluginNames.PushString(buffer);
|
|
|
+
|
|
|
+ // TODO make sure this is basename
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ delete configDirectory;
|
|
|
+}
|