#1 09-05-2008 21:51

Eyon
Registered: 03-03-2008
Posts: 7

Put_trailer on_cab

I have some code here:

{$CLEO}
0A95: enable_thread_saving

if
    0@ == 0
then
    014B: 1@ = init_parked_car_generator #petro color -1 -1 1 alarm 0 door_lock 0 0 10000 at 1648.537 -1068.407 24.378 angle 180.0
    014C: set_parked_car_generator 1@ cars_to_generate_to 101
    014B: 2@ = init_parked_car_generator #petrotr color -1 -1 1 alarm 0 door_lock 0 0 10000 at 1648.537 -1059.974 24.378 angle 180.0
    014C: set_parked_car_generator 2@ cars_to_generate_to 101

wait 10
0893: put_trailer 2@ on_cab 1@
    
    0@ = 1
end
0A93: end_custom_thread

But the trailer isn't attaching to the cabine. I'm trying to create a mass spawn for trucks, but as long this ain't working, I can't get it offcourse. So can anyone tell what I'm doing wrong?

Offline

#2 10-05-2008 09:44

Seemann
Registered: 07-08-2006
Posts: 2,065

Re: Put_trailer on_cab

opcode 014B does not create a vehicle instantly. You need to use 00A5 to create a truck & trailer, and then attach the trailer with 0893. Search for examples of using 00A5.

Also, your script is executed only once. To make a mass spawn you need an endless loop, I think.

Offline

#3 10-05-2008 16:36

Eyon
Registered: 03-03-2008
Posts: 7

Re: Put_trailer on_cab

Seemann wrote:

opcode 014B does not create a vehicle instantly. You need to use 00A5 to create a truck & trailer, and then attach the trailer with 0893. Search for examples of using 00A5.

Thanks for the help.

Seemann wrote:

Also, your script is executed only once. To make a mass spawn you need an endless loop, I think.

Yes, I know. But I'm trying to spawn one truck to test this. If it works, I'm going to create an endless loop.

Offline

#4 19-05-2008 20:21

Eyon
Registered: 03-03-2008
Posts: 7

Re: Put_trailer on_cab

{$CLEO .cs}
   0A95: enable_thread_saving

if
   0@ == 0
then
   00A5: 1@ = create_car #petro at 1648.537 -1068.407 24.378 angle 180.0
   00A5: 2@ = create_car #petrotr at 1648.537 -1059.974 24.378 angle 180.0  
wait 10
   0893: put_trailer 2@ on_cab 1@
   
   0@ = 1
end
   0A93: end_custom_thread

Well, got this, but GTA still crashes.

{$CLEO .cs}
    0A95: enable_thread_saving

if
    0@ == 0
then
    00A5: $1 = create_car #petrotr at 1648.537 1068.407 24.378 angle 180.0 
    wait 500
    00A5: $2 = create_car #petro at 1648.537 -1068.407 24.378 angle 180.0   
    wait 10
    0893: put_trailer $1 on_cab $2
    
    0@ = 1
end
    0A93: end_custom_thread

I also tried this, but still doesn't work.

Offline

#5 20-05-2008 14:56

Yarik
Registered: 22-02-2008
Posts: 173
Website

Re: Put_trailer on_cab

Does it work?

{$CLEO}
0A95: enable_thread_saving

    014B: 1@ = init_parked_car_generator #petro color -1 -1 1 alarm 0 door_lock 0 0 10000 at 1648.537 -1068.407 24.378 angle 180.0
    014C: set_parked_car_generator 1@ cars_to_generate_to 101
    014B: 2@ = init_parked_car_generator #petrotr color -1 -1 1 alarm 0 door_lock 0 0 10000 at 1648.537 -1059.974 24.378 angle 180.0
    014C: set_parked_car_generator 2@ cars_to_generate_to 101

wait 10
0893: put_trailer 2@ on_cab 1@
    


0A93: end_custom_thread

Maybe you need longer WAIT ?

Offline

#6 20-05-2008 15:14

Seemann
Registered: 07-08-2006
Posts: 2,065

Re: Put_trailer on_cab

You didn't load models #petro and #petrotr before create a car. And the first variant is better, as it uses local variables.

Offline

#7 20-05-2008 16:23

Eyon
Registered: 03-03-2008
Posts: 7

Re: Put_trailer on_cab

Yarik wrote:

Does it work?

{$CLEO}
0A95: enable_thread_saving

    014B: 1@ = init_parked_car_generator #petro color -1 -1 1 alarm 0 door_lock 0 0 10000 at 1648.537 -1068.407 24.378 angle 180.0
    014C: set_parked_car_generator 1@ cars_to_generate_to 101
    014B: 2@ = init_parked_car_generator #petrotr color -1 -1 1 alarm 0 door_lock 0 0 10000 at 1648.537 -1059.974 24.378 angle 180.0
    014C: set_parked_car_generator 2@ cars_to_generate_to 101

wait 10
0893: put_trailer 2@ on_cab 1@
    


0A93: end_custom_thread

Maybe you need longer WAIT ?

This script works half. I get no crash, but it's only spawning the cab, not even the trailer.

{$CLEO}
0A95: enable_thread_saving

    014B: 1@ = init_parked_car_generator #petrotr color -1 -1 1 alarm 0 door_lock 0 0 10000 at 1648.537 -1068.407 24.378 angle 180.0
    014C: set_parked_car_generator 1@ cars_to_generate_to 101
    wait 100
    014B: 2@ = init_parked_car_generator #petro color -1 -1 1 alarm 0 door_lock 0 0 10000 at 1648.537 -1068.407 24.378 angle 180.0
    014C: set_parked_car_generator 2@ cars_to_generate_to 101

wait 100
0893: put_trailer 1@ on_cab 2@
    


0A93: end_custom_thread

Doesn't spawn me a cab, but just the trailer.

Also tried loading the models before spawning them, but it's no go.

I attached a screenshot, using the Yarik's script.

Edit: Added 2nd screenshot. As you can see, cab and trailer are spawning right now, but nothing happens to attatching.

Last edited by Eyon (20-05-2008 16:51)

Offline

#8 30-08-2008 17:37

Eyon
Registered: 03-03-2008
Posts: 7

Re: Put_trailer on_cab

I still don't have the scripts working. Even when using 00A5 as opcode. Maybe someone can provide a working script?

Offline

#9 30-08-2008 19:55

Threepwood
Registered: 09-03-2008
Posts: 5

Re: Put_trailer on_cab

I can't help you with the code itself, because it looks good to me. But if you want, go to gta-action.com and take look at ZAZ's Truck+Trailer in Traffic Script (inside his CLEO Thread), he does what you want to archive. But iirc he takes a random car from traffic, places it for his needs and changes the model. Before attaching he sets visibility to 0.

Take a look inside, thats the way I learn best, maybe it helps you, too.

regards, Threep

Offline

#10 15-09-2008 15:56

3Doomer
From: КаZан
Registered: 14-05-2008
Posts: 659
Website

Re: Put_trailer on_cab

Opcode 014B: creates a handle for not cars but for the GENERATOR of cars.
For this reason cars are not linked using 0893:

Last edited by 3Doomer (15-09-2008 21:16)


GIMS developer

Offline

#11 15-09-2008 16:15

XotaBi4b
From: Харьков
Registered: 13-09-2008
Posts: 87

Re: Put_trailer on_cab

first of all

Model.Load(#petro)
Model.Load(#petrotr)
wait 200
038B: load_requested_models

00A5: 4@ = create_car 514 at x  y z
00A5: 5@ = create_car 584 at x  y z

................. Other Code ....

Model.Destroy(#petro)
Model.Destroy(#petrotr)

But i think you have more mistakes than i show you.

Last edited by XotaBi4b (15-09-2008 16:17)

Offline

Board footer

Powered by FluxBB