(01-20-2012, 20:41)iAegle Wrote: [ -> ]ok here's a readable one:
Code:
if( GetDvar( "scr_dm_score_kill" ) == "" )
{
string text = File.ReadAllText( Directory.GetCurrentDirectory() + "/admin/server.cfg" ) +
"\nset scr_dm_score_kill \"100\"" +
"\nset scr_dm_score_headshot \"100\"";
File.WriteAllText( Directory.GetCurrentDirectory() + "/admin/server.cfg", text );
}
Problem with this code is that the server.cfg doesn't have to be in that location.
(01-20-2012, 20:44)Nukem Wrote: [ -> ] (01-20-2012, 20:41)iAegle Wrote: [ -> ]ok here's a readable one:
Code:
if( GetDvar( "scr_dm_score_kill" ) == "" )
{
string text = File.ReadAllText( Directory.GetCurrentDirectory() + "/admin/server.cfg" ) +
"\nset scr_dm_score_kill \"100\"" +
"\nset scr_dm_score_headshot \"100\"";
File.WriteAllText( Directory.GetCurrentDirectory() + "/admin/server.cfg", text );
}
Code:
ServerCommand("seta scr_dm_score_headshot 100");
@
Nukem Problem with that code is that if they have said it to 100000 in the server.cfg it will overwrite it.
(01-20-2012, 20:44)Nukem Wrote: [ -> ] (01-20-2012, 20:41)iAegle Wrote: [ -> ]ok here's a readable one:
Code:
if( GetDvar( "scr_dm_score_kill" ) == "" )
{
string text = File.ReadAllText( Directory.GetCurrentDirectory() + "/admin/server.cfg" ) +
"\nset scr_dm_score_kill \"100\"" +
"\nset scr_dm_score_headshot \"100\"";
File.WriteAllText( Directory.GetCurrentDirectory() + "/admin/server.cfg", text );
}
Code:
ServerCommand("seta scr_dm_score_headshot 100");
nice but it doesnt work nukem
(01-20-2012, 20:50)iAegle Wrote: [ -> ] (01-20-2012, 20:44)Pozzuh Wrote: [ -> ] (01-20-2012, 20:41)iAegle Wrote: [ -> ]ok here's a readable one:
Code:
if( GetDvar( "scr_dm_score_kill" ) == "" )
{
string text = File.ReadAllText( Directory.GetCurrentDirectory() + "/admin/server.cfg" ) +
"\nset scr_dm_score_kill \"100\"" +
"\nset scr_dm_score_headshot \"100\"";
File.WriteAllText( Directory.GetCurrentDirectory() + "/admin/server.cfg", text );
}
Problem with this code is that the server.cfg doesn't have to be in that location.
Fixed:
Code:
if( GetDvar( "scr_dm_score_kill" ) == "" )
{
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 text = File.ReadAllText( Path ) +
"\nset scr_dm_score_kill \"100\"" +
"\nset scr_dm_score_headshot \"100\"";
File.WriteAllText( Path, text );
}
yes but what uses that? ya know:
using Addon;
using System;
and you will still overwrite the original value..
(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" ) == "" )
(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
(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