Thom747
Member
+1|5500
Introduction
So, you have read [url=http://wiki.bf2s.com/tactical-guides/editing-favourites]Snake's Guide on Manual Editing of your Favorites list[/url] and now you think: "Well, it's great that I now know how to edit my favorites manually, but I hate to edit those names every time I want to play Battlefield 2!"
Well here's how to do it automatically!
Please note that working with these codes can empty (if wrongly inputted) your General.con/VANGeneral.con/SFGeneral.con files so make sure that you have backups for those files! You have been warned!
Also note that this has only been tested in (and will probably only work for) WINDOWS

1) As explained by Snake
First of all you should do the first 2 steps from Snake's guide.
With only one change and that being that once you have separated your SF servers and your Vanilla servers, you should give them the following names:
SFGeneral.con for your Special Forces servers,
VanGeneral.con for your Vanilla servers,
and you should make an empty file called: General.con

2) First Coding
This is why this will only work for Windows as Windows is the only OS that uses DOS (as far as I know)
First of all, create 2 files.
Now you can name them anything as long as you make the extension .cmd.
for example:

Code:

Vanexample.cmd
SFexample.cmd
Now open them up in Notepad (by right-clicking and selecting "edit")
In your Vanexample.cmd enter the following:

Code:

set WORKDIR="Documents and Settings\NAME\My Documents\Battlefield 2\Profiles\0002"
copy %WORKDIR%\VanGeneral.con %WORKDIR%\General.con
here is what it all means:

set WORKDIR="Documents and Settings\NAME\My Documents\Battlefield 2\Profiles\0002"
sets the work directory to "Documents and Settings\NAME\My Documents\Battlefield 2\Profiles\0002"
Don't forget to change "NAME" to the name of the Windows-account you're using!

copy %WORKDIR%\VanGeneral.con %WORKDIR%\General.con
copies everything in VanGeneral.con into General.con

Now for your SFexample.cmd:

Code:

set WORKDIR="Documents and Settings\NAME\My Documents\Battlefield 2\Profiles\0002"
copy %WORKDIR%\SFGeneral.con %WORKDIR%\General.con
Again, don't forget to change "Name" into your Windows-account

Great! If you click one of them now, your General.con should change.

3) Getting Battlefield 2 to start up after changing the General.con
Now that it changes the General.con, why not start Battlefield immediately after?
Open up your Vanexample.cmd and SFexample.cmd again and add this line to each of them:
Vanexample.cmd:

Code:

C:
"C:\Program Files\EA GAMES\Battlefield 2\BF2.exe" +menu 1 +fullscreen 1
Again I'll list what it means:

C:
Tells the computer that the following command will be on the C disk

"C:\Program Files\EA GAMES\Battlefield 2\BF2.exe" +menu 1 +fullscreen 1
The command for starting Battlefield 2.

Now for SFexample.cmd:

Code:

C:
"C:\Games\EA GAMES\Battlefield 2\BF2.exe" +menu 1 +fullscreen 1 +modPath mods/xpack +ignoreAsserts 1
The complete code should be this:
Vanexample.cmd:

Code:

set WORKDIR="Documents and Settings\NAME\My Documents\Battlefield 2\Profiles\0002"
copy %WORKDIR%\VanGeneral.con %WORKDIR%\General.con
C:
"C:\Program Files\EA GAMES\Battlefield 2\BF2.exe" +menu 1 +fullscreen 1
SFexample.cmd:

Code:

set WORKDIR="Documents and Settings\NAME\My Documents\Battlefield 2\Profiles\0002"
copy %WORKDIR%\SFGeneral.con %WORKDIR%\General.con
C:
"C:\Games\EA GAMES\Battlefield 2\BF2.exe" +menu 1 +fullscreen 1 +modPath mods/xpack +ignoreAsserts 1
At this point you can choose to end the tutorial and use your .cmd files as they are (this does mean that you'll have to manually add new favorites to your list)
OR you go on with the next step which does require a program to be downloaded.

4) Saving your favorites and deleting your ServerHistory
please Note that for the next step you'll need a program called [url=http://gnuwin32.sourceforge.net/downlinks/gawk.php]Gawk[/url]
Gawk is a OpenSource (non-profit) program.
Meaning it can be changed (and thus often checked for viruses) by anyone, however, that doesn't mean you should be careless with every OpenSource program. Even though I tell you to download and execute it you might want to scan it first with your anti-virus software.

Now that we've got Gawk lets get on with coding, okay?
In your Vanexample.cmd enter the following:

Code:

awk -- "$0 !~ /ServerHistory/ { print }" "%WORKDIR%\General.con" >"%WORKDIR%\VanGeneral.con"
meaning:

awk
This tells the computer that the following will be done using Gawk

-- "$0 !~ /ServerHistory/ { print }"
Tells Gawk that if it finds "ServerHistory" it should not print (copy) the entire line which contains "ServerHistory".

"%WORKDIR%\General.con" >"%WORKDIR%\VanGeneral.con"
Tells Gawk to copy everything in General.con into Vangeneral.con (except for the lines with "HistoryServer" in it).

And this is the code for SFexample.cmd:

Code:

awk -- "$0 !~ /ServerHistory/ { print }" %WORKDIR%\General.con >%WORKDIR%\SFGeneral.con
Now that you've done this both files should look like this:
Vanexample.con:

Code:

set WORKDIR="Documents and Settings\NAME\My Documents\Battlefield 2\Profiles\0002"
copy %WORKDIR%\VanGeneral.con %WORKDIR%\General.con
C:
"C:\Program Files\EA GAMES\Battlefield 2\BF2.exe" +menu 1 +fullscreen 1 
awk -- "$0 !~ /ServerHistory/ { print }" "%WORKDIR%\General.con" >"%WORKDIR%\VanGeneral.con"
SFexample.con:

Code:

set WORKDIR="Documents and Settings\NAME\My Documents\Battlefield 2\Profiles\0002"
copy %WORKDIR%\SFGeneral.con %WORKDIR%\General.con
C:
"C:\Games\EA GAMES\Battlefield 2\BF2.exe" +menu 1 +fullscreen 1 +modPath mods/xpack +ignoreAsserts 1
awk -- "$0 !~ /ServerHistory/ { print }" %WORKDIR%\General.con >%WORKDIR%\SFGeneral.con
And we're done!
Clicking either one of the two .cmd files will now bring up a black screen with white characters, Do not close this! It will close itself after you quit Battlefield 2.
The reason you shouldn't close this screen is because there is one more thing this screen is going to do after you exit Battlefield 2 and that is that it copies your (new) Favorites into the right file and that it deletes all ServerHistory.

5) End and Credits
Well that's about it, if you have questions or comments please post a reply and I'll see what I can do for you.

Credits
Webmeesters
for the help with the code.
DICE and EA for making this great game.
You for reading.
Me for making this guide ;-)

Last edited by Thom747 (2009-03-08 01:05:45)

steelie34
pub hero!
+603|6351|the land of bourbon
more useful info!  pace, take notes
https://bf3s.com/sigs/36e1d9e36ae924048a933db90fb05bb247fe315e.png

Board footer

Privacy Policy - © 2024 Jeff Minard