alliedmodders / amxmodx

AMX Mod X - Half-Life 1 Scripting and Administration
http://www.amxmodx.org/
494 stars 197 forks source link

AutoExecConfig can't create the config file #805

Open oaus opened 4 years ago

oaus commented 4 years ago

I try to create a auto exec config file in my custom directory, but the plugin cannot create the config file because it says The configuration for myplugin.amxx could not be generated automatically, make sure the directory has write permission.

So I investigated how this native works and found the way in which the config file is created: https://github.com/alliedmodders/amxmodx/blob/975d8778005842efb0a2729f09017c359176f58d/amxmodx/CoreConfig.cpp#L161

so I ask: "Why AutoExecConfig can't create the config file with thewt mode, but can I create the configuration file with the wt mode in my plugin (in the same directory)? e.g.

public plugin_init()
{
    new szFileDir[128];
    get_configsdir(szFileDir, charsmax(szFileDir));
    add(szFileDir, charsmax(szFileDir), "/example");

    if(!dir_exists(szFileDir))
        mkdir(szFileDir);

    create_cvar("test", "cvar");
    AutoExecConfig(true, "my_custom_cfg", "example"); // with error

    new fp = fopen(fmt("%s/my_custom_cfg2.cfg", szFileDir), "wt"); //without error
    fprintf(fp, "test ^"cvar^"");
    fclose(fp);
}

I'm using the last build: v1.9.0.5263 sorry for my bad english.

oaus commented 4 years ago

I investigated a little more and I realized that if the "plugins" folder does not exist in the "configs" folder is when the error occurs, the "plugins" folder must be created next to the folder if they do not exist. .

If I put AutoExecConfig (true, "my_custom_cfg"), the "plugins" folder is created normally, but if the folder is specified it does not create the "plugins" folder