-
Notifications
You must be signed in to change notification settings - Fork 1
/
StaticCfg.as
76 lines (62 loc) · 1.9 KB
/
StaticCfg.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* StaticCfg- Plugin for overriding standard map cvars
Based on The StaticCfg AMXX plugin
Installation:
1) Put StaticCfg.as into svencoop_addon/scripts/plugins
2) Add this to default_plugins.txt:
"plugin"
{
"name" "StaticCfg"
"script" "StaticCfg"
}
3) Inside the dir svencoop_addon/scripts/plugins/store create the file static.cfg
4) Add your CVars into this new config file
WARNING:
This will override map cvars and will potentially break maps if you don't know what you're doing.
Add your CVars sparingly.
- Outerbeast*/
const string strCfgDir = "scripts/plugins/store/static.cfg";
dictionary dictCfg;
void PluginInit()
{
g_Module.ScriptInfo.SetAuthor( "Outerbeast" );
g_Module.ScriptInfo.SetContactInfo( "svencoopedia.fandom.com" );
ReadCfg();
}
void ReadCfg()
{
File@ pFile = g_FileSystem.OpenFile( strCfgDir, OpenFile::READ );
if( pFile is null || !pFile.IsOpen() )
{
g_EngineFuncs.ServerPrint( "StaticCfg: no static.cfg file found.\n" );
return;
}
while( !pFile.EOFReached() )
{
string strCurrentLine;
pFile.ReadLine( strCurrentLine );
if( strCurrentLine.SubString( 0, 1 ) == "#" || strCurrentLine.IsEmpty() )
continue;
array<string> parsed = strCurrentLine.Split( " " );
if( parsed.length() < 2 )
continue;
dictCfg[parsed[0]] = parsed[1];
}
pFile.Close();
}
void MapInit()
{
array<string> STR_CVARS_KEYS = dictCfg.getKeys();
STR_CVARS_KEYS.sortAsc();
string strCVarValue;
for( uint i = 0; i < STR_CVARS_KEYS.length(); ++i )
{
if( STR_CVARS_KEYS[i] == "" )
continue;
dictCfg.get( STR_CVARS_KEYS[i], strCVarValue );
g_EngineFuncs.CVarSetFloat( STR_CVARS_KEYS[i], atof( strCVarValue ) );
g_EngineFuncs.ServerPrint( "StaticCfg: Set CVar " + STR_CVARS_KEYS[i] + " " + strCVarValue + "\n" );
}
}
/* Special thanks to
- Neo for scripting support
- Incognico for file parsing code */