Quantcast

Jump to content

» «
Photo

CLEO car spawn help

19 replies to this topic
lpgunit
  • lpgunit

    It's L, as in Lpgunit, not I.

  • Feroci Racing
  • Joined: 24 May 2008
  • Philippines

#1

Posted 12 October 2008 - 11:51 AM

OK, so I experimented a car spawn CLEO script that I saw in this board, since I don't feel like altering the original SCM files. The syntax goes like this, much like the vehicle spawn script in the MAIN.SCM files:

CODE

{$CLEO .cs}
// GTA SAN ANDREAS CAR SPAWNER
014B: 1@ = init_parked_car_generator #STAFFORD color -1 -1 1 alarm 0 door_lock 0 0 10000 at 2491.173 -1681.651 13.33686 angle 88.6415
014C: set_parked_car_generator 1@ cars_to_generate_to 101
0A95: enable_thread_saving
0A93: end_custom_thread


The problem is that when I try to add a license plate string (one of which taken from Deji's custom SCMs), the game crashes. Is there a proper way of spawning a car with a number plate in CLEO?

OrionSR
  • OrionSR

    Chain Game Development Team

  • Members
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#2

Posted 12 October 2008 - 08:37 PM Edited by OrionSR, 12 October 2008 - 08:42 PM.

The code below is the plated version of the code you were using.
CODE
09E2: 1@ = parked_car_generator_w_numberplate #STAFFORD -1 -1 0 alarm 50 door_lock 0 0 10000 plate "_SHERM__" at 2491.173 -1681.651 13.33686 angle 88.6415


However, these are not standard spawn car codes. These codes create a new parked car generator that will be added permanently to the save file so anytime you drive by that location the car should spawn. If you run these codes again you'll add yet another car to the map. Add too many cars and the generator pool will become full and cars won't spawn as reliably. If you add new generators then you should find a way to flag the script so that it only creates the car once. The maximum custom plates that can be created with 09E2: is 15. 11 are used by the standard game.

Check in to some of these other spawn car codes. The process is a little more complicated, but offers considerable more control over the vehicle. This isn't a working code segment, it's a sample of some of the codes you can use when spawning cars. The lines unrelated to your stated goals are commented. You'll need to create a loop for the model available condition to get this working correctly. There are plenty of examples in the standard scripts to work from.
CODE
0247: load_model #STAFFORD
038B: load_requested_models
0248:   model #STAFFORD available  //  If Condition <-- make the script loop until model is loaded
//0506: set_car_model 0 next_variation -1 -1
0674: set_car_model #STAFFORD numberplate "_ASSMAN_"
00A5: 1@ = create_car #STAFFORD at 2491.173 -1681.651 13.33686
0175: set_car 1@ Z_angle_to 88.6415
//02AC: set_car 1@ immunities BP 0 FP 0 EP 0 CP 0 MP 0
//0229: set_car 1@ primary_color_to 51 secondary_color_to 73
//0A11: set_car 1@ tertiary_color_to 83 quaternary_color_to 0
//06E7: 0@ = add_car_component #WHEEL_SR5 to_car 1@ // load model before using
//01C3: remove_references_to_car 1@ // Like turning a car into any random car
0249: release_model #STAFFORD

lpgunit
  • lpgunit

    It's L, as in Lpgunit, not I.

  • Feroci Racing
  • Joined: 24 May 2008
  • Philippines

#3

Posted 12 October 2008 - 10:56 PM

QUOTE (OrionSR @ Oct 12 2008, 20:37)
The code below is the plated version of the code you were using.
CODE
09E2: 1@ = parked_car_generator_w_numberplate #STAFFORD -1 -1 0 alarm 50 door_lock 0 0 10000 plate "_SHERM__" at 2491.173 -1681.651 13.33686 angle 88.6415


However, these are not standard spawn car codes. These codes create a new parked car generator that will be added permanently to the save file so anytime you drive by that location the car should spawn. If you run these codes again you'll add yet another car to the map. Add too many cars and the generator pool will become full and cars won't spawn as reliably. If you add new generators then you should find a way to flag the script so that it only creates the car once. The maximum custom plates that can be created with 09E2: is 15. 11 are used by the standard game.

Check in to some of these other spawn car codes. The process is a little more complicated, but offers considerable more control over the vehicle. This isn't a working code segment, it's a sample of some of the codes you can use when spawning cars. The lines unrelated to your stated goals are commented. You'll need to create a loop for the model available condition to get this working correctly. There are plenty of examples in the standard scripts to work from.
CODE
0247: load_model #STAFFORD
038B: load_requested_models
0248:   model #STAFFORD available  //  If Condition <-- make the script loop until model is loaded
//0506: set_car_model 0 next_variation -1 -1
0674: set_car_model #STAFFORD numberplate "_ASSMAN_"
00A5: 1@ = create_car #STAFFORD at 2491.173 -1681.651 13.33686
0175: set_car 1@ Z_angle_to 88.6415
//02AC: set_car 1@ immunities BP 0 FP 0 EP 0 CP 0 MP 0
//0229: set_car 1@ primary_color_to 51 secondary_color_to 73
//0A11: set_car 1@ tertiary_color_to 83 quaternary_color_to 0
//06E7: 0@ = add_car_component #WHEEL_SR5 to_car 1@ // load model before using
//01C3: remove_references_to_car 1@ // Like turning a car into any random car
0249: release_model #STAFFORD

Thanks, but how do I do that? Any looping examples?

pietjuh
  • pietjuh

    I make old, crappy cars.

  • Members
  • Joined: 23 Jul 2004

#4

Posted 13 October 2008 - 06:55 AM

CODE
thread 'GREN'

:GREN_11
wait 0
if
Player.Defined($PLAYER_CHAR)
else_jump @GREN_11
if and
not Actor.Dead($PLAYER_ACTOR)
84AD: not actor $PLAYER_ACTOR in_water
Actor.Driving($PLAYER_ACTOR)
else_jump @GREN_11
if and
84A7: not actor $PLAYER_ACTOR driving_boat
84A9: not actor $PLAYER_ACTOR driving_heli
not Actor.DrivingPlane($PLAYER_ACTOR)
else_jump @GREN_11

:GREN_220
Model.Destroy(#GRENADE)
0108: destroy_object 7@
Car.RemoveReferences(0@)
Actor.SetImmunities($PLAYER_ACTOR, 0, 0, 0, 0, 0)
jump @GREN_11


This code does not have anything to do with car spawning and it is not mine, but it shows a loop. The end of the thread says go back to :GREN_11 so the script keeps running.

OrionSR
  • OrionSR

    Chain Game Development Team

  • Members
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#5

Posted 13 October 2008 - 08:25 AM

Yes. As I mentioned, there are lots of examples in the default scripts. Here's one of the simplest examples I managed find.

CODE
:SYN1_345
Model.Load(#MTBIKE)
038B: load_requested_models

:SYN1_352
if
  not Model.Available(#MTBIKE)
jf @SYN1_379
wait 0
jump @SYN1_352

:SYN1_379
386@ = Car.Create(#MTBIKE, 387@, 388@, 389@)
Car.Angle(386@) = 390@

lpgunit
  • lpgunit

    It's L, as in Lpgunit, not I.

  • Feroci Racing
  • Joined: 24 May 2008
  • Philippines

#6

Posted 13 October 2008 - 09:55 AM Edited by lpgunit, 13 October 2008 - 09:58 AM.

QUOTE (OrionSR @ Oct 13 2008, 08:25)
Yes. As I mentioned, there are lots of examples in the default scripts. Here's one of the simplest examples I managed find.

CODE
:SYN1_345
Model.Load(#MTBIKE)
038B: load_requested_models

:SYN1_352
if
  not Model.Available(#MTBIKE)
jf @SYN1_379
wait 0
jump @SYN1_352

:SYN1_379
386@ = Car.Create(#MTBIKE, 387@, 388@, 389@)
Car.Angle(386@) = 390@

Sorry, but I still don't get it. The bike spawn syntax seems fine, but what about the plate syntax?

OrionSR
  • OrionSR

    Chain Game Development Team

  • Members
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#7

Posted 13 October 2008 - 09:15 PM

I might tweak a line or two but I'm not going to write your code for you. Try experimenting with what you've got and check into the scripts or other cleo mods if you get stuck.

lpgunit
  • lpgunit

    It's L, as in Lpgunit, not I.

  • Feroci Racing
  • Joined: 24 May 2008
  • Philippines

#8

Posted 13 October 2008 - 11:53 PM

QUOTE (OrionSR @ Oct 13 2008, 21:15)
I might tweak a line or two but I'm not going to write your code for you. Try experimenting with what you've got and check into the scripts or other cleo mods if you get stuck.

You mean, like, use the plated version:

CODE
09E2: 1@ = parked_car_generator_w_numberplate #STAFFORD -1 -1 0 alarm 50 door_lock 0 0 10000 plate "_SHERM__" at 2491.173 -1681.651 13.33686 angle 88.6415


And then loop it? Or modify the code segment that you gave to me? Thanks, but if it still doesn't work, I'll probably resort to SCM editing...

OrionSR
  • OrionSR

    Chain Game Development Team

  • Members
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#9

Posted 14 October 2008 - 12:48 AM

Nope, don't loop the car generator code. That'll create way too many car generators, and all of them in the same place. That code will work fine as long as you only use it once for each car to be created, you don't use those codes again if you save the changes, and you don't try to add more than 4 more cars with plates.

lpgunit
  • lpgunit

    It's L, as in Lpgunit, not I.

  • Feroci Racing
  • Joined: 24 May 2008
  • Philippines

#10

Posted 14 October 2008 - 09:55 AM

QUOTE (OrionSR @ Oct 14 2008, 00:48)
Nope, don't loop the car generator code. That'll create way too many car generators, and all of them in the same place. That code will work fine as long as you only use it once for each car to be created, you don't use those codes again if you save the changes, and you don't try to add more than 4 more cars with plates.

So I'll just make the generator run just once? Hmm, it seems as though I should've used the STAFFRD code instead of STAFFORD.

How about this?

CODE

09E2: $STF = parked_car_generator_w_numberplate #STAFFRD alarm 50 door_lock  0  0  10000 plate "TEXTHERE" at 2491.173 -1681.651 13.33686 angle 88.6415
014C: set_parked_car_generator $STF cars_to_generate_to  50

OrionSR
  • OrionSR

    Chain Game Development Team

  • Members
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#11

Posted 14 October 2008 - 10:13 AM

Strange, #STAFFORD is working fine for me.

CODE
09E2: $STF = parked_car_generator_w_numberplate #STAFFRD alarm 50 door_lock  0  1  10000 plate "TEXTHERE" at 2491.173 -1681.651 13.33686 angle 88.6415


I turned on the force spawn flag in the line above. The car will spawn more reliably, especially if located near a hideout.

CODE
014C: set_parked_car_generator $STF cars_to_generate_to  50


If I understand this code correctly (and I haven't tested this so I'm not really sure) then your vehicle will spawn 50 times and then stop generating new cars. You'll want to set it to 101 if you want it to always be available.

The problem with getting your code to only run once per save is that if you leave that script in the cleo folder then it will run every time you load a save or start the game. If you have already added the car once to that save, then you will have two, and next time perhaps three. It can be managed but you will need to be careful.

lpgunit
  • lpgunit

    It's L, as in Lpgunit, not I.

  • Feroci Racing
  • Joined: 24 May 2008
  • Philippines

#12

Posted 14 October 2008 - 11:42 AM

QUOTE (OrionSR @ Oct 14 2008, 10:13)
Strange, #STAFFORD is working fine for me.

CODE
09E2: $STF = parked_car_generator_w_numberplate #STAFFRD alarm 50 door_lock  0  1  10000 plate "TEXTHERE" at 2491.173 -1681.651 13.33686 angle 88.6415


I turned on the force spawn flag in the line above. The car will spawn more reliably, especially if located near a hideout.

CODE
014C: set_parked_car_generator $STF cars_to_generate_to  50


If I understand this code correctly (and I haven't tested this so I'm not really sure) then your vehicle will spawn 50 times and then stop generating new cars. You'll want to set it to 101 if you want it to always be available.

The problem with getting your code to only run once per save is that if you leave that script in the cleo folder then it will run every time you load a save or start the game. If you have already added the car once to that save, then you will have two, and next time perhaps three. It can be managed but you will need to be careful.

OK, thanks. Maybe I'll try it when I run the other PC.

_CP_
  • _CP_

    Group: Vice City Stories team

  • Members
  • Joined: 27 Dec 2007
  • Poland
  • Best Map 2013 "ViceCityStories PC Edition"

#13

Posted 14 October 2008 - 01:45 PM

I use this opcode to make plate with my idea.
CODE
0674: set_car_model #your_car_model numberplate "your_name_plate"

coin-god
  • coin-god

    High Roller

  • $outh $ide Hoodz
  • Joined: 18 Mar 2007

#14

Posted 14 October 2008 - 06:37 PM

QUOTE (City_Poke912 @ Oct 14 2008, 10:45)
I use this opcode to make plate with my idea.
CODE
0674: set_car_model #your_car_model numberplate "your_name_plate"

What is so difficult about this?
Ive been looking at this thread for 4 days and still see no progress. Just use this code City_Poke shows you, and it will work.

wink.gif

lpgunit
  • lpgunit

    It's L, as in Lpgunit, not I.

  • Feroci Racing
  • Joined: 24 May 2008
  • Philippines

#15

Posted 14 October 2008 - 10:48 PM

QUOTE (goin-god @ Oct 14 2008, 18:37)
QUOTE (City_Poke912 @ Oct 14 2008, 10:45)
I use this opcode to make plate with my idea.
CODE
0674: set_car_model #your_car_model numberplate "your_name_plate"

What is so difficult about this?
Ive been looking at this thread for 4 days and still see no progress. Just use this code City_Poke shows you, and it will work.

wink.gif

OK, noted. Oh, and is it only a single line of code? How about the coordinates?

OrionSR
  • OrionSR

    Chain Game Development Team

  • Members
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#16

Posted 15 October 2008 - 12:00 AM

Okay, one more try.

Take that mt bike code and change the SYN1 labels to something else, it doesn't matter what as long as they are unique.
Change the 38x@ local variables to your coordinates.
Compile and run the code, see if it spawns a Mt Bike.
If so, then change the models to the Stafford and compile and run again.
If that works, then try that plate line just before creating the car.

If you run into trouble it might be because the vehicle is too far away from CJ when it spawns. Try using the cleo example of showsavescreen to save near those coordinates. You may also consider adapting the showsavescreen code to spawn your car. Change the key code line to look for F3 or F5 instead of F4, and then replace the show save screen line with your code. Then whenever you press that button your vehicle should spawn. Later you can replace the keypress line for a check of when CJ is in that area.

megaaj02
  • megaaj02

    Player Hater

  • Members
  • Joined: 05 Apr 2011

#17

Posted 28 April 2011 - 09:52 AM Edited by megaaj02, 28 April 2011 - 09:59 AM.

QUOTE (OrionSR @ Oct 14 2008, 10:13)
Strange, #STAFFORD is working fine for me.

CODE
09E2: $STF = parked_car_generator_w_numberplate #STAFFRD alarm 50 door_lock  0  1  10000 plate "TEXTHERE" at 2491.173 -1681.651 13.33686 angle 88.6415


I turned on the force spawn flag in the line above. The car will spawn more reliably, especially if located near a hideout.

CODE
014C: set_parked_car_generator $STF cars_to_generate_to  50


If I understand this code correctly (and I haven't tested this so I'm not really sure) then your vehicle will spawn 50 times and then stop generating new cars. You'll want to set it to 101 if you want it to always be available.

The problem with getting your code to only run once per save is that if you leave that script in the cleo folder then it will run every time you load a save or start the game. If you have already added the car once to that save, then you will have two, and next time perhaps three. It can be managed but you will need to be careful.

I've made a script of generating a car with a custom plate number but I can't seems to make it work... the code is:
CODE
09E2: $WASHING = init_parked_car_generator_w_numberplate #WASHING 0 0 0 alarm 0 door_lock 0 0 10000 plate "_VEDAD__" at 2424.242 -1635.456 13.314 angle 0.0
014C: set_parked_car_generator $WASHING cars_to_generate_to 101
0A95: enable_thread_saving
0A93: end_custom_thread


please reply what have I've bin doing wrong?

OrionSR
  • OrionSR

    Chain Game Development Team

  • Members
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#18

Posted 28 April 2011 - 11:02 AM Edited by OrionSR, 28 April 2011 - 11:11 AM.

These codes worked for me. I changed out your global variable for a local variable (0@) since user defined globals in a CLEO script is a very bad idea. You never know what game variables you might be writing over, or how the game might alter your variables. I doubt that was the problem though; still I don't even want to test a code with globals in it. I also change the "force spawn" flag to 1 (before alarm) so the car would spawn without having to leave the area and return.

CODE
09E2: 0@ = init_parked_car_generator_w_numberplate #WASHING 0 0 1 alarm 0 door_lock 0 0 10000 plate "_VEDAD__" at 2424.242 -1635.456 13.314 angle 0.0
014C: set_parked_car_generator 0@ cars_to_generate_to 101


Perhaps it isn't working because you tried several variations of the script and now there are several copies of your car in that location. The thread saving should have prevented that. Try again on a fresh save. Also, 11 of the 15 custom plates are used. If you've already created 4 then the plates won't show up for the 5th.

megaaj02
  • megaaj02

    Player Hater

  • Members
  • Joined: 05 Apr 2011

#19

Posted 29 April 2011 - 01:39 AM Edited by megaaj02, 29 April 2011 - 04:08 AM.

QUOTE (OrionSR @ Apr 28 2011, 11:02)
These codes worked for me. I changed out your global variable for a local variable (0@) since user defined globals in a CLEO script is a very bad idea. You never know what game variables you might be writing over, or how the game might alter your variables. I doubt that was the problem though; still I don't even want to test a code with globals in it. I also change the "force spawn" flag to 1 (before alarm) so the car would spawn without having to leave the area and return.

CODE
09E2: 0@ = init_parked_car_generator_w_numberplate #WASHING 0 0 1 alarm 0 door_lock 0 0 10000 plate "_VEDAD__" at 2424.242 -1635.456 13.314 angle 0.0
014C: set_parked_car_generator 0@ cars_to_generate_to 101


Perhaps it isn't working because you tried several variations of the script and now there are several copies of your car in that location. The thread saving should have prevented that. Try again on a fresh save. Also, 11 of the 15 custom plates are used. If you've already created 4 then the plates won't show up for the 5th.

Thanks for the tip... I'll edit this reply after I've tested it.... [{Edit: It works perfectly!! biggrin.gif Thanks....}] [{Edit2: PS. How can I make the car in the parked car generator w numperplate invulnerable, like bulletproof, fireproof, collisionproof, and explosionproof. Particularly, Everything Proof.

OrionSR
  • OrionSR

    Chain Game Development Team

  • Members
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#20

Posted 29 April 2011 - 04:34 AM Edited by OrionSR, 29 April 2011 - 04:37 AM.

You can't add immunities to a car generator. However, it is possible to simulate a car generator with a CLEO script that spawns a car when CJ is near. It's a fairly complicated process. I recommend reading a coding tutorial that describes the process. ZAZ has a pretty good one.

http://www.gtaforums...howtopic=403594




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users