barking Posted February 16, 2011 Share Posted February 16, 2011 I tried to create a cleo but every time that there is no any car near me the game crashes there is any code that will fix it? btw i am using to find a car with this code 0AB5: store_actor $PLAYER_ACTOR closest_vehicle_to 4@ closest_ped_to $_UNUSED_RANDOM_ACTOR Link to comment https://gtaforums.com/topic/469815-help-with-cars/ Share on other sites More sharing options...
PatrickW Posted February 16, 2011 Share Posted February 16, 2011 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 More sharing options...
barking Posted February 16, 2011 Author Share Posted February 16, 2011 can u give me an example im not so understanding Link to comment https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060341374 Share on other sites More sharing options...
PatrickW Posted February 16, 2011 Share Posted February 16, 2011 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 More sharing options...
barking Posted February 16, 2011 Author Share Posted February 16, 2011 oh and by the way there is any code that if i press a key it will effect not on my car while i am the driver so it will effect the car that near me not on mine? Link to comment https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060341391 Share on other sites More sharing options...
PatrickW Posted February 16, 2011 Share Posted February 16, 2011 You can use 03co: to get the players car-handle and compare against that one: (untested btw ) 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 More sharing options...
barking Posted February 16, 2011 Author Share Posted February 16, 2011 hmm i am very tankful about your help but when i trying to compile this code:NOT 4@ == 5@ its says that is inccorcet Link to comment https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060341444 Share on other sites More sharing options...
PatrickW Posted February 16, 2011 Share Posted February 16, 2011 ooh, my bad, sanny isn't able to figure that one out on its own. Try this instead: 803b: not 4@ == 5@ Link to comment https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060341462 Share on other sites More sharing options...
barking Posted February 16, 2011 Author Share Posted February 16, 2011 well ty its working but while i am in car its not moving the cars near me but if im on foot it is any way to do this while i am driving? Link to comment https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060341466 Share on other sites More sharing options...
barking Posted February 16, 2011 Author Share Posted February 16, 2011 someone? Link to comment https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060341841 Share on other sites More sharing options...
Bennington Posted February 16, 2011 Share Posted February 16, 2011 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 More sharing options...
TheSiggi Posted February 16, 2011 Share Posted February 16, 2011 If you use a sphere around the players car, the players car will be in the center of it which brings up the same problem again no, the defined opcodes are weird so checking if its not 0 is the best way. if its undefined its zero. Link to comment https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060341875 Share on other sites More sharing options...
PatrickW Posted February 16, 2011 Share Posted February 16, 2011 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 More sharing options...
fireguy109 Posted February 17, 2011 Share Posted February 17, 2011 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 More sharing options...
barking Posted February 17, 2011 Author Share Posted February 17, 2011 oh i wonder if you can help me and ive me the code to not get car with a player?? Link to comment https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060342653 Share on other sites More sharing options...
barking Posted February 17, 2011 Author Share Posted February 17, 2011 (edited) someone please this is importent to me ''oh i wonder if you can help me and ive me the code to not get car with a player??'' Edited February 17, 2011 by barking Link to comment https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060343024 Share on other sites More sharing options...
Bennington Posted February 17, 2011 Share Posted February 17, 2011 (edited) 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 February 17, 2011 by Bennington Link to comment https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060343029 Share on other sites More sharing options...
barking Posted February 17, 2011 Author Share Posted February 17, 2011 benni sry for double but its the last double lo i need a code like you wrote but it will net take car with a driver/player while im on foot ty agein Link to comment https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060343054 Share on other sites More sharing options...
Bennington Posted February 17, 2011 Share Posted February 17, 2011 You´re still abandoning punctuation Double-posts BTW don´t make any sense if the last post is just from an hour ago. Did you try the script yet? Link to comment https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060343068 Share on other sites More sharing options...
barking Posted February 17, 2011 Author Share Posted February 17, 2011 i tried now but it crashed me any way can u give me a code tha will not a car with a driver player? btw its look like the first code that someone gave me up in the topic Link to comment https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060343088 Share on other sites More sharing options...
fireguy109 Posted February 17, 2011 Share Posted February 17, 2011 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. 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. Link to comment https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060343106 Share on other sites More sharing options...
Bennington Posted February 17, 2011 Share Posted February 17, 2011 Oh, okay. I missed the " if NOT" part- I script with opcodes, so I don't always catch all the variables. 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. No prob, I´m actually coding with opcodes only, too That´s a great idea 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 More sharing options...
barking Posted February 17, 2011 Author Share Posted February 17, 2011 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 More sharing options...
fireguy109 Posted February 17, 2011 Share Posted February 17, 2011 (edited) 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 February 17, 2011 by fireguy109 Link to comment https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060343182 Share on other sites More sharing options...
barking Posted February 18, 2011 Author Share Posted February 18, 2011 someone?? ''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'' Link to comment https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060343833 Share on other sites More sharing options...
Bennington Posted February 18, 2011 Share Posted February 18, 2011 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 More sharing options...
barking Posted February 18, 2011 Author Share Posted February 18, 2011 (edited) 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 February 18, 2011 by barking Link to comment https://gtaforums.com/topic/469815-help-with-cars/#findComment-1060344228 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now