Raised This Month: $9 Target: $400
 2% 

Loading plugins from disabled-map.ini


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nG_getwreck
Senior Member
Join Date: Oct 2020
Location: Philippines from South K
Old 04-21-2021 , 15:00   Loading plugins from disabled-map.ini
Reply With Quote #1

Hello, i'm just wondering if this possible? I've seen this done in CS:BTE (CSNZ version of 1.6).

I look around in CS:BTE plugins and I found this plugin named "BTE_ChangeMode.amxx". I decompiled it and this is the result.

I don't know how he loads plugins from disabled.ini files.

PHP Code:
#pragma semicolon 1
#pragma ctrlchar '\'

new bte_mode[13][16] =
{
    
"none",
    
"td",
    
"dm",
    
"ze",
    
"zb1",
    
"zb3",
    
"zb4",
    
"ghost",
    
"zse",
    
"gd",
    
"zbexter",
    
"zg",
    
"zb2"
};

get_configsdir(String:name[], len)
{
    return 
get_localinfo("amxx_configsdir"namelen);
}

public 
plugin_init()
{
    
register_plugin("BTE Choose Mode""1.0""NN");
    
register_srvcmd("bte_change_mode""cmd_change_mode", -1"");
    return 
0;
}

public 
cmd_change_mode(id)
{
    new 
sCmd[32];
    
read_argv(1sCmd31);
    if (!
sCmd[0])
    {
        
server_print("usage: bte_change_mode < mode >");
        return 
1;
    }
    
change_mode(sCmd);
    return 
1;
}

public 
change_mode(String:mode[])
{
    new 
config_dir[64];
    new 
url_new[64];
    new 
url_new2[64];
    
get_configsdir(config_dir63);
    
format(url_new63"%s/plugins-%s.ini"config_dirmode);
    
format(url_new263"%s/disabled-%s.ini"config_dirmode);
    if (
file_exists(url_new))
    {
        
server_print("Current mode already is %s"mode);
        return 
0;
    }
    if (!
file_exists(url_new2))
    {
        
server_print("NOT exist %s"mode);
        return 
0;
    }
    new 
0;
    while (
13)
    {
        new 
url[64];
        new 
url2[64];
        
format(url63"%s/plugins-%s.ini"config_dirbte_mode[i][0][0]);
        
format(url263"%s/disabled-%s.ini"config_dirbte_mode[i][0][0]);
        if (
file_exists(url))
        {
            
rename(urlurl2);
            
i++;
        }
        
i++;
    }
    
rename(url_new2url_new);
    
client_print(0print_chat"[Server] game mode changed to %s"mode);
    return 
0;
}

public 
rename(String:old_name[], String:new_name[])
{
    new 
game[32];
    
game[0] = 1888;
    new 
old_name_furl[200];
    new 
new_name_furl[200];
    
format(old_name_furl199"%s/%s"gameold_name);
    
format(new_name_furl199"%s/%s"gamenew_name);
    
rename_file(old_name_furlnew_name_furl0);
    return 
0;

Fixed version (rewrite):
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include "inc/BTE_API.inc"

new bte_mode[][16] = {"none""td""dm""ze""zb1" "zb3""zb4""ghost""zse""gd"};

public 
plugin_init()
{
    
register_plugin("BTE Choose Mode""1.0""NN");
    
    
register_srvcmd("bte_change_mode""cmd_change_mode");
}

public 
cmd_change_mode(id)
{
    new 
sCmd[32];
    
read_argv(1sCmd31);
    
    if (!
sCmd[0])
    {
        
server_print("usage: bte_change_mode < mode >");
        return 
PLUGIN_HANDLED;
    }
    
    
change_mode(sCmd);
    
    return 
PLUGIN_HANDLED;
}

public 
change_mode(mode[])
{
    new 
config_dir[64], url_new[64], url_new2[64];
    
get_configsdir(config_dircharsmax(config_dir));
    
    
format(url_newcharsmax(url_new), "%s/plugins-%s.ini"config_dirmode);
    
format(url_new2charsmax(url_new2), "%s/disabled-%s.ini"config_dirmode);
    
    if (
file_exists(url_new))
    {
        
server_print("Current mode already is %s"mode);
        return;
    }
    
    if (!
file_exists(url_new2))
    {
        
server_print("NOT exist %s"mode);
        return;
    }
    
    for (new 
i=0i<sizeof(bte_mode); i++)
    {
        new 
url[64], url2[64];
        
format(urlcharsmax(url), "%s/plugins-%s.ini"config_dirbte_mode[i]);
        
format(url2charsmax(url2), "%s/disabled-%s.ini"config_dirbte_mode[i]);
        
        if (
file_exists(url))
            
rename(urlurl2);
    }
    
    
rename(url_new2url_new);
    
    
//server_print("Mode changed, please change map or restart server.");
    
client_print(0print_chat"[Server] game mode changed to %s"mode);
}

public 
rename(old_name[], new_name[])
{
    new 
game[32] = "cstrike"
    
new old_name_furl[200], new_name_furl[200]
    
format(old_name_furl199"%s/%s"gameold_name)
    
format(new_name_furl199"%s/%s"gamenew_name)
    
rename_file(old_name_furlnew_name_furl0);

__________________

Last edited by nG_getwreck; 04-21-2021 at 15:05.
nG_getwreck is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 04-21-2021 , 18:28   Re: Loading plugins from disabled-map.ini
Reply With Quote #2

And why would you want such a plugin when there's such a function built into the amxx system?
__________________
My Plugins:


Accepting private projects.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 04-21-2021 , 22:34   Re: Loading plugins from disabled-map.ini
Reply With Quote #3

He doesn't read disabled-<mod name>.ini
He change the file's name from disabled-<mod name>.ini to plugins-<mod name>.ini while change the other to disabled

This was used in CS-NST years ago
__________________
My plugin:

Last edited by Celena Luna; 04-21-2021 at 22:35.
Celena Luna 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 19:40.


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