Battlefield 2 invades the high-tech frontlines of modern warfare. The game brings the intensity and excitement of Battlefield 1942 into the modern era with enhanced team play and the latest, most technologically advanced vehicles and weapons systems available to man.

Post tutorial Report RSS How to edit files while playing

This tutorial will help you and save you valuable time modding the game when you play it in real time.

Posted by on - Intermediate Server Side Coding

Well let's start


Here are the prerequisites :

  • Battlefield 2 already installed
  • Notepad++ Link
  • Winrar or any software for extract .zip
  • A mod to edit, never edit the folder *mods/bf2/.. >Tutorial Link (see rule n°1)

What is this for ?
Well you know, modding means that we have to modify files, and launch the game to see if everything is good, close it, and that everytime..

So the goal is to save as much time as possible, and to be able to edit files WHILE PLAYING !

Here are the steps to follow :
I use bf2 without going through my mod so that everyone understands

Capture dcran 2024 02 20 1857


Open your mod and create a "scripts" folder (or name it whatever you want, you will have to copy the name later.

Capture dcran 2024 02 20 1857 1

Open the "scripts" folder, and create a .con file and name it, in my case is "weaponsSettings.con"
Then after, open the .con file and add this into it, BE CAREFUL OF SPACES :

"If v_arg1 == editing"

It should give this :

Capture dcran 2024 02 20 1857 2

Save it and leave it aside for a while.

Now be careful, don't miss the crucial step, we will have to edit a file in menu_server.zip.
Go to > menu_server.zip/HUD/HudSetup/Communication/HudElementsRadioComm.con

And then you need to add a line here :
"hudBuilder.setButtonNodeConCmd "run scripts/weaponsSettings.con editing" 0"

It should give this :
Capture dcran 2024 02 20 1913

Save it.

So what did we do? We used the "enemy spot" button in the game (Key A - azerty or q for qwerty) to activate the script which will change the files in game, remember that it will always be impossible to edit the .zip files when the game is running, but don't worry, it won't be a problem.

Now here's the fun part, you can now open the game (of course in windowed mod), and launch a map alone, try not to use bots when you do this, it could do weird things.

Okay now that you are in game, open your file in the script, and open objects_server.zip (or the zip in which you would like to make your modifications.

Capture dcran 2024 02 20 1913 1

Now we're going to do a few things, let's start something simple, change the number of bullets/magazine of my ak101, go to objects_server.zip/weapons/handheld/RURIF_AK101/RURIF_AK101.tweak

Open it, and just copy the name of the weapon and the component you are going to modify into your script and save it, pay attention to spaces, do it like the screenshot below :

Capture dcran 2024 02 20 1913 2

Obviously, add the lines you want, you can edit EVERYTHING, weapons, engine, deviation, speed, sounds, effects

Be careful though, everything you enter in the script is only for testing, once the game is closed, don't forget to report the values/modifications in your zip files !

Each line that you write in the script will overwrite the previous value, for example putting a 100 bullet magazine will replace the previous value, nothing will add together

Don't like the changes? Do you want to go back? Re-enter the previous values ​​and save the script, deleting the lines will not change anything.

Well let's go back to our ak101 with 30 bullets by default, let's give him 500 for example :

Capture dcran 2024 02 20 1913 3

Did you save the script and nothing changed? This is normal, remember, we configured the script on the spot button, press "A" (or q) and click on "spotted"

Still nothing changed? This is still normal, most modifications require the player to commit suicide (while carrying a weapon) or exit and re-enter the stationary vehicle/weapon for the modifications to take place.

After suicide, the magic happens :

Capture dcran 2024 02 20 1913 4

And here is an example of what we can do, the script is very useful especially for modifying vehicle engines, and object/hud positions, as well as sounds, camera and effects, you can add lines afterwards, it's entirely possible, for the HUD it is an a little different, here are the lines to use :

For the hud position : (hudBuilder.setActiveObject)

hudBuilder.setNodePos 274 175

(first value is axe "x" , second is "y")

For the size :

hudBuilder.setNodeSize 256 256

For example I want to move the hud of the igla

enter the name of the hud igla in the script :

Capture dcran 2024 02 20 1913 5

Change the position value for example, save, press "spotted" and exit/re-enter the igla :
Magic happend again

Capture dcran 2024 02 20 1913 6

Well of course it's just a demo, it's not really useful to move the hud of the bf2 igla !

And don't forget, When you exit the game the changes are lost, so to keep the changes, you have edit the files in the zip.

And here I think it's quite detailed, I took a really long time to write all this, don't hesitate to leave a comment to let me know if it was useful to you :)

Thanks to @EUWINPRO for the help !

For more information, join the discord modding server : Discord invite
If you want to save that tutorial, use chrome, then print tool, and save to .pdf

See you soon on the Battlefield

Ryan_Production

Post comment Comments
TEGUHDWIiD
TEGUHDWIiD - - 102 comments

Thanks Ryan

Reply Good karma Bad karma+6 votes
BF2all
BF2all - - 1,144 comments

Cool trick, thx again
In Action:

Reply Good karma Bad karma+4 votes
Anthony817
Anthony817 - - 2,771 comments

Wow this is incredible and will greatly help the community out! You are the best Ryan!

Reply Good karma Bad karma+3 votes
S_h_a_r_k_93
S_h_a_r_k_93 - - 176 comments

I didn't understand it very well the first step but, knowing that this could be used to quickly test several different variations in one fell swoop I imagine this knowledge is God-sent! Well done, thanks for sharing

Reply Good karma Bad karma+3 votes
Ryan_Production Author
Ryan_Production - - 421 comments

Basically, it involves configuring the script so that it is activated with the spot button, but it can easily be configured on another commonRose button

Reply Good karma+2 votes
Ryan_Production Author
Ryan_Production - - 421 comments

Thanks guys !

Reply Good karma+2 votes
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: