Author Topic: Introduction to SCM coding VC\LC  (Read 28268 times)

0 Members and 2 Guests are viewing this topic.

Offline Dannye

  • Veteran Member
  • Posts: 3580
    • View Profile
Introduction to SCM coding VC\LC
« Reply #45 on: June 20, 2007, 04:58:30 PM »
This has nothing to do with the problems in the code, its just a few helpful hints.

When you create your own threads/labels, you can call them whatever the hell you want, it doesn't need to be "LabelXXXXXetc", you can make it words/letters, it makes the code much easier to read. Then when its compiled the compiler will handle the conversion from words into numbers for ya and you don't have to worry about it.

Also, when you are creating objects, you don't need to give them memory addresses like xxxx??, because again it just makes things harder to read, its much easier just to name them whatever the hell you want, as long as you start it with a "$". Again, the compiler will handle converting it to the next available memory address for ya. Sure, there are a few cases where you might choose to use the memory address method, but with most cases here using words would be easiest.

Here are a couple examples of what I mean:

Type of labels I use, see, just words are fine too, and as you can probably imagine from this, it makes code much easier to work with
00D6: if  0?
80E0:   NOT player $PLAYER_CHAR driving
004D: jump_if_false テつ」テつ」LABEL_CAR

Another example of word labels
00D6: if  21?                                    
80E1:   NOT key_pressed  0?  18?
80E1:   NOT key_pressed  0?  4?
004D: jump_if_false テつ」テつ」LABEL_GHOSTTOWN

You don't need to use xxxx??, you can use a normal word with a dollar sign in front ($Curr_Car). Its handy because if you use it alot in your code (as I obviously do for current car) its easy to remember, and makes the code easier to read
03C1: $Curr_Car = player $PLAYER_CHAR car

A different situation, here I need to store something which I will use in the next line, but never again afterwards, so instead of bothering using a handle like above, I just use a local variable (thats what the x@'s are)
04C4: create_coordinate  1@  2@  3@ from_actor $PLAYER_ACTOR offset -4!  3!  0!
00A5: 4@ = create_car #TAXI at  1@  2@  3@
« Last Edit: June 20, 2007, 04:59:31 PM by Dannye »

Offline DJS

  • Veteran Member
  • Posts: 755
  • Click my sig yo
    • View Profile
    • YouTubz
Introduction to SCM coding VC\LC
« Reply #46 on: June 21, 2007, 07:52:24 AM »
Dannye just confused me , i think its easier using numbers for some reason. You i see i put the numbers  +4 each time, do i need to do that because i seen neo put something about that in the first post :S. Thanks for fixing the script neo, hope it works

EDIT:   it didnt fix  . did the script work with you neo?

EDIT 2: i got the last guy moving (a lampost blocked him ) but the third guy to spawn still spawns weird [and he my guy also which is kinda bad ]
« Last Edit: June 21, 2007, 08:10:54 AM by DJS »

Offline JayFoxRox

  • Posts: 2221
    • View Profile
    • Homepage
Introduction to SCM coding VC\LC
« Reply #47 on: June 21, 2007, 08:51:55 AM »
Dannye you can also have full text labels. Also the # are predefined symbols

00D6: if 0?
80E0: NOT player $PLAYER_CHAR driving
004D: jump_if_false テつ」テつ」CAR_noticethatthelabeltextisnothere // This labelname might be too long for the compiler

Another example of word labels
00D6: if 21?
80E1: NOT key_pressed 0? 18?
80E1: NOT key_pressed 0? 4?
004D: jump_if_false テつ」テつ」GHOSTTOWN


For the # -> If you enter #PCJ600, the compiler checks what #PCJ600 stands for and dynamicly replaces them with the text found in the files you gave it. This means you haev the following choises too:

#PCJ600

OR

191

OR

0004: $MODELID = 191
and then use $MODELID instead of 191 or #PCJ600 - this is clever when you want to have a dynamic code or when you want to have the ability to change something easily. Sample (Without opcodes ):

$model = #PCJ600 // Enter model id here
:carspawner
if 0
model $model available
jif carspawnermodel
:carspawnerspawn
$car = create_car $model x y z
release model $model
jump carspawnerdone
:carspawnermodel
request model $model
load requested models
:carspawnerdone

//Edit:
Oh and dannye, try getting away from the local vars, they can be tricky in multithreaded scm sometimes.
each thread has 16 local variables (0 to 15). These can only be reached from the own thread and are deleted when the thread is CLOSED - not when you jump out!
You can use them to create functions:

create thread MylabelBlub 191 1 3 3 7

Now the 191 is in @0, 1 in @1, 3 in @2, 3 @3 and 7 in @4
You can create cool stuff with this. For a spawner for example:

:carspawner
if 0
model @0 available
jif carspawnermodel
:carspawnerspawn
$car = create_car @0 @1 @2 @3
set car $car z_angle to @4
set car $car color to @5 @6
release model @0
jump carspawnerdone
:carspawnermodel
request model @0
load requested models
:carspawnerdone
end_thread

and now to spawn a car you use:

create_thread <modelid> <x> <y> <z> <a> <c1> <c2>
 
since gta only looks at the opcode i would rename it to

create_car_with_model #PCJ600 at 100.0 150.0 14.0 with_angle 0.0 and_color 1 1

which would spawn a white PCJ. Now this is usefull to spawn alot of cars with only a few lines:

create_car_with_model #PCJ600 at 100.0 150.0 14.0 with_angle 0.0 and_color 1 1
create_car_with_model #FAGGIO at 110.0 150.0 14.0 with_angle 0.0 and_color 1 1
create_car_with_model #TAXI at 120.0 150.0 14.0 with_angle 0.0 and_color 1 1
create_car_with_model #INFERNUS at 130.0 150.0 14.0 with_angle 0.0 and_color 1 1

Also take note that my thread will load the model if its not loaded so far!
« Last Edit: June 21, 2007, 09:00:07 AM by Fox »

Offline DJS

  • Veteran Member
  • Posts: 755
  • Click my sig yo
    • View Profile
    • YouTubz
Introduction to SCM coding VC\LC
« Reply #48 on: June 21, 2007, 09:42:02 AM »
0211: actor 32?? exit car 404??   :S something wrong here it dont work  :/

Offline VenomX

  • Veteran Member
  • Posts: 4294
    • View Profile
Introduction to SCM coding VC\LC
« Reply #49 on: June 21, 2007, 09:45:23 AM »
^ Wrong opcode .

03E2: actor 32?? exit_car

You don't need to say which car they should exit, because there shouldn't be too much of a choice...unless you've done it VERY wrong .
« Last Edit: June 21, 2007, 09:46:08 AM by VenomX »

Offline JayFoxRox

  • Posts: 2221
    • View Profile
    • Homepage
Introduction to SCM coding VC\LC
« Reply #50 on: June 21, 2007, 12:16:58 PM »
DJS: you syntax is wrong. the actor handle should be stored in a variable (starting with an $)

Like:

$blub = create_actor
make_actor $blub leave_car

an actor as a number is weird

//Edit: Wrong info.. Sry my bad, the old var namings confused me..
« Last Edit: June 21, 2007, 12:18:10 PM by Fox »

Offline Neo Anderson

  • ATS precision whore
  • Veteran Member
  • Posts: 5079
  • Registered on: April 16, 2004
    • View Profile
Introduction to SCM coding VC\LC
« Reply #51 on: June 21, 2007, 02:10:27 PM »
Quote from: DJS
Dannye just confused me , i think its easier using numbers for some reason. You i see i put the numbers  +4 each time, do i need to do that because i seen neo put something about that in the first post :S. Thanks for fixing the script neo, hope it works

EDIT:   it didnt fix  . did the script work with you neo?

EDIT 2: i got the last guy moving (a lampost blocked him ) but the third guy to spawn still spawns weird [and he my guy also which is kinda bad ]

The label numbers can be anything,(though they do have to stay in order or your script will jump all over the place) I just try to jump a few numbers each time I make a new label is all.
I never ran your script because I'm not sure what things your not getting to happen right.
Tell me exactly what your tryin to do with your script and I'll check into it further for you.

Dannye and Fox, you guys are confusin even me with this stuff.   Like DJS said, numbers are just to simple to keep in order so I use those.
« Last Edit: June 21, 2007, 02:12:33 PM by Neo Anderson »

Offline Dannye

  • Veteran Member
  • Posts: 3580
    • View Profile
Introduction to SCM coding VC\LC
« Reply #52 on: June 21, 2007, 04:35:21 PM »
Haha fair enough then. To put it simply I was just saying that you didn't have to use numbers if you didn't want to, but seeing as you guys prefer it, you can ignore all the crap I wrote

Offline DJS

  • Veteran Member
  • Posts: 755
  • Click my sig yo
    • View Profile
    • YouTubz
Introduction to SCM coding VC\LC
« Reply #53 on: June 22, 2007, 08:08:36 AM »
Its ok Neo i fixed the problem i think  it works properly if my character is near him when he spawns for some reason . so im basicly dont except camera angles XD. Ill add you neo and venomx to the "thanks to" part at the end of the film. not sure to add dannye XD he just confused me ^^

Offline Neo Anderson

  • ATS precision whore
  • Veteran Member
  • Posts: 5079
  • Registered on: April 16, 2004
    • View Profile
Introduction to SCM coding VC\LC
« Reply #54 on: June 22, 2007, 02:27:25 PM »
Quote from: Dannye
Haha fair enough then. To put it simply I was just saying that you didn't have to use numbers if you didn't want to, but seeing as you guys prefer it, you can ignore all the crap I wrote

I'm not sayin it's "crap" man. But if it confused me, imagine how confusing it would be to someone who's just startin to learn. I'm just tryin to keep it as simple as possible for everyone. Any comments or suggestion you have for this tut are always welcome.  

Offline deVon

  • Posts: 141
    • View Profile
    • http://
Introduction to SCM coding VC\LC
« Reply #55 on: June 26, 2007, 05:42:09 AM »
Can anyone tell me what's wrong with this code ?
Because after the explosions, it starts over again.
DEFINE VERSION VICE 0.22

0002: jump テつ」テつ」Label008620
DEFINE MEMORY 34329

:Label008620
0002: jump テつ」テつ」Label008644
DEFINE OBJECTS 1
DEFINE OBJECT DOOR \\ This is an unused object. You can put anything here.

:Label008644
0002: jump テつ」テつ」Label008658
DEFINE MISSIONS 0

;-------------MAIN---------------


:Label008658
03A4: name_thread "MAIN"
016A: fade 0? () 0? ms
01F0: set_max_wanted_level_to 0?
03AD: toggle_rubbish 0?
03DE: set_pedestrians_density_multiplier_to 0?
01EB: set_car_density_to 0?
0111: set_wasted_busted_check_to 0? (disabled)
00C0: set_current_time 12? 0?
04E4: unknown_refresh_game_renderer_at 385.00! 239.00!
03CB: set_camera 385.00! 239.00! 11.43!
0053: $PLAYER_CHAR = create_player #NULL at 385.00! 239.00! 11.43!
01F5: $PLAYER_ACTOR = create_emulated_actor_from_player $PLAYER_CHAR
0330: set_player $PLAYER_CHAR infinite_run_to 1? (true)
0001: wait 0? ms
01B6: set_weather 5?
00D6: if 0?
8118: NOT actor $PLAYER_ACTOR dead
004D: jump_if_false テつ」テつ」Label0086EF
0352: set_actor $PLAYER_ACTOR skin_to "PLAYER"
038B: load_requested_models
0353: refresh_actor $PLAYER_ACTOR
0222: set_player 2228?? health_to 100!

:Label0086EF
016A: fade 1? (back) 1000& ms
00D6: if 0?
0256: player $PLAYER_CHAR defined
004D: jump_if_false テつ」テつ」Label0086EF
04BB: select_interiour 0? \\ select render area
01B4: set_player $PLAYER_CHAR frozen_state 0? (frozen)
01B7: release_weather

:Label008700
0001: wait 0& ms
0247: request_model #FREEWAY
0247: request_model #PCJ600
0247: request_model #UZI
0247: request_model #BFYBE
0247: request_model #TEC9
0247: request_model #BKA
0247: request_model #CHEETAH
0247: request_model #ARMY
00D6: if 0?
8248: NOT model #FREEWAY available
8248: NOT model #PCJ600 available
8248: NOT model #UZI available
8248: NOT model #BFYBE available
8248: NOT model #TEC9 available
8248: NOT model #BKA available
8248: NOT model #CHEETAH available
8248: NOT model #ARMY available
004D: jump_if_false テつ」テつ」Label008706
0001: wait 1000& ms
0002: jump テつ」テつ」Label008700

:Label008706
038B: load_requested_models
0001: wait 0& ms
0002: jump テつ」テつ」Label008711

:Label008711
0001: wait 0& ms
00A5: 400?? = create_car #PCJ600 at 338.58! 239.19! 11.37!
0175: set_car 400?? z_angle_to 270!
00AE: unknown_set_car 400?? to_ignore_traffic_lights 1?
00AD: set_car 400?? max_speed_to 0!
02AC: set_car 400?? immunities 1? 1? 1? 1? 1?
0129: 28?? = create_actor 4? #BFYBE in_car 400?? driverseat
01B2: give_actor 28?? weapon 22? ammo 100&
02E2: set_actor 28?? weapon_accuracy_to 99?
0350: unknown_actor 28?? not_scared_flag 1?
0002: jump テつ」テつ」Label008717

:Label008717
0001: wait 0& ms
00A5: 404?? = create_car #FREEWAY at 408.77! 239.58! 10.88!
0175: set_car 404?? z_angle_to 90!
00AE: unknown_set_car 404?? to_ignore_traffic_lights 1?
00AD: set_car 404?? max_speed_to 0!
02AC: set_car 404?? immunities 1? 1? 1? 1? 1?
0129: 32?? = create_actor 4? #BKA in_car 404?? driverseat
01B2: give_actor 32?? weapon 23? ammo 100&
02E2: set_actor 32?? weapon_accuracy_to 29?
0350: unknown_actor 32?? not_scared_flag 1?
0002: jump テつ」テつ」Label008745

:Label008745
0001: wait 0& ms
00A5: 4000?? = create_car #CHEETAH at 360.00! 239.30! 11.37!
0175: set_car 4000?? z_angle_to 90!
00AE: unknown_set_car 4000?? to_ignore_traffic_lights 1?
00AD: set_car 4000?? max_speed_to 0!
02AC: set_car 4000?? immunities 1? 1? 1? 1? 1?
0129: 9172?? = create_actor 4? #ARMY in_car 4000?? driverseat
01B2: give_actor 9172?? weapon 23? ammo 100&
02E2: set_actor 9172?? weapon_accuracy_to 99?
0350: unknown_actor 9172?? not_scared_flag 1?
0002: jump テつ」テつ」Label008722

:Label008722
0001: wait 2000& ms
0158: camera_on_vehicle 400?? 3? 2?
02C2: car 400?? drive_to_point 372.51! 238.48! 10.82!
00AD: set_car 400?? max_speed_to 10!
0001: wait 1000& ms
02C2: car 404?? drive_to_point 381.83! 241.16! 10.61!
00AD: set_car 404?? max_speed_to 10!
0001: wait 1000& ms
02C2: car 4000?? drive_to_point 360.00! 240.00! 11.00!
00AD: set_car 4000?? max_speed_to 10!
0002: jump テつ」テつ」Label008729

:Label008729
0001: wait 7000& ms
015F: set_camera_position 372.51! 244.48! 10.82! 0! 0! 0!
0160: point_camera 372.51! 238.48! 10.82! 1?
0460: set_camera_pointing_time 0! 5000&
0001: wait 5000& ms
03E2: actor 28?? exit_car
03E2: actor 32?? exit_car
03E2: actor 9172?? exit_car
0001: wait 3500& ms
0211: actor 28?? walk_to 368.27! 242.45!
0211: actor 32?? walk_to 385.78! 236.38!
015F: set_camera_position 372.51! 244.48! 10.82! 0! 0! 0!
0160: point_camera 385.78! 236.38! 10.82! 1?
0460: set_camera_pointing_time 0! 5000&
0001: wait 8000& ms
020E: actor 28?? look_at_actor 32??
020E: actor 32?? look_at_actor 28??
020E: actor 9172?? look_at_actor 28??
015F: set_camera_position 370.27! 241.45! 11.32! 0! 0! 0!
0160: point_camera 368.27! 242.45! 11.32! 2?
0460: set_camera_pointing_time 0! 2000&
0001: wait 2000& ms
015F: set_camera_position 384.08! 237.38! 10.82! 0! 0! 0!
0160: point_camera 385.78! 236.38! 10.82! 2?
0460: set_camera_pointing_time 0! 2000&
0001: wait 2000& ms
0002: jump テつ」テつ」Label008733

:Label008733
015F: set_camera_position 382.60! 252.15! 14.43! 0! 0! 0!
0160: point_camera 378.80! 243.15! 10.82! 2?
0460: set_camera_pointing_time 0! 5000&
0001: wait 4000& ms
01C9: actor 28?? kill_actor 32??
01C9: actor 9172?? kill_actor 28??
0002: jump テつ」テつ」Label008738

:Label008738
0001: wait 5000& ms
0159: camera_on_ped 9172?? 4? 2?
0001: wait 4000& ms
015F: set_camera_position 385.43! 237.43! 10.82! 0! 0! 0!
0160: point_camera 382.93! 237.43! 10.82! 2?
0460: set_camera_pointing_time 0! 5000&
0001: wait 4000& ms
015F: set_camera_position 385.43! 237.43! 10.82! 0! 0! 0!
0160: point_camera 382.93! 237.43! 9.82! 1?
0460: set_camera_pointing_time 0! 500&
0001: wait 2000& ms
0239: actor 9172?? run_to 372.51! 238.48!
0001: wait 1000& ms
01D5: actor 9172?? go_to_and_drive_car 400??
00AD: set_car 400?? max_speed_to 0!
0158: camera_on_vehicle 400?? 3? 2?
0001: wait 4500& ms
02C2: car 400?? drive_to_point 323.93! 240.77! 11.45!
00AD: set_car 400?? max_speed_to 30!
0001: wait 2000& ms
03E2: actor 9172?? exit_car
0159: camera_on_ped  9172??  4?  2?
0239: actor 9172?? run_to 375.00! 239.00!
0001: wait 1000& ms
020F: actor 9172?? look_at_player $PLAYER_CHAR
0002: jump テつ」テつ」Label008743

:Label008743
0001: wait 1000& ms
020B: explode_car 400??
020B: explode_car 404??
020B: explode_car 4000??
0321: kill_actor 9172??
0002: jump テつ」テつ」Label008744

:Label008744
0157: camera_on_player $PLAYER_CHAR  4?  2?
01B4: set_player $PLAYER_CHAR frozen_state 1? (unfrozen)
0002: jump テつ」テつ」Label008745

:Label008745
0001: wait 1000& ms
0002: jump テつ」テつ」Label008745

Offline VenomX

  • Veteran Member
  • Posts: 4294
    • View Profile
Introduction to SCM coding VC\LC
« Reply #56 on: June 26, 2007, 05:55:50 AM »
You have two different versions of Label008745 .  Change the last four lines to:

0002: jump テつ」テつ」Label008746

:Label008746
0001: wait 1000& ms
0002: jump テつ」テつ」Label008746

Then it should work.

Offline bogeymaster

  • Posts: 154
    • View Profile
    • http://
Introduction to SCM coding VC\LC
« Reply #57 on: June 28, 2007, 07:02:20 AM »
How to make an actor dance? I couldn't find it in opcodes. Can anyone help please?    

Offline Cody

  • Veteran Member
  • Posts: 5666
  • (stormlexer)
    • View Profile
Introduction to SCM coding VC\LC
« Reply #58 on: June 30, 2007, 03:11:52 AM »
Can somebody PLEASE tell me why I keep getting this gay ass error? >=\


It happens every time I try to compile a SCM.. Is there something i'm screwing up? =/

Offline Neo Anderson

  • ATS precision whore
  • Veteran Member
  • Posts: 5079
  • Registered on: April 16, 2004
    • View Profile
Introduction to SCM coding VC\LC
« Reply #59 on: June 30, 2007, 04:00:59 AM »
2 things come to mind right away, is the SCM checked as "read only" or if your using a different version of Mission builder than the SCM is. Say 1.5 and your tryin to compile a script thats version 0.22?

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal