AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Need Help for Config (https://forums.alliedmods.net/showthread.php?t=235811)

Kriax 02-21-2014 12:13

Need Help for Config
 
Hello,

I made ​​a self-balancing via a config file based on the map.
I only want to know how to finish the plugin because I block, let me explain:

In addons / sourcemod / config I have a folder name test, this test file name includes the name of each map used by the server.
If the file does not exist, the plugin automatically created.

Files that behaves like this:

Code:

"team"
{
    "1"        "1"
    "3"        "6"
    "4"        "11"
    "5"        "16"
    "6"        "24"
    "7"        "30"
   
    // "T"    "CT"
}

I want to know how to read my addons/sourcemod/test/de_dust2.cfg file.
And how an automatic swap T in CT if the number of T is greater to that defined in the config.

This is the beginning of the plugin:

PHP Code:

#include <sourcemod>

new String:g_sConfigFile[256];

public 
OnMapStart()
{
    
decl String:sPath[256];
    
BuildPath(Path_SMsPathsizeof(sPath), "configs/test");
    
    if (!
DirExists(sPath))
        
CreateDirectory(sPath511);
        
    
decl String:sMap[64];
    
GetCurrentMap(sMapsizeof(sMap));
    
    
BuildPath(Path_SMg_sConfigFilesizeof(g_sConfigFile), "configs/test/%s.cfg"sMap);
    
    if (!
FileExists(g_ConfigFilefalse))
        
CreateConfig();
}

public 
CreateConfig()
{
    new 
Handle:hKv CreateKeyValues("team""""");
    
FileToKeyValues(hKvg_sConfigFile);
    
    
KvSetNum(hKv"1"1);
    
KvSetNum(hKv"2"6);
    
KvSetNum(hKv"3"11);
    
KvSetNum(hKv"4"16);
    
KvSetNum(hKv"5"24);
    
    
KeyValuesToFile(hKvg_ConfigFile);
    
CloseHandle(hKv);


Thx,
Kriax.

Spoiler

Kriax 03-04-2014 13:46

Re: Need Help for Config
 
up :3

spumer 03-05-2014 03:21

Re: Need Help for Config
 
Kriax, read the manual: https://wiki.alliedmods.net/KeyValue...d_Scripting%29


All times are GMT -4. The time now is 00:14.

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