Posts: 1,830
Threads: 104
Joined: Jan 2011
Reputation:
46
(01-20-2012, 21:00)slipknotignacio Wrote: (01-20-2012, 20:55)iAegle Wrote: (01-20-2012, 20:53)slipknotignacio Wrote: (01-20-2012, 20:52)Pozzuh Wrote: and you will still overwrite the original value..
if( GetDvar( "scr_dm_score_kill" ) == "" )
if( GetDvar( "scr_dm_score_kill" ) == "" )
if( GetDvar( "scr_dm_score_kill" ) == "" )
if( GetDvar( "scr_dm_score_kill" ) == "" )
if( GetDvar( "scr_dm_score_kill" ) == "" )
if( GetDvar( "scr_dm_score_kill" ) == "" )
Yeah well .. that doesn't work according to @Pozzuh which I believe is true. But you could do something like:
Code: string[] files = Directory.GetFiles( Directory.GetCurrentDirectory(), new string[]{ ".cfg" } );
string Path = Directory.GetCurrentDirectory() + "/admin/server.cfg";
foreach( string file in files )
if( file.ToLower().EndsWith( "server.cfg" ) )
Path = file;
string xpValueK = GetServerCFG( "XP", "Kill", "100" );
string xpValueH = GetServerCFG( "XP", "Headshot", "100" );
string text = File.ReadAllText( Path ) +
"\nset scr_dm_score_kill \"" + xpValueK + "\"" +
"\nset scr_dm_score_headshot \"" + xpValueH + "\"";
File.WriteAllText( Path, text );
so people can set it in their .ini file
why put that if is the same like in server.cfg just without this code
pretty good question, dunno just trying to help
Posts: 1,519
Threads: 107
Joined: Dec 2011
Reputation:
48
(01-20-2012, 21:02)iAegle Wrote: (01-20-2012, 21:00)slipknotignacio Wrote: (01-20-2012, 20:55)iAegle Wrote: (01-20-2012, 20:53)slipknotignacio Wrote: (01-20-2012, 20:52)Pozzuh Wrote: and you will still overwrite the original value..
if( GetDvar( "scr_dm_score_kill" ) == "" )
if( GetDvar( "scr_dm_score_kill" ) == "" )
if( GetDvar( "scr_dm_score_kill" ) == "" )
if( GetDvar( "scr_dm_score_kill" ) == "" )
if( GetDvar( "scr_dm_score_kill" ) == "" )
if( GetDvar( "scr_dm_score_kill" ) == "" )
Yeah well .. that doesn't work according to @Pozzuh which I believe is true. But you could do something like:
Code: string[] files = Directory.GetFiles( Directory.GetCurrentDirectory(), new string[]{ ".cfg" } );
string Path = Directory.GetCurrentDirectory() + "/admin/server.cfg";
foreach( string file in files )
if( file.ToLower().EndsWith( "server.cfg" ) )
Path = file;
string xpValueK = GetServerCFG( "XP", "Kill", "100" );
string xpValueH = GetServerCFG( "XP", "Headshot", "100" );
string text = File.ReadAllText( Path ) +
"\nset scr_dm_score_kill \"" + xpValueK + "\"" +
"\nset scr_dm_score_headshot \"" + xpValueH + "\"";
File.WriteAllText( Path, text );
so people can set it in their .ini file
why put that if is the same like in server.cfg just without this code
pretty good question, dunno just trying to help
haha
Code: string[] files = Directory.GetFiles(Directory.GetCurrentDirectory(), new string[] { "*.cfg" });
im getting 2 errors:
The best overloaded method match for 'System.IO.Directory.GetFiles(string, string)' has some invalid arguments
Argument 2: cannot convert from 'string[]' to 'string'
Posts: 1,830
Threads: 104
Joined: Jan 2011
Reputation:
46
Change new string[]{blabla} to "*.cfg"
Posts: 1,519
Threads: 107
Joined: Dec 2011
Reputation:
48
01-20-2012, 21:10
(This post was last modified: 01-20-2012, 21:34 by kokole.)
(01-20-2012, 21:08)iAegle Wrote: Change new string[]{blabla} to "*.cfg"
Awezome! But im trying to understand how this works fully
Learn C# Is cool!
(01-20-2012, 21:08)iAegle Wrote: Change new string[]{blabla} to "*.cfg"
and is seta not set
commands differ depending of where they are used
I tested it but it works not properly. It sets the values AGAIN every time the dedi console is opened like this if i open it 3 times:
Code: seta scr_dm_score_kill "100"
seta scr_dm_score_headshot "100"
seta scr_dm_score_suicide "100"
seta scr_dm_score_kill "100"
seta scr_dm_score_headshot "100"
seta scr_dm_score_suicide "100"
seta scr_dm_score_kill "100"
seta scr_dm_score_headshot "100"
seta scr_dm_score_suicide "100"
here is your code modified a bit:
Code: public override void OnServerLoad()
{
if (GetDvar("scr_dm_score_kill") == "")
{
string[] files = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.cfg");
string Path = Directory.GetCurrentDirectory() + "/admin/server.cfg";
foreach (string file in files)
if (file.ToLower().EndsWith("server.cfg"))
Path = file;
string text = File.ReadAllText(Path) +
"\nseta scr_dm_score_kill \"100\"";
File.WriteAllText(Path, text);
}
if (GetDvar("scr_dm_score_headshot") == "")
{
string[] files = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.cfg");
string Path = Directory.GetCurrentDirectory() + "/admin/server.cfg";
foreach (string file in files)
if (file.ToLower().EndsWith("server.cfg"))
Path = file;
string text = File.ReadAllText(Path) +
"\nseta scr_dm_score_headshot \"100\"";
File.WriteAllText(Path, text);
}
if (GetDvar("scr_dm_score_suicide") == "")
{
string[] files = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.cfg");
string Path = Directory.GetCurrentDirectory() + "/admin/server.cfg";
foreach (string file in files)
if (file.ToLower().EndsWith("server.cfg"))
Path = file;
string text = File.ReadAllText(Path) +
"\nseta scr_dm_score_suicide \"100\"";
File.WriteAllText(Path, text);
}
|