Page 1 of 1

[?] How to Remove Vehicles?

Posted: 2010-02-18 11:37
by Reel Liddy
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):

***************

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
""")
**************

Re: How to Remove Vehicles?

Posted: 2010-02-18 12:11
by AfterDune
Put it in code tags, son. If people copy/paste this, they will crash hardzorz.



And you're not using the PR vehicle names in your script.

Re: How to Remove Vehicles?

Posted: 2010-02-18 13:27
by Reel Liddy
What are code tags? Tell me how to paste this sort of thing safely and I'll edit my original post to remove the hazard.

Otherwise, the PR vehicle names do not appear because, as I explained, this is a script to be used in BF2, not PR. I gave it as an example of how it is done in BF2 in the hopes that a Python-able person would immediately see what I was talking about.

Re: How to Remove Vehicles?

Posted: 2010-02-18 15:08
by AfterDune
Code tags:

[ code]
paste your code here
[/ code]

(remove the spaces in code-tags)

Re: How to Remove Vehicles?

Posted: 2010-02-19 12:07
by Reel Liddy
There, I've put proper code tags in my original post. No replies yet -- is removing vehicles with scripts more difficult in PR than in BF2? Perhaps I'm in the wrong subforum? I'm going to ask this question again in the PRSP subforum, if it's answered there I'll delete this thread

Re: How to Remove Vehicles?

Posted: 2010-02-19 13:38
by Amok@ndy
did you even tried putting in all the pr vehicles ?

Re: How to Remove Vehicles?

Posted: 2010-02-19 14:46
by Reel Liddy
I have found the answer! I have discovered the modding tutorials and it turns out to be very easy to remove assets; all you have to do is comment out the relevant lines in the GamePlayObjects.con file.

Admins, please feel free to delete this thread if you like.