Posts: 5,135
Threads: 241
Joined: Nov 2010
Reputation:
100
(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.
Posts: 619
Threads: 30
Joined: Oct 2010
Reputation:
85
(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");
Posts: 5,135
Threads: 241
Joined: Nov 2010
Reputation:
100
(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.
Posts: 1,519
Threads: 107
Joined: Dec 2011
Reputation:
48
(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
Posts: 1,830
Threads: 104
Joined: Jan 2011
Reputation:
46
01-20-2012, 20:50
(This post was last modified: 01-20-2012, 20:51 by iAegle.)
(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(), "*.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 );
}
Posts: 1,519
Threads: 107
Joined: Dec 2011
Reputation:
48
(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;
Posts: 5,135
Threads: 241
Joined: Nov 2010
Reputation:
100
and you will still overwrite the original value..
Posts: 1,519
Threads: 107
Joined: Dec 2011
Reputation:
48
(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" ) == "" )
Posts: 1,830
Threads: 104
Joined: Jan 2011
Reputation:
46
(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
Posts: 1,519
Threads: 107
Joined: Dec 2011
Reputation:
48
(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
|