Jump to content

Help with my first code


Recommended Posts

Hey guys, I have been looking at other peoples work and tutorials and stuff having a look at how mission scripting works. Here is my first attempt:

 

 

:TRANSME03A4: name_thread 'TRANSME':TRANSME_LOOP0001: wait 0 ms00D6: if 00EC: actor $PLAYER_ACTOR 1 near_point 2494.9304 -1651.0594 13.4839 radius 8.0 8.0 004D: jump_if_false @TRANSME_LOOP0247: request_model #TURISMO0247: request_model #ARMY0247: request_model #BFYRI038B: load_requested_models:TRANSME_10001: wait 100 ms00D6: if and0248:   model #TURISMO available 0248:   model #ARMY available0248:   model #BFYRI available004D: jump_if_false @TRANSME_100A5: 1@ = create_car #TURISMO at 2346.6755 -1657.5316 12.76280129: 0@ = create_actor 5 #ARMY in_car 1@ driverseat 009A: 2@ = create_actor 4 #BFYRI at 2492.2068 -1630.8121 13.40190249: release_model #TURISMO 0249: release_model #ARMY02C2: car 1@ drive_to_point  2464.5347 -1660.1932 12.927202C2: car 1@ drive_to_point  2483.7095 -1653.2235 13.0690002: jump @TRANSME_2:TRANSME_20001: wait 5000 ms05CA: action_sequence actor 2@ enter_car 1@ passenger_seat 0 10000 ms00D6: if 0431:   car 1@ car_passenger_seat_free 1004D: jump_if_false @TRANSME_202C2: car 1@ drive_to_point  2355.7578 -1661.1049 13.02301C3: remove_references_to_car 1@01C2: remove_references_to_actor 0@01C2: remove_references_to_actor 2@0001: wait 5000 ms0002: jump @TRANSME_LOOP

 

 

The idea of the script is when I enter my big red thingo a car dives up, a woman exits the alley and hops in the car and for it to drive away (after that become a regular ped). It sorta semi works lol

 

Could you guys tell me what I did wrong

Thanks smile.gif

Link to comment
https://gtaforums.com/topic/274174-help-with-my-first-code/
Share on other sites

For the first try, it looks really good. What doesn't work exactly?

 

1. In TRANSME_2, you have 2 5 seconds WAITs. You only need it once, the one in the second to last line is unnecessary.

2. The jump to TRANSME_2 is unnecessary, as that's the next piece of code the game would execute anyways.

3. Why the two 02C2 opcodes one after the other in TM_1?

4. In TRANSME_2, add a check if the car is at the point you want it to be, that makes the huge wait unnecessary. (You can then use a 'normal' wait time, but the code won't be fully executed if the car gets obstructed and can't show up at that point. Look at the cutscene code of the original game to see how R* 'circumvented' that problem)

4b. The huge wait means that the actor or the car could be destroyed or killed in the meantime. You should include checks for that.

5. Why are you only releasing two of the models? What about #BFYRI?

6. The loop in the last label makes the actor perform the 'enter' animation repeatedly. It has to be in a seperate label (that otherwise consists of the 'is_car_where_I_want_it_to_be' check)

 

 

 

:TRANSME_10001: wait 100 ms00D6: if and0248:   model #TURISMO available0248:   model #ARMY available0248:   model #BFYRI available004D: jump_if_false @TRANSME_100A5: 1@ = create_car #TURISMO at 2346.6755 -1657.5316 12.76280129: 0@ = create_actor 5 #ARMY in_car 1@ driverseat009A: 2@ = create_actor 4 #BFYRI at 2492.2068 -1630.8121 13.40190249: release_model #TURISMO0249: release_model #ARMY0249: release_model #BFYRI02C2: car 1@ drive_to_point  2464.5347 -1660.1932 12.9272 //which one?02C2: car 1@ drive_to_point  2483.7095 -1653.2235 13.069  //:TRANSME_1Await 100 msif00B1:  is_car_in_cube  ........or00B0: is_car_in_rect .........jf @TRANSME_1A05CA: action_sequence actor 2@ enter_car 1@ passenger_seat 0 10000 ms:TRANSME_20001: wait 500 ms00D6: if0431:   car 1@ car_passenger_seat_free 1004D: jump_if_false @TRANSME_202C2: car 1@ drive_to_point  2355.7578 -1661.1049 13.02301C3: remove_references_to_car 1@01C2: remove_references_to_actor 0@01C2: remove_references_to_actor 2@0002: jump @TRANSME_LOOP

 

Edited by SteaVor
Link to comment
https://gtaforums.com/topic/274174-help-with-my-first-code/#findComment-4173092
Share on other sites

 

For the first try, it looks really good. What doesn't work exactly?

 

1. In TRANSME_2, you have 2 5 seconds WAITs. You only need it once, the one in the second to last line is unnecessary.

2. The jump to TRANSME_2 is unnecessary, as that's the next piece of code the game would execute anyways.

3. Why the two 02C2 opcodes one after the other in TM_1?

4. In TRANSME_2, add a check if the car is at the point you want it to be, that makes the huge wait unnecessary. (You can then use a 'normal' wait time, but the code won't be fully executed if the car gets obstructed and can't show up at that point. Look at the cutscene code of the original game to see how R* 'circumvented' that problem)

4b. The huge wait means that the actor or the car could be destroyed or killed in the meantime. You should include checks for that.

5. Why are you only releasing two of the models? What about #BFYRI?

6. The loop in the last label makes the actor perform the 'enter' animation repeatedly. It has to be in a seperate label (that otherwise consists of the 'is_car_where_I_want_it_to_be' check)

 

 

 

:TRANSME_10001: wait 100 ms00D6: if and0248:   model #TURISMO available0248:   model #ARMY available0248:   model #BFYRI available004D: jump_if_false @TRANSME_100A5: 1@ = create_car #TURISMO at 2346.6755 -1657.5316 12.76280129: 0@ = create_actor 5 #ARMY in_car 1@ driverseat009A: 2@ = create_actor 4 #BFYRI at 2492.2068 -1630.8121 13.40190249: release_model #TURISMO0249: release_model #ARMY0249: release_model #BFYRI02C2: car 1@ drive_to_point  2464.5347 -1660.1932 12.9272 //which one?02C2: car 1@ drive_to_point  2483.7095 -1653.2235 13.069  //:TRANSME_1Await 100 msif00B1:  is_car_in_cube  ........or00B0: is_car_in_rect .........jf @TRANSME_1A05CA: action_sequence actor 2@ enter_car 1@ passenger_seat 0 10000 ms:TRANSME_20001: wait 500 ms00D6: if0431:   car 1@ car_passenger_seat_free 1004D: jump_if_false @TRANSME_202C2: car 1@ drive_to_point  2355.7578 -1661.1049 13.02301C3: remove_references_to_car 1@01C2: remove_references_to_actor 0@01C2: remove_references_to_actor 2@0002: jump @TRANSME_LOOP

 

Thanks for that!! smile.gif

Link to comment
https://gtaforums.com/topic/274174-help-with-my-first-code/#findComment-4173261
Share on other sites

That's the format of 00B0 - is_car_in_rect:

$carID, X1, Y1, X2, Y2, int (0)

X1/Y1 marks the bottom left corner of the rectangle, X2/Y2 the upper right.

 

But that's not the best solution for your problem (I just skimmed your code quickly, so that's what came to my mind the first time)

In your code example, an easier way would be

00EE: is_actor_near_point_in_car

$actorID, 0, X1, Y1 radius R1, R2 (distance from the specified point in X/Y direction)

 

For your code the line could go like this:

00EE: actor 0@ 0 (always 0) 2483.7095 -1653.2235 radius 5.0 5.0

Mess with the values to make them fit.

Edited by SteaVor
Link to comment
https://gtaforums.com/topic/274174-help-with-my-first-code/#findComment-4173518
Share on other sites

Ok cool, I just tried it then. This is what happens:

 

Car drives and stops (as expected) then the girl runs our of alley (as expected) then when she gets close to the car she dosn't use the door she kinda teleports into it, then the car stands still.

 

Why could this be happening?

Link to comment
https://gtaforums.com/topic/274174-help-with-my-first-code/#findComment-4173565
Share on other sites

That's happening because there's not enough time for the animation to be fully executed. Try fiddling with the last parameter of 05CA.

 

Also you have passenger_seat 0 in 05CA and passenger_seat 1 in the check 0431. To be honest, I don't know much about these opcodes as I've never used them, but this could very well be the reason that the car doesn't drive away (because the condition can never be TRUE).

Edited by SteaVor
Link to comment
https://gtaforums.com/topic/274174-help-with-my-first-code/#findComment-4173582
Share on other sites

I got it working smile.gifsmile.gif w00t it's 2:46 am and I got it working.

 

Thanks for you help dude!!

 

To get it working I made the "check passanger" into a "not" and made and "if check" to see if the car had finished its mission.

 

 

:TRANSME_LOOP0001: wait 0 ms00D6: if 00EC: actor $PLAYER_ACTOR 1 near_point 2494.9304 -1651.0594 13.4839 radius 8.0 8.0 004D: jump_if_false @TRANSME_LOOP0247: request_model #TURISMO0247: request_model #ARMY0247: request_model #BFYRI038B: load_requested_models:TRANSME_10001: wait 100 ms00D6: if and0248:   model #TURISMO available0248:   model #ARMY available0248:   model #BFYRI available004D: jump_if_false @TRANSME_100A5: 1@ = create_car #TURISMO at 2346.6755 -1657.5316 12.76280129: 0@ = create_actor 5 #ARMY in_car 1@ driverseat009A: 2@ = create_actor 4 #BFYRI at 2492.2068 -1630.8121 13.40190249: release_model #TURISMO0249: release_model #ARMY0249: release_model #BFYRI02C2: car 1@ drive_to_point  2464.5347 -1660.1932 12.927202C2: car 1@ drive_to_point  2483.7095 -1653.2235 13.069  :TRANSME_1Await 100 ms00D6: if 00EE: actor 0@ 0 2483.7095 -1653.2235 radius 5.0 5.0004D: jump_if_false @TRANSME_1A 05CA: action_sequence actor 2@ enter_car 1@ passenger_seat 0 50000 ms:TRANSME_20001: wait 500 ms00D6: if8431:   car 1@ car_passenger_seat_free 0004D: jump_if_false @TRANSME_2:TRANSME_30001: wait 100 ms02C2: car 1@ drive_to_point  2355.7578 -1661.1049 13.02300D6: if00EE: actor 0@ 0 2355.7578 -1661.1049 13.023 radius 3.0 3.0004D: jump_if_false @TRANSME_301C3: remove_references_to_car 1@01C2: remove_references_to_actor 0@01C2: remove_references_to_actor 2@0002: jump @TRANSME_LOOP

 

Link to comment
https://gtaforums.com/topic/274174-help-with-my-first-code/#findComment-4173709
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.