Raised This Month: $32 Target: $400
 8% 

How unload all plugins from folder?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
die_man
Senior Member
Join Date: Jul 2017
Old 05-01-2019 , 15:26   How unload all plugins from folder?
Reply With Quote #1

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
die_man is offline
ozrich
AlliedModders Donor
Join Date: Oct 2015
Old 05-01-2019 , 23:57   Re: How unload all plugins from folder?
Reply With Quote #2

Try sm plugins unload_all

https://github.com/alliedmodders/sou.../PluginSys.cpp line 1863
__________________
ozrich is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 05-02-2019 , 00:44   Re: How unload all plugins from folder?
Reply With Quote #3

Quote:
Originally Posted by ozrich View Post
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.
__________________
ddhoward is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 05-02-2019 , 08:13   Re: How unload all plugins from folder?
Reply With Quote #4

https://github.com/nosoop/SM-PluginMangler
__________________
8guawong is offline
die_man
Senior Member
Join Date: Jul 2017
Old 05-02-2019 , 10:38   Re: How unload all plugins from folder?
Reply With Quote #5

Quote:
Originally Posted by 8guawong View Post
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.
die_man is offline
TheBOSS
Member
Join Date: Nov 2018
Old 05-02-2019 , 11:32   Re: How unload all plugins from folder?
Reply With Quote #6

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

Last edited by TheBOSS; 05-02-2019 at 11:34.
TheBOSS is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 05-02-2019 , 12:01   Re: How unload all plugins from folder?
Reply With Quote #7

Quote:
Originally Posted by die_man View Post
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
__________________
8guawong is offline
die_man
Senior Member
Join Date: Jul 2017
Old 05-02-2019 , 15:56   Re: How unload all plugins from folder?
Reply With Quote #8

Quote:
Originally Posted by 8guawong View Post
plugins unload /mg/

try that
It worked, thank you!
die_man is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:23.


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