AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   General (https://forums.alliedmods.net/forumdisplay.php?f=58)
-   -   How unload all plugins from folder? (https://forums.alliedmods.net/showthread.php?t=315923)

die_man 05-01-2019 15:26

How unload all plugins from folder?
 
Hi,
I want unload all plugin from plugins/mg folder, how I can do this?
Is there any command that does everything at once instead of having to unload one by one?
Code:

sm plugins unload mg/plugin1.smx
sm plugins unload mg/plugin2.smx


ozrich 05-01-2019 23:57

Re: How unload all plugins from folder?
 
Try sm plugins unload_all

https://github.com/alliedmodders/sou.../PluginSys.cpp line 1863

ddhoward 05-02-2019 00:44

Re: How unload all plugins from folder?
 
Quote:

Originally Posted by ozrich (Post 2649735)
Try sm plugins unload_all

https://github.com/alliedmodders/sou.../PluginSys.cpp line 1863

That would unload all plugins, which is not what he wants to do.

8guawong 05-02-2019 08:13

Re: How unload all plugins from folder?
 
https://github.com/nosoop/SM-PluginMangler

die_man 05-02-2019 10:38

Re: How unload all plugins from folder?
 
Quote:

Originally Posted by 8guawong (Post 2649785)

Sorry, but what is the command i need to use with this plugin to disable all plugins in "plugins/mg" folder?
I'll use mapconfigs to unload the plugins based in map prefix.

TheBOSS 05-02-2019 11:32

Re: How unload all plugins from folder?
 
Quote:

#include <sourcemod>

enum enumMods {
String:Folder[32],
String:Cmd[16]
}

int g_Mods[32][enumMods];
int g_numbMods;

public void OnMapStart() {
ReadConfig();
}

public void OnPluginStart() {
RegAdminCmd("sm_mods", Command_Mods, ADMFLAG_CONFIG);
}

public void ReadConfig() {
KeyValues kv = new KeyValues("root");
kv.ImportFromFile("addons/sourcemod/configs/multimods.cfg");

if(!FileExists("addons/sourcemod/configs/multimods.cfg")) {
LogError("File addons/sourcemod/configs/multimods.cfg do not exist");

delete kv;
return;
}

if (!kv.GotoFirstSubKey()) {
LogError("Config addons/sourcemod/configs/multimods.cfg not exist");

delete kv;
return;
}

do {
g_numbMods++;

kv.GetSectionName(g_Mods[g_numbMods][Cmd], 32);
kv.GetString("folder", g_Mods[g_numbMods][Folder], 32);

} while (kv.GotoNextKey());

delete kv;
}

public Action Command_Mods(int client, int args) {

if(args < 2) {
return Plugin_Handled;
}

char szArg[32];
GetCmdArg(1, szArg, sizeof(szArg));

int mod = getMods(szArg);

if(mod == 0) {
ReplyToCommand(client, "[SM] This mod not exist");
return Plugin_Handled;
}

char szEnablePath[256], szDisablePath[256];
Format(szEnablePath, 256, "addons/sourcemod/plugins/%s", g_Mods[mod][Folder]);
Format(szDisablePath, 256, "addons/sourcemod/plugins/disabled/%s", g_Mods[mod][Folder]);

GetCmdArg(2, szArg, sizeof(szArg));

if(StrEqual(szArg, "enable", false)) {
if(ChangeStatus(szDisablePath, szEnablePath)) {
ReplyToCommand(client, "[SM] Enable mod %s", g_Mods[mod][Cmd]);
} else {
ReplyToCommand(client, "[SM] %s can't be enable", g_Mods[mod][Cmd]);
}

return Plugin_Handled;
}
if(StrEqual(szArg, "disable", false)) {
if(ChangeStatus(szEnablePath, szDisablePath)) {
ReplyToCommand(client, "[SM] Disable mod %s", g_Mods[mod][Cmd]);
} else {
ReplyToCommand(client, "[SM] %s can't be disable", g_Mods[mod][Cmd]);
}

return Plugin_Handled;
}

return Plugin_Handled;
}

public int getMods(char[] cmd) {
int mod;

for (int i = 1; i <= g_numbMods; i++) {
if(StrEqual(g_Mods[i][Cmd], cmd, false)) {
mod = i;
break;
}
}
return mod;
}


public bool ChangeStatus(char[] oldpath, char[] newpath) {
if(!DirExists(oldpath)) {
LogError("[SM] Directory %s not exist", oldpath);
return false;
}

DirectoryListing Directory = OpenDirectory(oldpath);
char szFile[32], szOldPath[256], szNewPath[256];
bool change;
FileType type = FileType_File | FileType_Directory;

while(ReadDirEntry(Directory, szFile, 32, type)) {
if(szFile[0] != '.') {
Format(szOldPath, 256, "%s/%s", oldpath, szFile);
Format(szNewPath, 256, "%s/%s", newpath, szFile);

RenameFile(newpath, oldpath);

change = true;
}
}
Directory.Close();

if(change) {
RemoveDir(oldpath);
}

return change;
}
config/multimod.cfg
Quote:

"Multimods"
{
"name1"
{
"folder" "thefolder"
}
"name2"
{
"folder" "anotherfolder"
}
}
This plugin is created by Verygames community
For use the command "sm_mods <name> <enable|disable>" the admin need "config" flag (ADMFLAG_CONFIG)

Follow this exemple for use multimods
.You don't need use "addons/sourcemod/plugins" on "folder" config, the plugin already get it

In this exemple, for enable or disable "name1" and "name2", just type it on the chat:
. !mods name1 enable OR !mods name1 disable
. !mods name2 enable OR !mods name2 disable
->change map is require after that

8guawong 05-02-2019 12:01

Re: How unload all plugins from folder?
 
Quote:

Originally Posted by die_man (Post 2649815)
Sorry, but what is the command i need to use with this plugin to disable all plugins in "plugins/mg" folder?
I'll use mapconfigs to unload the plugins based in map prefix.

plugins unload /mg/

try that

die_man 05-02-2019 15:56

Re: How unload all plugins from folder?
 
Quote:

Originally Posted by 8guawong (Post 2649830)
plugins unload /mg/

try that

It worked, thank you!


All times are GMT -4. The time now is 07:22.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.