Raised This Month: $12 Target: $400
 3% 

Loading all plugins in optional folder


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
heavyisgps
Member
Join Date: Aug 2018
Old 10-09-2021 , 10:57   Loading all plugins in optional folder
Reply With Quote #1

Is there a way to load a whole folder from the optional folder?

plugins/optional/pluginpack

where pluginpack contains a changing number of plugins, I know you can do "sm plugins load optional/plugin.smx", but is there a syntax to load all in a specific folder in the optional folder?
__________________
Creator of the Hi GPS Balance mod for TF2.

www.higps.no

Last edited by heavyisgps; 10-09-2021 at 10:57.
heavyisgps is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-09-2021 , 11:14   Re: Loading all plugins in optional folder
Reply With Quote #2

I tested with sub folders, ...plugins/test/abc and moved all SM plugin into last folder.
All plugins are loaded when server start.
Code:
sm plugins list
[SM] Listing 20 plugins:
  01 "Admin File Reader" (1.10.0.6510) by AlliedModders LLC
  02 "Admin Help" (1.10.0.6510) by AlliedModders LLC
  03 "Admin Menu" (1.10.0.6510) by AlliedModders LLC
  04 "Anti-Flood" (1.10.0.6510) by AlliedModders LLC
  05 "Basic Ban Commands" (1.10.0.6510) by AlliedModders LLC
  06 "Basic Chat" (1.10.0.6510) by AlliedModders LLC
  07 "Basic Comm Control" (1.10.0.6510) by AlliedModders LLC
  08 "Basic Commands" (1.10.0.6510) by AlliedModders LLC
  09 "Basic Info Triggers" (1.10.0.6510) by AlliedModders LLC
  10 "Basic Votes" (1.10.0.6510) by AlliedModders LLC
  11 "test\abc\boon.smx"
  12 "Client Preferences" (1.10.0.6510) by AlliedModders LLC
  13 "Delay or disable server hibernate" (13.3.2021) by Bacardi
  14 "Fun Commands" (1.10.0.6510) by AlliedModders LLC
  15 "Fun Votes" (1.10.0.6510) by AlliedModders LLC
  16 "test\abc\kickplayers.smx"
  17 "Player Commands" (1.10.0.6510) by AlliedModders LLC
  18 "Reserved Slots" (1.10.0.6510) by AlliedModders LLC
  19 "Sound Commands" (1.10.0.6510) by AlliedModders LLC
  20 "test\abc\test.smx"
Plugins in the ...plugins/disabled/ folder would not load automatically, you can manually load plugins however.


...to load all plugins "sm plugins refresh"
but there is no way to load from specific folder.
Code:
sm plugins
SourceMod Plugins Menu:
    info             - Information about a plugin
    list             - Show loaded plugins
    load             - Load a plugin
    load_lock        - Prevents any more plugins from being loaded
    load_unlock      - Re-enables plugin loading
    refresh          - Reloads/refreshes all plugins in the plugins folder
    reload           - Reloads a plugin
    unload           - Unload a plugin
    unload_all       - Unloads all plugins

*edit
But you can do this with custom plugin :/


*edit
Here some kind plugin.

Give folder name or path/name:
sm_plugins_load
sm_plugins_unload
sm_plugins_reload

example sm_plugins_load disabled
PHP Code:

public void OnPluginStart()
{
    
RegConsoleCmd("sm_plugins_load"test);
    
RegConsoleCmd("sm_plugins_unload"test);
    
RegConsoleCmd("sm_plugins_reload"test);
}

public 
Action test(int clientint args)
{
    
char command[] = "sm plugins reload string";
    
GetCmdArg(0commandsizeof(command));

    if(
args 1)
    {
        
ReplyToCommand(client"Usage: %s <folder>\nload, unload or reload plugins from folder"command);
        return 
Plugin_Handled;
    }

    
char folder[PLATFORM_MAX_PATH];

    if(
GetCmdArg(1foldersizeof(folder)) < 1
    
|| (!IsCharNumeric(folder[0]) && !IsCharAlpha(folder[0])))
    {
        
ReplyToCommand(client" - Give a folder name.");
        return 
Plugin_Handled;
    }

    
BuildPath(Path_SMfoldersizeof(folder), "plugins/%s"folder);

    if(!
DirExists(folder))
    {
        
ReplyToCommand(client" - This folder '%s' not exist"folder);
        return 
Plugin_Handled;
    }

    
DirectoryListing dir;
    
dir OpenDirectory(folder);

    if(
dir == nullSetFailState("Error - couldn't open directory %s"folder);


    if(
StrEqual(command"sm_plugins_load"false))
        
Format(commandsizeof(command), "sm plugins load");
    else if(
StrEqual(command"sm_plugins_unload"false))
        
Format(commandsizeof(command), "sm plugins unload");
    else if(
StrEqual(command"sm_plugins_reload"false))
        
Format(commandsizeof(command), "sm plugins reload");



    
char plugin[MAX_NAME_LENGTH];
    
FileType type;
    
int dot;

    while(
dir.GetNext(pluginsizeof(plugin), type))
    {
        if(
type == FileType_File
        
&& (dot FindCharInString(plugin'.'true)) != -1
        
&& StrEqual(plugin[dot], ".smx"true))
        {
            
ServerCommand("%s %s/%s"commandfolder[25], plugin);
        }

    }
    
delete dir;
    return 
Plugin_Handled;

__________________
Do not Private Message @me

Last edited by Bacardi; 10-09-2021 at 13:35. Reason: delete
Bacardi 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 11:05.


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