Glenstorm Posted February 18, 2010 Share Posted February 18, 2010 Simple as the topic sounds, I need to spawn a car... a RANDOM car at a position. How do I code the RANDOM part of the script? I mean is there a get_random_car blah blah opcode? P.S. this should work even if there are no other cars in the vicinity Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/ Share on other sites More sharing options...
dtd mods Posted February 18, 2010 Share Posted February 18, 2010 Simple as the topic sounds, I need to spawn a car... a RANDOM car at a position. How do I code the RANDOM part of the script? I mean is there a get_random_car blah blah opcode? P.S. this should work even if there are no other cars in the vicinity :CAR_504 0001: wait 0 ms 0004: $CRIMINAL_CAR = -1 04C4: store_coords_to $LC1 $LC2 $LC3 from_actor $PLAYER_ACTOR with_offset 0.0 0.0 0.0 073E: get_car_in_sphere $LC1 $LC2 $LC3 radius 34.0 model -1 handle_as $CRIMINAL_CAR 00D6: if 8038: not $CRIMINAL_CAR == -1 004D: jump_if_false @CAR_504 Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059785721 Share on other sites More sharing options...
H4milton Posted February 18, 2010 Share Posted February 18, 2010 Use a trainer, search for GTA SA Crazytrainer 151+ in google. www.thegtaplace.com has it. It can spawn 5 different cars for you. And, you can even change it in game. Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059785722 Share on other sites More sharing options...
Glenstorm Posted February 18, 2010 Author Share Posted February 18, 2010 QUOTE (Glenstorm @ Feb 18 2010, 11:45)Simple as the topic sounds, I need to spawn a car... a RANDOM car at a position. How do I code the RANDOM part of the script? I mean is there a get_random_car blah blah opcode? P.S. this should work even if there are no other cars in the vicinity :CAR_504 0001: wait 0 ms 0004: $CRIMINAL_CAR = -1 04C4: store_coords_to $LC1 $LC2 $LC3 from_actor $PLAYER_ACTOR with_offset 0.0 0.0 0.0 073E: get_car_in_sphere $LC1 $LC2 $LC3 radius 34.0 model -1 handle_as $CRIMINAL_CAR 00D6: if 8038: not $CRIMINAL_CAR == -1 004D: jump_if_false @CAR_504 Can you explain how that works? I need a complete random spawn, not specific,for example like the firefighter or vigilante missions Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059785736 Share on other sites More sharing options...
dtd mods Posted February 18, 2010 Share Posted February 18, 2010 QUOTE (Glenstorm @ Feb 18 2010, 11:45)Simple as the topic sounds, I need to spawn a car... a RANDOM car at a position. How do I code the RANDOM part of the script? I mean is there a get_random_car blah blah opcode? P.S. this should work even if there are no other cars in the vicinity :CAR_504 0001: wait 0 ms 0004: $CRIMINAL_CAR = -1 04C4: store_coords_to $LC1 $LC2 $LC3 from_actor $PLAYER_ACTOR with_offset 0.0 0.0 0.0 073E: get_car_in_sphere $LC1 $LC2 $LC3 radius 34.0 model -1 handle_as $CRIMINAL_CAR 00D6: if 8038: not $CRIMINAL_CAR == -1 004D: jump_if_false @CAR_504 Can you explain how that works? I need a complete random spawn, not specific,for example like the firefighter or vigilante missions what do u need to do Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059785745 Share on other sites More sharing options...
gtasearcher Posted February 18, 2010 Share Posted February 18, 2010 (edited) There'd ya go. var  $PLAYER_CHAR: player  $PLAYER_ACTOR: actor  0@: car  1@: int  2@: int  3@: float  4@: float  5@: float  6@: float  7@: float  8@: float  9@: float  10@: float  11@: float  20@: float  21@: int  22@: carendconst  RND_A = 3@  RND_X = 4@  RND_Y = 5@  RND_Z = 6@  VAN_X = 7@  VAN_Y = 8@  VAN_Z = 9@  RND_SINE = 10@  RND_COSINE = 11@  VAN_A = 20@  CARM = 21@  CAR = 22@endwhile true  wait 0  Actor.StorePos($PLAYER_ACTOR, RND_X, RND_Y, RND_Z)  RND_A = random(0.0, 180.0)  02F7: RND_SINE = sine RND_A // (float)  02F6: RND_COSINE = cosine RND_A // (float)  RND_A = random(250.0, 600.0)  RND_SINE *= RND_A          RND_A = random(250.0, 600.0)  RND_COSINE *= RND_A  RND_X += RND_SINE  RND_Y += RND_COSINE  03D3: get_route_nearest_for RND_X RND_Y RND_Z store_to VAN_X VAN_Y VAN_Z Z_angle_to VAN_A   if    00C2:  sphere_onscreen VAN_X VAN_Y VAN_Z radius 5.0  then    continue  end    CARM = random(#LANDSTAL, #UTILTR1)  Model.Load(CARM)  while not Model.Available(CARM)    wait 0  end  Car.Create(CAR, VAN_X, VAN_Y, VAN_Z)  Car.Angle(CAR) = VAN_A  0587: enable_car CAR validate_position 0   Model.Destroy(CARM) breakend Edited February 18, 2010 by gtasearcher Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059785758 Share on other sites More sharing options...
Glenstorm Posted February 18, 2010 Author Share Posted February 18, 2010 There'd ya go.var  $PLAYER_CHAR: player  $PLAYER_ACTOR: actor  0@: car  1@: int  2@: int  3@: float  4@: float  5@: float  6@: float  7@: float  8@: float  9@: float  10@: float  11@: float  20@: float  21@: int  22@: carendconst  RND_A = 3@  RND_X = 4@  RND_Y = 5@  RND_Z = 6@  VAN_X = 7@  VAN_Y = 8@  VAN_Z = 9@  RND_SINE = 10@  RND_COSINE = 11@  VAN_A = 20@  CARM = 21@  CAR = 22@endwhile true  wait 0  Actor.StorePos($PLAYER_ACTOR, RND_X, RND_Y, RND_Z)  RND_A = random(0.0, 180.0)  02F7: RND_SINE = sine RND_A // (float)  02F6: RND_COSINE = cosine RND_A // (float)  RND_A = random(250.0, 600.0)  RND_SINE *= RND_A          RND_A = random(250.0, 600.0)  RND_COSINE *= RND_A  RND_X += RND_SINE  RND_Y += RND_COSINE  03D3: get_route_nearest_for RND_X RND_Y RND_Z store_to VAN_X VAN_Y VAN_Z Z_angle_to VAN_A   if    00C2:  sphere_onscreen VAN_X VAN_Y VAN_Z radius 5.0  then    continue  end    CARM = random(#LANDSTAL, #UTILTR1)  Model.Load(CARM)  while not Model.Available(CARM)    wait 0  end  Car.Create(CAR, VAN_X, VAN_Y, VAN_Z)  Car.Angle(CAR) = VAN_A  0587: enable_car CAR validate_position 0   Model.Destroy(CARM) breakend how do i choose only those random vehicles that are not flying, boat, or cars like utilitr1? Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059785765 Share on other sites More sharing options...
james227uk Posted February 18, 2010 Share Posted February 18, 2010 gtasearcher just over complicates things. Also, no idea what those random A's are. And also, random(,) doesn't even register for me, just throws up errors Find a way of creating a random car, then use this :104C4: store_coords_to 1@ 2@ 3@ from_actor $PLAYER_ACTOR with_offset 0.0 25.0 1.0 04D3: get_nearest_car_path_coords_from 1@ 2@ 3@ type 2 store_to 1@ 2@ 3@wait 1000create random car Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059785880 Share on other sites More sharing options...
gtasearcher Posted February 18, 2010 Share Posted February 18, 2010 gtasearcher just over complicates things. Also, no idea what those random A's are. Those random 'A's or how you call them are used for sines and cosines - it's safer than the usual 'offset' method. Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059785908 Share on other sites More sharing options...
james227uk Posted February 18, 2010 Share Posted February 18, 2010 (edited) Sanny doesn't agree with them Nor does it agree with random(,) Edited February 18, 2010 by james227uk Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059785917 Share on other sites More sharing options...
gtasearcher Posted February 18, 2010 Share Posted February 18, 2010 (edited) Sanny doesn't agree with them Uh, excuse me James, that's YOUR problem, not mine. It's a bug in some browsers - will put those random characters instead of tabs/spaces. Edited February 18, 2010 by gtasearcher Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059785918 Share on other sites More sharing options...
james227uk Posted February 18, 2010 Share Posted February 18, 2010 Uh, excuse you, that's YOUR problem. 4 different browsers all display the same. Firefox, IE, Opera, Chrome Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059785923 Share on other sites More sharing options...
gtasearcher Posted February 18, 2010 Share Posted February 18, 2010 (edited) Uh, excuse me, my browser displays it correctly. And that's Firefox 3.6 Edited February 18, 2010 by gtasearcher Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059785927 Share on other sites More sharing options...
james227uk Posted February 18, 2010 Share Posted February 18, 2010 Excuse me, but what's your browser then? EDIT: To put the nail to it's coffin IE - http://i178.photobucket.com/albums/w265/james227uk/IE.png Firefox - http://i178.photobucket.com/albums/w265/ja...7uk/firefox.png Chrome - http://i178.photobucket.com/albums/w265/ja...27uk/chrone.png Opera - http://i178.photobucket.com/albums/w265/james227uk/opera.png 4 of the most well know and most common updated browsers displaying it incorrectly? I don't think so, as I said, those images put the nail to the coffin Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059785939 Share on other sites More sharing options...
gtasearcher Posted February 18, 2010 Share Posted February 18, 2010 Ok, this is strange. My firefox displays it correctly http://i49.tinypic.com/2zivwk1.jpg And my IE does not http://i48.tinypic.com/688pjt.jpg Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059785953 Share on other sites More sharing options...
NTAuthority Posted February 18, 2010 Share Posted February 18, 2010 (edited) Ok, this is strange. My firefox displays it correctly http://i49.tinypic.com/2zivwk1.jpg And my IE does not http://i48.tinypic.com/688pjt.jpg It's an encoding bug with GTAF, and almost always occurs to me whenever a post containing tabs is quoted - it replaces those things in front of tabs. The fact that it works differently might be due to a different locale setting, a different GTAF theme, or other. My browser also shows the 'A with accent' symbols. You shouldn't blame gtasearcher for it. EDIT: the characters are 'C2 A0', where U+00C2 is the A and U+00A0 is a non-breaking space in ASCII. This conversion issue seems to occur more often than only on GTAF, and is caused by applications incorrectly converting 20 20/20 A0 to C2 A0 in UTF-8, which coincides with these characters in ASCII, and a 'non-breaking space' in UTF-8. gtasearcher, you likely have your browser hardconfigured to UTF-8, which might be due to a special language. Edited February 18, 2010 by NTAuthority Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059785981 Share on other sites More sharing options...
Glenstorm Posted February 18, 2010 Author Share Posted February 18, 2010 So.... uh.. Any working ideas how to get random cars, or at least model IDs? (no planes, boats, trailers) Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059785996 Share on other sites More sharing options...
ZAZ Posted February 18, 2010 Share Posted February 18, 2010 So.... uh.. Any working ideas how to get random cars, or at least model IDs? (no planes, boats, trailers) read Scripting/Writing a Thread the subtheme: Spawn a 3D model Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059786025 Share on other sites More sharing options...
Glenstorm Posted February 18, 2010 Author Share Posted February 18, 2010 I guess ppl are confused with the question. Let me rephrase it. In order to spawn a car, there are basically two steps 1. Load car model 2. Create car with the loaded model Now, if I want to create a random car model, I would focus on the model since there is no spawn_random_car opcode in CLEO Since CLEO allows a model IDs to be numbers (400 instead of #LANDSTAL) it opens up a possible way. I can use the following method to continue 0@ = <get random number between 400 and 611> load_model 0@ blah blah ... But in the mod I'm making I only want cars that run on the road, and which can be driven. Therefore, boats, vortex, planes, choppers and other models like the truck trailers etc... is to be omitted when random number is generated. Since I have been unable to find a shortcut way (apart from creating the car and checking it, which is time consuming from script's point of view), I was obliged to create a list of numbers which should be invalidated, from GGMM. This is what I made: :Get_Modelwait 0 ms0209: 0@ = random_int_in_ranges 400 612if and 0@ <> 416 . . . 0@ <> 441jf @Get_Model //Only 9 conditions per ifif and 0@ <> 450 . . . 0@ <> 500jf @Get_Model... Please do not put the above in Sannybuilder and compile. It's just illustration This will manually check for unwanted cars and get another number if invalidated. If number found valid, the script will proceed to spawn it. But for some weird reason, this if thing does not work, I've got boats to RC planes spawning where it's only supposed to be cars. What's wrong? Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059786051 Share on other sites More sharing options...
Glenstorm Posted February 18, 2010 Author Share Posted February 18, 2010 <Forget this post. Accidently posted the same thing twice> Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059786057 Share on other sites More sharing options...
Deji Posted February 18, 2010 Share Posted February 18, 2010 Back2Basics... You can create random car park cars with this... 03C5: create_random_car_for_carpark 2077.872 2398.657 9.8203 z_angle 89.6383 To load a random model, whilst ensuring it is a certain type: :LOOPwait 00209: 0@ = random_int_in_ranges 400 611if and 881E: not model 0@ boat // make sure the model is not a boat. 8820: not model 0@ heli // and not a heli. 881F: not model 0@ plane // and not a plane. // Add lines like this to specify that the car can not be a certain model ID/Name... //8039: not model 0@ == #AMBULAN // Make sure it has 4 wheels? // 0A01: model 0@ minimum_4wheels_vehicleelse_jump @LOOP0247: load_model 0@while 8248: not model 0@ available wait 0end00A5: 1@ = create_car 0@ at 0.0 0.0 0.0 8039: not model 1@ == #AMBULAN - simply checks the random number and makes sure it isn't a specified value. Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059786373 Share on other sites More sharing options...
Glenstorm Posted February 19, 2010 Author Share Posted February 19, 2010 Back2Basics... You can create random car park cars with this... 03C5: create_random_car_for_carpark 2077.872 2398.657 9.8203 z_angle 89.6383 To load a random model, whilst ensuring it is a certain type: :LOOPwait 00209: 0@ = random_int_in_ranges 400 611if and 881E: not model 0@ boat // make sure the model is not a boat. 8820: not model 0@ heli // and not a heli. 881F: not model 0@ plane // and not a plane. // Add lines like this to specify that the car can not be a certain model ID/Name... //8039: not model 0@ == #AMBULAN // Make sure it has 4 wheels? // 0A01: model 0@ minimum_4wheels_vehicleelse_jump @LOOP0247: load_model 0@while 8248: not model 0@ available wait 0end00A5: 1@ = create_car 0@ at 0.0 0.0 0.0 8039: not model 1@ == #AMBULAN - simply checks the random number and makes sure it isn't a specified value. Yes, that's what I was looking for.. Thanks a bunch Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059786835 Share on other sites More sharing options...
H4milton Posted February 19, 2010 Share Posted February 19, 2010 This edits the .scm file right? and you have to start a new game, isn't it? Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059786841 Share on other sites More sharing options...
Glenstorm Posted February 19, 2010 Author Share Posted February 19, 2010 Can be used for CLEO too. In that case no need of new game Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059786937 Share on other sites More sharing options...
ZAZ Posted February 19, 2010 Share Posted February 19, 2010 This edits the .scm file right? and you have to start a new game, isn't it? A Cleo script file get then the file extension, which is written in the Cleo Script directive at the beginning of the script {$CLEO .cs} = Cleo directive will be compiled to *.cs if not, sanny compiles the script as main.scm read CLEO Script Tutorial Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059787267 Share on other sites More sharing options...
ZAZ Posted February 21, 2010 Share Posted February 21, 2010 My firefox displays it correctly http://i49.tinypic.com/2zivwk1.jpg And my IE does not http://i48.tinypic.com/688pjt.jpg It's an encoding bug with GTAF, and almost always occurs to me whenever a post containing tabs is quoted - it replaces those things in front of tabs. The fact that it works differently might be due to a different locale setting, a different GTAF theme, or other. My browser also shows the 'A with accent' symbols. EDIT: the characters are 'C2 A0', where U+00C2 is the A and U+00A0 is a non-breaking space in ASCII. This conversion issue seems to occur more often than only on GTAF, and is caused by applications incorrectly converting 20 20/20 A0 to C2 A0 in UTF-8, which coincides with these characters in ASCII, and a 'non-breaking space' in UTF-8. gtasearcher, you likely have your browser hardconfigured to UTF-8, which might be due to a special language. terrible, now I have it also first I thought it's caused by gtasearchers browser yesterday night I posted a script here and it looked fine now I have it in all my posted scripts I have question marks at Tab positions I believe I had a firefox update in the last 2 days and hey, gtasearchers script of first page looks now clean for me I can correct the wrong display by set the coding to westlich (ISO-8859-1) but I must do it for each page Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059790614 Share on other sites More sharing options...
NTAuthority Posted February 21, 2010 Share Posted February 21, 2010 I can correct the wrong display by set the coding to westlich (ISO-8859-1)but I must do it for each page Until GTAForums fixes it, the Firefox options contain a 'default encoding' setting hidden somewhere deep. Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059790617 Share on other sites More sharing options...
ZAZ Posted February 21, 2010 Share Posted February 21, 2010 I can correct the wrong display by set the coding to westlich (ISO-8859-1)but I must do it for each page Until GTAForums fixes it, the Firefox options contain a 'default encoding' setting hidden somewhere deep. you mean settings>content>advanced:charackter encoding? it was allready set to west(ISO 8859-1) a bug of the last firefox update? I hope gtaf can fix it Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059790636 Share on other sites More sharing options...
Deji Posted February 21, 2010 Share Posted February 21, 2010 I'm sure UTF-8 is supposed to be a universal. Odd thing is... GTAForums doesn't specify a character encoding... Which I'm sure is bad XHTML-ing Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059790939 Share on other sites More sharing options...
dtd mods Posted February 23, 2010 Share Posted February 23, 2010 zaz rocks Link to comment https://gtaforums.com/topic/441089-how-to-spawn-cars/#findComment-1059792601 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