Python Coding in BF2
-
- Retired PR Developer
- Posts: 9381
- Joined: 2006-06-08 19:13
Python Coding in BF2
For the ones interested in python coding in BF2, here are a few links that helped me out when I started.
Main Page - BF2 Technical Information Wiki
Object Reference - BF2 Technical Information Wiki
Event Reference - BF2 Technical Information Wiki
Scripts - BF2 Technical Information Wiki
BF2 Coordinates - BF2 Technical Information Wiki
List of available host.rcon invoke commands - BF2 Technical Information Wiki
Official BF Editor Forums -> Python
Also you can check vBF2 python code in mods/bf2/python/game and other mods python code.
If you are new to python, checking online documentation is your best bet. Here are some links that were useful when I started learning the language:
5. Data Structures
3.6.1 String Methods
Main Page - BF2 Technical Information Wiki
Object Reference - BF2 Technical Information Wiki
Event Reference - BF2 Technical Information Wiki
Scripts - BF2 Technical Information Wiki
BF2 Coordinates - BF2 Technical Information Wiki
List of available host.rcon invoke commands - BF2 Technical Information Wiki
Official BF Editor Forums -> Python
Also you can check vBF2 python code in mods/bf2/python/game and other mods python code.
If you are new to python, checking online documentation is your best bet. Here are some links that were useful when I started learning the language:
5. Data Structures
3.6.1 String Methods
Last edited by Suchar on 2021-01-09 18:50, edited 2 times in total.
Reason: Updated links to BF2 Technical Wiki
Reason: Updated links to BF2 Technical Wiki
-
- Posts: 128
- Joined: 2008-06-20 20:31
Re: Python coding in BF2
Hello dbzao, we want to make an Argentinian faction (PR), could you tell me if is necessary to modify the python (pyc) files or it is possible to do this only using the open files (_init_.py , realityconfig_local / private.py) from a patch into a level??, local and dedicated options.
Have the pyc files a pass? I want to open scoringCommon.pyc but Ican't do it.
][/URL]
Thanks
Have the pyc files a pass? I want to open scoringCommon.pyc but Ican't do it.
][/URL]
Thanks
-
- Retired PR Developer
- Posts: 9381
- Joined: 2006-06-08 19:13
Re: Python coding in BF2
To test your changes you only really need to edit realityconfig_local (when testing locally) or realityconfig_private (if testing in a passworded dedicated server).
Also there are a few other .con and .tweak files you need to edit to make sure things spawn properly like the spawner files in objects_server/common/spawner.
I think there's another thread somewhere with instructions to test new factions.
Also there are a few other .con and .tweak files you need to edit to make sure things spawn properly like the spawner files in objects_server/common/spawner.
I think there's another thread somewhere with instructions to test new factions.
-
- Posts: 128
- Joined: 2008-06-20 20:31
Re: Python coding in BF2
Ok thanks, I try to make it, about kits and new vehicles , soldiers, etc, We worked in this files and at this time they are operative, but there are not working the kits "ar", for example: crewman_ar, pilot_ar, etc..scoreflags...
link to TH Puerto_Argentino (Port_Stanley):https://www.realitymod.com/forum/f354-community-maps/56973-map-puerto_argentino-wip.html
link to TH Puerto_Argentino (Port_Stanley):https://www.realitymod.com/forum/f354-community-maps/56973-map-puerto_argentino-wip.html
Last edited by alexandrei07 on 2009-04-23 01:13, edited 2 times in total.
-
- Posts: 128
- Joined: 2008-06-20 20:31
Re: Python coding in BF2
Hi, I modify realityconfig_local (ar faction) and put into the init.con this setting:
rem gameLogic.setTeamName 1 "US"
gameLogic.setTeamName 1 "AR"
gameLogic.setTeamName 2 "GB"
gameLogic.setTeamLanguage 1 "USEnglish"
gameLogic.setTeamLanguage 2 "GBEnglish"
gameLogic.setTeamFlag 0 "flag_neutral"
rem gameLogic.setTeamFlag 1 "flag_us"
gameLogic.setTeamFlag 1 "flag_ar"
gameLogic.setTeamFlag 2 "flag_gb"
gameLogic.setKit 1 0 "ar_officer" "pr_ar_soldier4"
rem gameLogic.setKit 1 0 "us_officer" "pr_ar_soldier4"
gameLogic.setKit 2 0 "gb_officer" "pr_gb_soldier4"
gameLogic.setKit 1 1 "ar_riflemanab" "pr_ar_soldier2"
rem gameLogic.setKit 1 1 "us_riflemanab" "pr_ar_soldier2"
gameLogic.setKit 2 1 "gb_riflemanab" "pr_gb_soldier2"
gameLogic.setKit 1 2 "ar_rifleman" "pr_ar_soldier3"
rem gameLogic.setKit 1 2 "us_rifleman" "pr_ar_soldier3"
gameLogic.setKit 2 2 "gb_rifleman" "pr_gb_soldier3"
gameLogic.setKit 1 3 "ar_specialist" "pr_ar_soldier1"
rem gameLogic.setKit 1 3 "us_specialist" "pr_ar_soldier1"
gameLogic.setKit 2 3 "gb_specialist" "pr_gb_soldier1"
gameLogic.setKit 1 4 "ar_medic" "pr_ar_soldier2"
rem gameLogic.setKit 1 4 "us_medic" "pr_ar_soldier2"
gameLogic.setKit 2 4 "gb_medic" "pr_gb_soldier2"
gameLogic.setKit 1 5 "" ""
gameLogic.setKit 2 5 "" ""
gameLogic.setKit 1 6 "" ""
gameLogic.setKit 2 6 "" ""
When I deploying ...
realityflags.py error, I can't find this file...what can I do??
I put into a patch level menu_client.zip >>
Scoreboard_flag
minimap_cp
minimap_cpbase
minimap_flag
flag_ar
hugeflag_ar
flaglarge_ar
but I don't know what can I do about memeatlas_020.dds? Is it possible that this produces the error?
Edit:
The error appears at the end of the load of the map
thanks
rem gameLogic.setTeamName 1 "US"
gameLogic.setTeamName 1 "AR"
gameLogic.setTeamName 2 "GB"
gameLogic.setTeamLanguage 1 "USEnglish"
gameLogic.setTeamLanguage 2 "GBEnglish"
gameLogic.setTeamFlag 0 "flag_neutral"
rem gameLogic.setTeamFlag 1 "flag_us"
gameLogic.setTeamFlag 1 "flag_ar"
gameLogic.setTeamFlag 2 "flag_gb"
gameLogic.setKit 1 0 "ar_officer" "pr_ar_soldier4"
rem gameLogic.setKit 1 0 "us_officer" "pr_ar_soldier4"
gameLogic.setKit 2 0 "gb_officer" "pr_gb_soldier4"
gameLogic.setKit 1 1 "ar_riflemanab" "pr_ar_soldier2"
rem gameLogic.setKit 1 1 "us_riflemanab" "pr_ar_soldier2"
gameLogic.setKit 2 1 "gb_riflemanab" "pr_gb_soldier2"
gameLogic.setKit 1 2 "ar_rifleman" "pr_ar_soldier3"
rem gameLogic.setKit 1 2 "us_rifleman" "pr_ar_soldier3"
gameLogic.setKit 2 2 "gb_rifleman" "pr_gb_soldier3"
gameLogic.setKit 1 3 "ar_specialist" "pr_ar_soldier1"
rem gameLogic.setKit 1 3 "us_specialist" "pr_ar_soldier1"
gameLogic.setKit 2 3 "gb_specialist" "pr_gb_soldier1"
gameLogic.setKit 1 4 "ar_medic" "pr_ar_soldier2"
rem gameLogic.setKit 1 4 "us_medic" "pr_ar_soldier2"
gameLogic.setKit 2 4 "gb_medic" "pr_gb_soldier2"
gameLogic.setKit 1 5 "" ""
gameLogic.setKit 2 5 "" ""
gameLogic.setKit 1 6 "" ""
gameLogic.setKit 2 6 "" ""
When I deploying ...
realityflags.py error, I can't find this file...what can I do??
I put into a patch level menu_client.zip >>
Scoreboard_flag
minimap_cp
minimap_cpbase
minimap_flag
flag_ar
hugeflag_ar
flaglarge_ar
but I don't know what can I do about memeatlas_020.dds? Is it possible that this produces the error?
Edit:
The error appears at the end of the load of the map
thanks
Last edited by alexandrei07 on 2009-04-23 11:19, edited 4 times in total.
Reason: add edit
Reason: add edit
-
- Retired PR Developer
- Posts: 9381
- Joined: 2006-06-08 19:13
Re: Python coding in BF2
Please, don't post in this thread with bugs or unrelated stuff.
If you want, post your own thread about this. This is not the place.
If you want, post your own thread about this. This is not the place.
-
- Posts: 128
- Joined: 2008-06-20 20:31
Re: Python coding in BF2
OK, I will do it
sorry , please delete my post.
sorry , please delete my post.
-
- Posts: 22
- Joined: 2009-07-12 01:47
Re: Python coding in BF2
sheesh...python sucks! lol, i only say that cuz it's new to me
im a noob anyway. I know java, I just started learning C (and that gives me **** every time i try to use pointers)...so i dont know many languages.
I'm following your guides though, im gonna try and learn it (even though i think i should get C and C++ down first )
im a noob anyway. I know java, I just started learning C (and that gives me **** every time i try to use pointers)...so i dont know many languages.
I'm following your guides though, im gonna try and learn it (even though i think i should get C and C++ down first )
-
- Retired PR Developer
- Posts: 1873
- Joined: 2007-07-22 17:54
Re: Python coding in BF2
I'm not as good as dbzao or Afterdune in Python but I've learned enough to tell you that pretty much all other languages suck compared to Python!
wifi hacker
Hacking Tutorial
wifi hacker
Hacking Tutorial
Last edited by MAINERROR on 2018-05-25 12:46, edited 1 time in total.
-
- Posts: 22
- Joined: 2009-07-12 01:47
Re: Python coding in BF2
no way!!!
JAVA RULZZ!! 31337!!!!!
I COULD PROGRAM A BANANA IN JAVA!! cant do that in python
JAVA RULZZ!! 31337!!!!!
I COULD PROGRAM A BANANA IN JAVA!! cant do that in python
-
- Retired PR Developer
- Posts: 1873
- Joined: 2007-07-22 17:54
Re: Python coding in BF2
Well you can program a ASCII banana in Python.
-
- Retired PR Developer
- Posts: 3141
- Joined: 2008-02-05 00:20
Re: Python coding in BF2
Here is a pretty good tut Non-Programmer's Tutorial for Python 2.0 - Wikibooks, collection of open-content textbooks
You miss 100% of the shots you don't take.- Wayne Gretzky
-
- Posts: 31
- Joined: 2009-06-26 14:16
Re: [Python Tutorial] Python coding in BF2
is there some kind of tutorial for beginners ?
I mean, I could read thousands of python tutorials by not knowing wich modules etc. to import and what these methods and callbacks are returning etc. in order to let your script working FOR BATTLEFIELD 2 / Project Reality.
Do i have to completely learn python itself if I'd like to do some coding in Bf2 ?
or is there some kinda small library of knowledge wich would only be needed
this wiki: Original python scripting reference documentation - BFEditor
is really helpful, but I can't get started with this:
Nice to know wich methods exist and how they're called but for me as a beginner I couldn't start of with a new script like this ...
It's difficult to say but what I'd like to have is something that answers the question:
"Okay, i see
THIS =>
is the code that engages the script to "listen for players being revived"
But what if I'd like to have the script listen to players entering vehicles ?!?!"
Yeah it's basic stuff, but imo all these python tutorials do not help beginners with scripting for BF2...
Hope you'll understand
thx for responses!
I mean, I could read thousands of python tutorials by not knowing wich modules etc. to import and what these methods and callbacks are returning etc. in order to let your script working FOR BATTLEFIELD 2 / Project Reality.
Do i have to completely learn python itself if I'd like to do some coding in Bf2 ?
or is there some kinda small library of knowledge wich would only be needed
this wiki: Original python scripting reference documentation - BFEditor
is really helpful, but I can't get started with this:
Nice to know wich methods exist and how they're called but for me as a beginner I couldn't start of with a new script like this ...
It's difficult to say but what I'd like to have is something that answers the question:
"Okay, i see
THIS =>
Code: Select all
init():
bf2.registerHandler('PlayerRevived', onPlayerRevived)
print "MyScript is now listening for players being revived..."
But what if I'd like to have the script listen to players entering vehicles ?!?!"
Yeah it's basic stuff, but imo all these python tutorials do not help beginners with scripting for BF2...
Hope you'll understand
thx for responses!
Last edited by j0g32 on 2010-01-24 13:43, edited 1 time in total.
-
- Posts: 22
- Joined: 2009-03-06 10:54
Re: [Python Tutorial] Python coding in BF2
it uses version 2, but I'm not sure which subversion
some old info says it's 2.3.4, but maybe it was updated...
some old info says it's 2.3.4, but maybe it was updated...
-
- Retired PR Developer
- Posts: 9381
- Joined: 2006-06-08 19:13
Re: [Python Tutorial] Python coding in BF2
2.3.7 is fine, but bear in mind BF2 has its own set of modules, so not all of original python 2.3 modules are available.
"There's always one more bug." - Lubarsky's Law of Cybernetic Entomology
-
- Posts: 18
- Joined: 2009-06-02 16:53
Re: [Python Tutorial] Python coding in BF2
hey all,
i want to try out some stuff on our server "gis+ cobat zone PR9.x" and got some questions about it.
first of all; is it legal to change things like "player amount", "sq sice" and "removing nametags" on a locked server.
and; what files have to be modified to do so.
i want to try out some stuff on our server "gis+ cobat zone PR9.x" and got some questions about it.
first of all; is it legal to change things like "player amount", "sq sice" and "removing nametags" on a locked server.
and; what files have to be modified to do so.
-
- Retired PR Developer
- Posts: 4452
- Joined: 2008-05-07 17:43
Re: [Python Tutorial] Python coding in BF2
Afaik nametags would require you to modify the clients files.
I strongly recommend you NOT to change any client files as this if you're not backing up correctly will kick you off the servers due to md5 mismatch.
Player amount is really easy to change, just set the sv.maxPlayers 16 to whatever you want. More than 64 slots is hardcoded and requires assembly skills which is BY FAR more complex than python.
Squadsize is also hardcoded and theres no way to change that without changing the bf2 binaries.
All these question have nothing to do with python tho, would fit better in the server admins forum.
I strongly recommend you NOT to change any client files as this if you're not backing up correctly will kick you off the servers due to md5 mismatch.
Player amount is really easy to change, just set the sv.maxPlayers 16 to whatever you want. More than 64 slots is hardcoded and requires assembly skills which is BY FAR more complex than python.
Squadsize is also hardcoded and theres no way to change that without changing the bf2 binaries.
All these question have nothing to do with python tho, would fit better in the server admins forum.