Jump to content

Help With cars


Recommended Posts

You're probably always using the car-handle you get back in 4@ in some car-related opcode after this call.

 

The problem is that when there is no car near you, the content of 4@ is left untouched with by that opcode.

What you need to do, it assign a specific value to 4@ before you call that opcode, e.g. -1

and after the opcode, test the value of 4@, if it still contains -1, he didn't find a car, if it is not -1,

it will contain a valid car-handle and you can safely call a car-related opcode with it.

Link to comment
https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060341338
Share on other sites

sure:

 

4@ = -10AB5: store_actor $PLAYER_ACTOR closest_vehicle_to 4@ closest_ped_to $_UNUSED_RANDOM_ACTORif NOT 4@ == -1then    //do something with 4@  e.g.    car.SetToPsychoDriver(4@)end

 

Link to comment
https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060341382
Share on other sites

You can use 03co: to get the players car-handle and compare against that one: (untested btw tounge.gif )

 

03C0: 5@ = actor $PLAYER_ACTOR car 4@ = -10AB5: store_actor $PLAYER_ACTOR closest_vehicle_to 4@ closest_ped_to $_UNUSED_RANDOM_ACTORif and NOT 4@ == -1NOT 4@ == 5@then   //do something with 4@  e.g.   car.SetToPsychoDriver(4@)end

 

 

Link to comment
https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060341433
Share on other sites

PatrickW, I think that won´t work. The player´s car is the nearest car everytime. This script will jump back everytime, it just can´t get any other car... the script is only preventing the effects on the car.

 

Instead of getting the nearest car, I would recommend you using a "sphere" around your car.

 

03C0: 5@ = actor $PLAYER_ACTOR car 0407: store_coords_to 20@ 21@ 22@ from_car 5@ with_offset 0.0 0.0 0.0073E: get_car_in_sphere 20@ 21@ 22@ radius 10.0 model -1 handle_as 4@if andNOT 4@ == -1NOT 4@ == 5@then...

 

That script now detects a random car in a space around your car with radius 10.0. It may still get your car, but there´s a chance now that there will be "got" others. You can set the radius you like.

 

BTW, wouldn´t it be easier to check if a car exists with that opcode?!

 

056E:   car 4@ defined

 

 

03C0: 5@ = actor $PLAYER_ACTOR car 0407: store_coords_to 20@ 21@ 22@ from_car 5@ with_offset 0.0 0.0 0.0073E: get_car_in_sphere 20@ 21@ 22@ radius 10.0 model -1 handle_as 4@if and056E:   car 4@ definedNOT 4@ == 5@then...

 

Link to comment
https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060341856
Share on other sites

Actually, I think bennington has a very valid point there. It's been a long time since I experimented with the "get random car in sphere" opcodes, but they should be able to pickup other cars that the one the player is in currently, even if the sphere or rectangle is centered around the player.

Link to comment
https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060342118
Share on other sites

What if you first detected the player's car, gave that a name, used sphere technique, and did something like this (raw idea, not real code)

 

:firstpartplayer_char car == @15gosub @nextpart:nextpart//all that stuff you talked aboutif NOT car_in_sphere=@15jump_if_false @firstpart // or "if car is players jump to start"//do whatever

 

Wouldn't that theoretically make sure the player car was unaffected/undetected?

Link to comment
https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060342128
Share on other sites

 

What if you first detected the player's car, gave that a name, used sphere technique, and did something like this (raw idea, not real code)

 

:firstpartplayer_char car == @15gosub @nextpart:nextpart//all that stuff you talked aboutif NOT car_in_sphere=@15jump_if_false @firstpart // or "if car is players jump to start"//do whatever

 

Wouldn't that theoretically make sure the player car was unaffected/undetected?

That´s exactly what we were talking about. We didn´t give it a name but stored it in a variable. The problem is following:

That script is always storing the player´s car, because of the check if it´s the player´s car, the script restarts and gets the player car again and so on...

Looks like this:

 

:PART103C0: 5@ = actor $PLAYER_ACTOR car4@ = -10AB5: store_actor $PLAYER_ACTOR closest_vehicle_to 4@ closest_ped_to 6@ //GETS PLAYER CAR IN 4@ EVERYTIMEif andNOT 4@ == -1NOT 4@ == 5@ //FALSE, BECAUSE IT´S THE PLAYER CARjump_if_false PART1jump PART2:PART2//do something with that car

 

 

Are you understanding what I mean?

We need an option that excludes the player car from the beginning.

 

EDIT:

@barking

Please stop double-posting. And use punctuation, I´m not able to decipher even half of the things you write.

Edited by Bennington
Link to comment
https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060343029
Share on other sites

 

That´s exactly what we were talking about. We didn´t give it a name but stored it in a variable. The problem is following:

That script is always storing the player´s car, because of the check if it´s the player´s car, the script restarts and gets the player car again and so on...

Looks like this:

 

:PART103C0: 5@ = actor $PLAYER_ACTOR car4@ = -10AB5: store_actor $PLAYER_ACTOR closest_vehicle_to 4@ closest_ped_to 6@ //GETS PLAYER CAR IN 4@ EVERYTIMEif andNOT 4@ == -1NOT 4@ == 5@ //FALSE, BECAUSE IT´S THE PLAYER CARjump_if_false PART1jump PART2:PART2//do something with that car

 

 

Are you understanding what I mean?

We need an option that excludes the player car from the beginning.

 

EDIT:

@barking

Please stop double-posting. And use punctuation, I´m not able to decipher even half of the things you write.

Oh, okay. I missed the " if NOT" part- I script with opcodes, so I don't always catch all the variables. blush.gif

 

Although wouldn't that theoretically make it abandon the script, as it'll always find the player car first and then restart the script? Just a never ending cycle of checking, without changing. We need to, like, either place a bunch of spheres around the vehicle, and check if there was anything in any one, or make it completely disregard the player car as a vehicle. facedesk.gif

Link to comment
https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060343106
Share on other sites

Oh, okay. I missed the " if NOT" part- I script with opcodes, so I don't always catch all the variables. blush.gif

 

Although wouldn't that theoretically make it abandon the script, as it'll always find the player car first and then restart the script? Just a never ending cycle of checking, without changing. We need to, like, either place a bunch of spheres around the vehicle, and check if there was anything in any one, or make it completely disregard the player car as a vehicle. facedesk.gif

No prob, I´m actually coding with opcodes only, too turn.gif

 

That´s a great idea biggrin.gif We could maybe 4 to 8 spheres around the player´s car, but it will be elaborate...

 

Barking, what exactly are you needing the script for? Maybe we could find an alternate way to solve that problem?

Link to comment
https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060343140
Share on other sites

i need a code that will get only empty cars without drivers like petric gave me but it will not take cars with players in(drivers)the car while im on foot

btw if u will find with him the code that will not effect on my car so on other car post it here please

Link to comment
https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060343164
Share on other sites

If that's so, we should make a HUGE sphere of the entire map and detect all vehicles, then delete all drivers but player_char.

 

 

:code1ifplayer_char in_vehiclejump_if_false@code1gosub@code2:code2//detect all drivers and delete eachdriverguy==@14if NOT@14=player_charjump_if_false@code2delete_guy = @14gosub@code1

 

Edited by fireguy109
Link to comment
https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060343182
Share on other sites

Barking, you´re repeating yourself too often... and you seem to have barely patience. Sometimes replies aren´t coming quickly.

And it´s complete bullsh*t that you created a new topic, we can try to find a solution in this one, you don´t have to if another problems appears...

 

What do you like to do with that empty cars?

Link to comment
https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060344226
Share on other sites

to teleport her to me

i just need the code like petick gave me but i want to get only empty cars without a driver while i use this opcode:

0AB5: store_actor $PLAYER_ACTOR closest_vehicle_to 6@ closest_ped_to $_UNUSED_RANDOM_ACTOR

Edited by barking
Link to comment
https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060344228
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 0 User Currently Viewing
    0 members, 0 Anonymous, 0 Guests

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.