Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Another bit of help...
#11
(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.
[Image: MaEIQ.png]
Reply

#12
(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");
[Image: b_560_95_1.png]
Reply

#13
(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.

[Image: MaEIQ.png]
Reply

#14
(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
Reply

#15
(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 );
}
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#16
(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;
Reply

#17
and you will still overwrite the original value..
[Image: MaEIQ.png]
Reply

#18
(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" ) == "" )
Reply

#19
(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
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#20
(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
Reply



Forum Jump:


Users browsing this thread:
2 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.