GTA SAN ANDREAS
MODS for


GTA SA Main.scm coding Tutorial / english
add code to stripped main
I. use stripped main
This is a total stripped main, copy and paste the script below into
a new empty page of sannybuilder,
then run the function "compile+copy"
and test it ingame,
but don't forget to backup first your current
main.scm
and don't forget: you must start a new game!
DEFINE OBJECTS 1
DEFINE OBJECT (dummyobject) // This is an unused object. You can put anything here.
DEFINE MISSIONS 0
DEFINE EXTERNAL_SCRIPTS -1
DEFINE UNKNOWN_EMPTY_SEGMENT 0
DEFINE UNKNOWN_THREADS_MEMORY 0
//-------------MAIN---------------
:MAIN_1
03A4: name_thread 'MAIN'
016A: fade 0 (in) 0 ms
042C: set_total_missions_to 0
030D: set_total_mission_points_to 0
01F0: set_max_wanted_level_to 6
0111: set_wasted_busted_check_to 0 (disabled)
00C0: set_current_time 23 0
04E4: unknown_refresh_game_renderer_at 2494.5 -1668.5
03CB: set_camera 2494.5 -1668.5 13.4
0053: $PLAYER_CHAR = create_player #NULL at 2494.5 -1668.5 13.4
07AF: $PLAYER_GROUP = player $PLAYER_CHAR group
01F5: $PLAYER_ACTOR = create_emulated_actor_from_player $PLAYER_CHAR
0173: set_actor $PLAYER_ACTOR z_angle_to 7.0
0373: set_camera_directly_behind_player
070D: $PLAYER_CHAR
0629: change_stat 181 (islands unlocked) to 4 // integer see statdisp.dat
01B6: set_weather 1
04BB: select_interior 0 // select render area
01B4: set_player $PLAYER_CHAR frozen_state 1 (unfrozen)
01B7: release_weather
016C: restart_if_wasted at 2494.5 -1668.5 13.4 angle 180.0 unknown 0
016D: restart_if_busted at 2494.5 -1668.5 13.4 angle 180.0 unknown 0
016A: fade 1 (out) 1000 ms
0001: wait 100 ms
03E6: remove_text_box
0180: set_on_mission_flag_to $ONMISSION // Note: your missions have to use the variable defined here
:MAIN_3
0001: wait 2500 ms
//end_thread
0002: jump @MAIN_3
these are the codes to create the Player_Actor in Gameworld as well as initialising game rendering at spawn location
04E4: unknown_refresh_game_renderer_at 2494.5
-1668.5 // only X, Y coords 0053: $PLAYER_CHAR = create_player #NULL at 2494.5
-1668.5 13.4 // X, Y, Z coords |
Use Coords Manager to read the current player position while game is running in background (when ingame: go to main menue, then press ALT+TAB)
and change the coords to spawn player at another location
II. add code to stripped main
Go back to sannybuilder and give the player_actor clothes, body and money
and spawn some pickups as well as a car_generator which generate motorbike
Details about Parked_Car_Generator and Weapon Pickups
Copy the script below, overwrite the first one, then run the function "compile+copy" and test it ingame
DEFINE OBJECTS 1
DEFINE OBJECT (dummyobject) // This is an unused object. You can put anything here.
DEFINE MISSIONS 0
DEFINE EXTERNAL_SCRIPTS -1
DEFINE UNKNOWN_EMPTY_SEGMENT 0
DEFINE UNKNOWN_THREADS_MEMORY 0
//-------------MAIN---------------
:MAIN_1
03A4: name_thread 'MAIN'
016A: fade 0 (in) 0 ms
042C: set_total_missions_to 0
030D: set_total_mission_points_to 0
01F0: set_max_wanted_level_to 6
0111: set_wasted_busted_check_to 0 (disabled)
00C0: set_current_time 23 0
04E4: unknown_refresh_game_renderer_at 2494.5 -1668.5
03CB: set_camera 2494.5 -1668.5 13.4
0053: $PLAYER_CHAR = create_player #NULL at 2494.5 -1668.5 13.4
07AF: $PLAYER_GROUP = player $PLAYER_CHAR group
01F5: $PLAYER_ACTOR = create_emulated_actor_from_player $PLAYER_CHAR
0173: set_actor $PLAYER_ACTOR z_angle_to 7.0
0373: set_camera_directly_behind_player
070D: $PLAYER_CHAR
0629: change_stat 181 (islands unlocked) to 4 // integer see statdisp.dat
01B6: set_weather 1
04BB: select_interior 0 // select render area
01B4: set_player $PLAYER_CHAR frozen_state 1 (unfrozen)
01B7: release_weather
016C: restart_if_wasted at 2494.5 -1668.5 13.4 angle 180.0 unknown 0
016D: restart_if_busted at 2494.5 -1668.5 13.4 angle 180.0 unknown 0
0629: change_stat 181 (islands unlocked) to 4 // integer see statdisp.dat
0998: add_respect 1000
062A: change_stat 165 (energy) to 800.0 // float
062A: change_stat 23 (muscle) to 800.0 // float
062A: change_stat 21 (fat) to 200.0 // float
0629: change_stat 225 (lung capasity) to 1000 // integer see statdisp.dat
0629: change_stat 22 (stamina) to 1000 // integer see statdisp.dat
0629: change_stat 156 (dance skill) to 1000 // integer see statdisp.dat
062A: change_stat 81 (gambling skill) to 1000.0 // integer see statdisp.dat
087B: set_player $PLAYER_CHAR clothes_texture "HAWAIIRED" model "HAWAII" body_part 0
087B: set_player $PLAYER_CHAR clothes_texture "BASK2HEATBAND" model "BASK1" body_part 3
087B: set_player $PLAYER_CHAR clothes_texture "GLASSES05DARK" model "GLASSES03" body_part 15
087B: set_player $PLAYER_CHAR clothes_texture "LEATHERTR" model "LEATHERTR" body_part 2
070D: rebuild_player $PLAYER_CHAR
0109: player $PLAYER_CHAR money += 350000
016A: fade 1 (out) 1000 ms
0001: wait 100 ms
03E6: remove_text_box
0180: set_on_mission_flag_to $ONMISSION // Note: your missions have to use the variable defined here
014B: 0@ = init_parked_car_generator #PCJ600 0 17 1 alarm 0 door_lock 0 0 10000 at 2490.0 -1682.0 13.5 angle 90.0
014C: set_parked_car_generator 0@ cars_to_generate_to 101
032B: 1@ = create_weapon_pickup #AK47 15 ammo 3000 at 2490.0 -1662.0 13.5
032B: 2@ = create_weapon_pickup #JETPACK 15 ammo 0 at 2492.0 -1662.0 13.5
0213: 3@ = create_pickup #BODYARMOUR type 15 at 2494.0 -1662.0 13.5
0213: 4@ = create_pickup #GUN_PARA type 15 at 2496.0 -1662.0 13.5
0213: 5@ = create_pickup #BRIBE type 15 at 2498.0 -1662.0 13.5
:MAIN_3
0001: wait 2500 ms
//end_thread
0002: jump @MAIN_3
III. add a script to stripped main
Now let's add a new thread, a script to show the text "OK" by keypress Firebutton
look where this line is placed:
004F: create_thread @DEMOTEXT
it initialize the added thread
DEFINE OBJECTS 1
DEFINE OBJECT (dummyobject) // This is an unused object. You can put anything here.
DEFINE MISSIONS 0
DEFINE EXTERNAL_SCRIPTS -1
DEFINE UNKNOWN_EMPTY_SEGMENT 0
DEFINE UNKNOWN_THREADS_MEMORY 0
//-------------MAIN---------------
:MAIN_1
03A4: name_thread 'MAIN'
016A: fade 0 (in) 0 ms
042C: set_total_missions_to 0
030D: set_total_mission_points_to 0
01F0: set_max_wanted_level_to 6
0111: set_wasted_busted_check_to 0 (disabled)
00C0: set_current_time 23 0
04E4: unknown_refresh_game_renderer_at 2494.5 -1668.5
03CB: set_camera 2494.5 -1668.5 13.4
0053: $PLAYER_CHAR = create_player #NULL at 2494.5 -1668.5 13.4
07AF: $PLAYER_GROUP = player $PLAYER_CHAR group
01F5: $PLAYER_ACTOR = create_emulated_actor_from_player $PLAYER_CHAR
0173: set_actor $PLAYER_ACTOR z_angle_to 7.0
0373: set_camera_directly_behind_player
070D: $PLAYER_CHAR
0629: change_stat 181 (islands unlocked) to 4 // integer see statdisp.dat
01B6: set_weather 1
04BB: select_interior 0 // select render area
01B4: set_player $PLAYER_CHAR frozen_state 1 (unfrozen)
01B7: release_weather
016C: restart_if_wasted at 2494.5 -1668.5 13.4 angle 180.0 unknown 0
016D: restart_if_busted at 2494.5 -1668.5 13.4 angle 180.0 unknown 0
0629: change_stat 181 (islands unlocked) to 4 // integer see statdisp.dat
0998: add_respect 1000
062A: change_stat 165 (energy) to 800.0 // float
062A: change_stat 23 (muscle) to 800.0 // float
062A: change_stat 21 (fat) to 200.0 // float
0629: change_stat 225 (lung capasity) to 1000 // integer see statdisp.dat
0629: change_stat 22 (stamina) to 1000 // integer see statdisp.dat
0629: change_stat 156 (dance skill) to 1000 // integer see statdisp.dat
062A: change_stat 81 (gambling skill) to 1000.0 // integer see statdisp.dat
087B: set_player $PLAYER_CHAR clothes_texture "HAWAIIRED" model "HAWAII" body_part 0
087B: set_player $PLAYER_CHAR clothes_texture "BASK2HEATBAND" model "BASK1" body_part 3
087B: set_player $PLAYER_CHAR clothes_texture "GLASSES05DARK" model "GLASSES03" body_part 15
087B: set_player $PLAYER_CHAR clothes_texture "LEATHERTR" model "LEATHERTR" body_part 2
070D: rebuild_player $PLAYER_CHAR
0109: player $PLAYER_CHAR money += 350000
016A: fade 1 (out) 1000 ms
0001: wait 100 ms
03E6: remove_text_box
0180: set_on_mission_flag_to $ONMISSION // Note: your missions have to use the variable defined here
014B: 0@ = init_parked_car_generator #PCJ600 0 17 1 alarm 0 door_lock 0 0 10000 at 2490.0 -1682.0 13.5 angle 90.0
014C: set_parked_car_generator 0@ cars_to_generate_to 101
032B: 1@ = create_weapon_pickup #AK47 15 ammo 3000 at 2490.0 -1662.0 13.5
032B: 2@ = create_weapon_pickup #JETPACK 15 ammo 0 at 2492.0 -1662.0 13.5
0213: 3@ = create_pickup #BODYARMOUR type 15 at 2494.0 -1662.0 13.5
0213: 4@ = create_pickup #GUN_PARA type 15 at 2496.0 -1662.0 13.5
0213: 5@ = create_pickup #BRIBE type 15 at 2498.0 -1662.0 13.5
004F: create_thread @DEMOTEXT
:MAIN_3
0001: wait 2500 ms
//end_thread
0002: jump @MAIN_3
:DEMOTEXT
03A4: name_thread "DEMO"
wait 1000
:DEMOTEXT_1
wait 0
if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @DEMOTEXT_1
if
00E1: key_pressed 0 17//----------- Fire button
004D: jump_if_false @DEMOTEXT_1
00BA: text_styled 'FEM_OK' 1000 ms 1
004E: end_thread
Now add a script to spawn an actor in Grovestreet
Go into red marker in Grovestreet to spawn actor
The conditional opcode to check if player_actor is at a specified location have also the option to show a sphere(red round marker)
It needs to load the model for the actor and check if the model is loaded
After the creations must the code running in a loop which checks if the acor is dead
then it needs a cleanup when the actor is dead or when the scenery is finished
it needs to terminate the instances of the stuff for the script
then the code can jump back to start the script again from new
DEFINE OBJECTS 1
DEFINE OBJECT (dummyobject) // This is an unused object. You can put anything here.
DEFINE MISSIONS 0
DEFINE EXTERNAL_SCRIPTS -1
DEFINE UNKNOWN_EMPTY_SEGMENT 0
DEFINE UNKNOWN_THREADS_MEMORY 0
//-------------MAIN---------------
:MAIN_1
03A4: name_thread 'MAIN'
016A: fade 0 (in) 0 ms
042C: set_total_missions_to 0
030D: set_total_mission_points_to 0
01F0: set_max_wanted_level_to 6
0111: set_wasted_busted_check_to 0 (disabled)
00C0: set_current_time 23 0
04E4: unknown_refresh_game_renderer_at 2494.5 -1668.5
03CB: set_camera 2494.5 -1668.5 13.4
0053: $PLAYER_CHAR = create_player #NULL at 2494.5 -1668.5 13.4
07AF: $PLAYER_GROUP = player $PLAYER_CHAR group
01F5: $PLAYER_ACTOR = create_emulated_actor_from_player $PLAYER_CHAR
0173: set_actor $PLAYER_ACTOR z_angle_to 7.0
0373: set_camera_directly_behind_player
070D: $PLAYER_CHAR
0629: change_stat 181 (islands unlocked) to 4 // integer see statdisp.dat
01B6: set_weather 1
04BB: select_interior 0 // select render area
01B4: set_player $PLAYER_CHAR frozen_state 1 (unfrozen)
01B7: release_weather
016C: restart_if_wasted at 2494.5 -1668.5 13.4 angle 180.0 unknown 0
016D: restart_if_busted at 2494.5 -1668.5 13.4 angle 180.0 unknown 0
0629: change_stat 181 (islands unlocked) to 4 // integer see statdisp.dat
0998: add_respect 1000
062A: change_stat 165 (energy) to 800.0 // float
062A: change_stat 23 (muscle) to 800.0 // float
062A: change_stat 21 (fat) to 200.0 // float
0629: change_stat 225 (lung capasity) to 1000 // integer see statdisp.dat
0629: change_stat 22 (stamina) to 1000 // integer see statdisp.dat
0629: change_stat 156 (dance skill) to 1000 // integer see statdisp.dat
062A: change_stat 81 (gambling skill) to 1000.0 // integer see statdisp.dat
087B: set_player $PLAYER_CHAR clothes_texture "HAWAIIRED" model "HAWAII" body_part 0
087B: set_player $PLAYER_CHAR clothes_texture "BASK2HEATBAND" model "BASK1" body_part 3
087B: set_player $PLAYER_CHAR clothes_texture "GLASSES05DARK" model "GLASSES03" body_part 15
087B: set_player $PLAYER_CHAR clothes_texture "LEATHERTR" model "LEATHERTR" body_part 2
070D: rebuild_player $PLAYER_CHAR
0109: player $PLAYER_CHAR money += 350000
016A: fade 1 (out) 1000 ms
0001: wait 100 ms
03E6: remove_text_box
0180: set_on_mission_flag_to $ONMISSION // Note: your missions have to use the variable defined here
014B: 0@ = init_parked_car_generator #PCJ600 0 17 1 alarm 0 door_lock 0 0 10000 at 2490.0 -1682.0 13.5 angle 90.0
014C: set_parked_car_generator 0@ cars_to_generate_to 101
032B: 1@ = create_weapon_pickup #AK47 15 ammo 3000 at 2490.0 -1662.0 13.5
032B: 2@ = create_weapon_pickup #JETPACK 15 ammo 0 at 2492.0 -1662.0 13.5
0213: 3@ = create_pickup #BODYARMOUR type 15 at 2494.0 -1662.0 13.5
0213: 4@ = create_pickup #GUN_PARA type 15 at 2496.0 -1662.0 13.5
0213: 5@ = create_pickup #BRIBE type 15 at 2498.0 -1662.0 13.5
004F: create_thread @DEMOTEXT
004F: create_thread @Actor_1
:MAIN_3
0001: wait 2500 ms
//end_thread
0002: jump @MAIN_3
:DEMOTEXT
03A4: name_thread "DEMO"
wait 1000
:DEMOTEXT_1
wait 0
if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @DEMOTEXT_1
if
00E1: key_pressed 0 17//----------- Fire button
004D: jump_if_false @DEMOTEXT_1
00BA: text_styled 'FEM_OK' 1000 ms 1
004E: end_thread
:Actor_1
03A4: name_thread 'Actor'
:Actor_2
0001: wait 0 ms
if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @Actor_2
if
00FF: actor $PLAYER_ACTOR 1 (in-sphere)near_point_on_foot 2491.5 -1667.5 13.35 radius 1.0 1.0 1.0
004D: jump_if_false @Actor_2
0247: request_model #BFYST
0247: request_model #AK47
:Load_models_check
0001: wait 0 ms
00D6: if and
0248: model #BFYST available
0248: model #AK47 available
004D: jump_if_false @Load_models_check
009A: 1@ = create_actor 24 #BFYST at 2486.5 -1664.5 13.45
0173: set_actor 1@ z_angle_to 180.0
01B2: give_actor 1@ weapon 30 ammo 99999 // Load the weapon model before using this
02E2: set_actor 1@ weapon_accuracy_to 100
0223: set_actor 1@ health_to 1000
05E2: AS_actor 1@ kill_actor $PLAYER_ACTOR
0249: release_model #BFYST
:Loop_1
0001: wait 0 ms
if
8118: NOT actor 1@ dead
004D: jump_if_false @Cleanup_1
if
0104: actor $PLAYER_ACTOR near_actor 1@ radius 80.0 80.0 10.0 sphere 0
004D: jump_if_false @Cleanup_1
0002: jump @Loop_1
:Cleanup_1
01C2: remove_references_to_actor 1@ // Like turning an actor into a random pedestrian
0002: jump @Actor_2
next lesson >> IV. add a script to originally main