Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Another bit of help...
#21
(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 Big Grin
(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

#22
(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 Big Grin

haha Wink
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'
Reply

#23
Change new string[]{blabla} to "*.cfg"
(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

#24
(01-20-2012, 21:08)iAegle Wrote: Change new string[]{blabla} to "*.cfg"

Awezome! But im trying to understand how this works fully Rolleyes
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);
            }
Reply



Forum Jump:


Users browsing this thread:
2 Guest(s)

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