[?] How to Remove Vehicles?
Posted: 2010-02-18 11:37
I'm sure this will be an easy question for you Python heads to answer... I want to play PR Single, in Coop mode, or run server, and remove ALL JETS from ALL MAPS. A kind fellow helped me do this in BF2, with a little script he wrote called vehicle.py (I will paste the whole thing below after this question.
Basically all I want to do is prevent all Jets from spawning when I start up PR. I vaguely understand how the script vehicle.py works when I run it for BF2, but I can't see how it would work in PR, which seems to initialize the vehicles differently.
Here is how Jets (and also Arty in this case) can be removed from BF2, from the original fellow who sent me the material:
"Move both of these files, __init__.py and vehicle.py, to Battlefield 2\mods\bf2\python\game\gamemodes (overwrite the init.py, it's empty anyway)....To remove the changes (just in case), delete the two lines inside the __init__.py and restart the server."
The new __init__.py now contains these two lines (but no asterisks):
***************
***************
And the script, vehicle.py, contains the following:
****************
**************
Basically all I want to do is prevent all Jets from spawning when I start up PR. I vaguely understand how the script vehicle.py works when I run it for BF2, but I can't see how it would work in PR, which seems to initialize the vehicles differently.
Here is how Jets (and also Arty in this case) can be removed from BF2, from the original fellow who sent me the material:
"Move both of these files, __init__.py and vehicle.py, to Battlefield 2\mods\bf2\python\game\gamemodes (overwrite the init.py, it's empty anyway)....To remove the changes (just in case), delete the two lines inside the __init__.py and restart the server."
The new __init__.py now contains these two lines (but no asterisks):
***************
Code: Select all
import vehicle
vehicle.init()
And the script, vehicle.py, contains the following:
****************
Code: Select all
import host
import bf2
APCS=("usapc_lav25","apc_btr90","apc_wz551")
TANKS=("ustnk_m1a2","rutnk_t90","tnk_type98")
MOBILEAA=("usaav_m6","aav_tunguska","aav_type95")
JEEPS=("jeep_faav","usjep_hmmwv","jep_paratrooper","jep_mec_paratrooper","jep_vodnik","jep_nanjing")
BOATS=("at_rib")
STATAA=("usaas_stinger","igla_djigit")
STATAT=("ats_tow","ats_hj8")
BIPODS=("mec_bipod","us_bipod","ch_bipod")
WASP=("wasp_defence_front","wasp_defence_back")
JETS=("usair_f18","ruair_mig29","air_j10","usair_f15","ruair_su34","air_su30mkk","air_f35")
HELICOPTERS=("usthe_uh60","the_mi17","chthe_z8","ahe_ah1z","ahe_havoc","ahe_z10")
ARTY=("usart_lw155","ars_d30")
def init():
host.registerGameStatusHandler(onGameStatusChanged)
def onGameStatusChanged(status):
print status
if status == 1:
remover(JETS+ARTY)
####### to remove APCs instead of jets, use remover(APCS) instead of remover(JETS) above
####### to remove both APCs and jets, use remover(JETS+APCS)
####### to remove APCS, jets and arty, blahblahblah
def remover(vehicletype):
cp = bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ObjectSpawner')
for spawner in cp:
spawnerName = spawner.templateName
vehicle = host.rcon_invoke("""
objecttemplate.active %s
objecttemplate.objecttemplate
""" % spawnerName)
for obj in vehicletype:
if vehicle.lower().find(obj)!=-1:
print spawnerName
print vehicle
host.rcon_invoke("""
objecttemplate.nrofobjecttospawn 0
""")