Quantcast

Jump to content

» «
Photo

[Q]

6 replies to this topic
stef538
  • stef538

    It's just me, going 88 MPH.

  • Members
  • Joined: 06 Oct 2012
  • Netherlands

#1

Posted 05 May 2014 - 04:14 PM Edited by stef538, 05 May 2014 - 04:43 PM.

Hey guys, do you know how to select every vehicle, but not the player's vehicle ?

 

Also I apologize for the title, I don't know why it only shows [Q]


julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#2

Posted 05 May 2014 - 04:44 PM

world.getVehicles or world.getAllVehicles and inside a For you check if vehicle still exists and if is not player currentVehicle

also make a title that identifies the question :)

obs.: becarefull when using those methods, they can result in lag if used wrong


stef538
  • stef538

    It's just me, going 88 MPH.

  • Members
  • Joined: 06 Oct 2012
  • Netherlands

#3

Posted 05 May 2014 - 04:48 PM Edited by stef538, 05 May 2014 - 04:48 PM.

But how to make it check that it isn't player.currentvehicle ?

 

i have this :

 

                foreach (GTA.Vehicle ExplodeCars in World.GetAllVehicles())
                {
                  ExplodeCars.Explode();
                }


pedro2555
  • pedro2555

    Open Sourcer

  • Members
  • Joined: 02 Sep 2012
  • Portugal

#4

Posted 05 May 2014 - 05:02 PM Edited by pedro2555, 05 May 2014 - 05:02 PM.

But how to make it check that it isn't player.currentvehicle ?

 

i have this :

 

                foreach (GTA.Vehicle ExplodeCars in World.GetAllVehicles())
                {
                  ExplodeCars.Explode();
                }

 

Seriously ?

foreach (Vehicle v in World.GetAllVehicles())
    if (v.Exists() && v != Player.Character.CurrentVehicle)
        v.Explode();

stef538
  • stef538

    It's just me, going 88 MPH.

  • Members
  • Joined: 06 Oct 2012
  • Netherlands

#5

Posted 05 May 2014 - 06:06 PM

yeah, and that still makes my car explode...


julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#6

Posted 05 May 2014 - 07:58 PM

you are doing something wrong, this requires just basic logic to ignore your car, remember that not always we test the code we paste here, its the logic and methods that matters,  you should made your own code based on the answer

  • pedro2555 likes this

LordOfTheBongs
  • LordOfTheBongs

    Deceased

  • Members
  • Joined: 21 Sep 2013
  • None

#7

Posted 06 May 2014 - 02:09 PM Edited by LordOfTheBongs, 06 May 2014 - 04:34 PM.

yeah, and that still makes my car explode...

the code he posted only prevents your car from exploding if you are driving it... i havent tested but add a check for Player.LastVehicle so u prevent explosion to your car even if u get out.

foreach (Vehicle v in World.GetAllVehicles())
    if (v.Exists() && v != Player.Character.CurrentVehicle && v != Player.LastVehicle)
        v.Explode();




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users