Author Topic: How to get "every" vehicle datablock  (Read 1639 times)

I was working on something for EVERY vehicle, but this one statement stopped me:
Code: [Select]
if(%mnt.getDatablock().getName() $= "VEHICLENAMEVehicle")I need help making the "VEHICLENAME" to be every vehicle. Is that possible?

if(%mnt.getClassname() $= "FlyingVehicle" || %mnt.getClassname() $= "WheeledVehicle")
    //Do stuff


You could also do
if(strStr(%mnt.getClassname(),"Vehicle") != -1)
    //Do stuff

if(%mnt.getClassname() $= "FlyingVehicle" || %mnt.getClassname() $= "WheeledVehicle")
    //Do stuff


You could also do
if(strStr(%mnt.getClassname(),"Vehicle") != -1)
    //Do stuff

1st one doesnt work..
2nd is fine!
Thanks!
« Last Edit: May 23, 2012, 06:16:19 PM by MARBLE MAN »


if(%mnt.getDatablock().getName() $= "TronLightBikeVehicle")

anyone see a similarity?


if(%mnt.getDatablock().getName() $= "TronLightBikeVehicle")

anyone see a similarity?
Ofc

See the post I made in his other topic (I think it's about the planes though, not the bike)


if(%mnt.getDatablock().getName() $= "TronLightBikeVehicle")

anyone see a similarity?
Does it even matter? He's learning how to script, what's wrong with that?

Does it even matter? He's learning how to script, what's wrong with that?

Exactly. Brian, I know you've done this plenty so chill out and instead, help him.

I use this:
Code: [Select]
if(striPos(%obj.getClassName(),"Vehicle") >= 0)

I use this:
Code: [Select]
if(striPos(%obj.getClassName(),"Vehicle") >= 0)
I don't think striPos is default...


if ( %obj.getType() & $TypeMasks::VehicleObjectType )

if ( %obj.getType() & $TypeMasks::VehicleObjectType )
Nope, that doesn't work for what we're talking about. This is for any vehicle, including playertype vehicles. You could use $TypeMasks::PlayerObjectType in addition to it to get playertype vehicles as well, but that would also cause it to return true for players.

if ( %obj.getType() & $TypeMasks::VehicleObjectType )
I like the way you think. This is what I use, as well.

This is for any vehicle, including playertype vehicles.
What in the hell is a playertype vehicle? If it's a vehicle, it will fall under $TypeMasks::VehicleObjectType. If it's a player, it will fall under $TypeMasks::PlayerObject Type. They're two different object types.


Bot vehicles, such as the horse

Bot vehicles, such as the horse

They don't necessarily have “Vehicle“ in their datablock name.
For example, horseArmor.