Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Forum Support

    3. Suggestions

[SA] "DEFINE MISSION" crashes the game


EAZYJ
 Share

Recommended Posts

Hello everyone.

 

I have scripted a custom mission in the form of a thread first on a custom main.scm, then I decided to turn it into a mission. Problem is, when I decide to remove the thread and use "DEFINE MISSION" the game instantly crashes at that point.

EDIT: After searching where the problem could be, turns out that it's the creation of other threads that conflict with this, but I still don't understand why. Even if some threads are empty...

EDIT2: Problem fixed! I put all of my create_thread scripts below my mission script, while they should be put above.

 

DEFINE OBJECTS  1
DEFINE OBJECT (dummyobject) // This is an unused object. You can put anything here.



DEFINE MISSIONS 1
DEFINE MISSION 0 AT @MISSION1



DEFINE EXTERNAL_SCRIPTS  -1



DEFINE UNKNOWN_EMPTY_SEGMENT  0



DEFINE UNKNOWN_THREADS_MEMORY  0

 

 

I really don't understand... 

Plus, my mission begin script

//---------------------------------------------------------------------------------------------

:MISSION1
thread 'MISSION1'

     

:MISSION1_0
wait 0
0050: gosub @Mission1_100



:MISSION1_1
wait 0
if
 0112: wasted_or_busted
jf @MISSION1_1
gosub @Mission1_Failed
gosub @Mission1_Cleanup



end_thread

 

 

Any help is appreciated, thank you!

Edited by EAZYJ
Link to comment
Share on other sites

 

The MAIN thread is required

You must work with a stripped main.scm

there you see the minimum codes to start game and run in a valid way

important the restart_if_wasted or busted

and of course the player spawn

04E4: refresh_game_renderer_at 2494.5 -1668.5 
03CB: set_rendering_origin_at 2494.5 -1668.5 13.4 
0053: $PLAYER_CHAR = create_player 0 at 2494.5 -1668.5 13.4 
07AF: $PLAYER_GROUP = player $PLAYER_CHAR group 
01F5: $PLAYER_ACTOR = get_player_actor $PLAYER_CHAR 
0173: set_actor $PLAYER_ACTOR Z_angle_to 7.0 
0373: set_camera_directly_behind_player

 

 

and very important:

0180: set_on_mission_flag_to $ONMISSION

real missions run in a special mission mode

the global variable $ONMISSION works as controler for the special mission mode

 

look in spoiler for totally stripped main to see the minimum codes to start game and run in a valid way

Spoiler

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  7  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 town_number 0 
016D: restart_if_busted_at 2494.5 -1668.5 13.4 angle 180.0 town_number 0 
016C: restart_if_wasted_at 2494.5 -1668.5 13.4 angle 180.0 town_number 1 
016D: restart_if_busted_at 2494.5 -1668.5 13.4 angle 180.0 town_number 1 
016C: restart_if_wasted_at 2494.5 -1668.5 13.4 angle 180.0 town_number 2 
016D: restart_if_busted_at 2494.5 -1668.5 13.4 angle 180.0 town_number 2
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

:MAIN_3
0001: wait 2500 ms
//end_thread
0002: jump @MAIN_3

 

 

 

read also about Structure of main.scm

 

and here the template for small working mission

Player spawn in groovestree, weapon M4 pickup infront

Red sphere behind to start mission that spawns an actor which should kill player


DEFINE OBJECTS  1
DEFINE OBJECT (dummyobject) // This is an unused object. You can put anything here.

DEFINE MISSIONS  1
DEFINE MISSION 0 AT @TestMission_1

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  7  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 town_number 0 
016D: restart_if_busted_at 2494.5 -1668.5 13.4 angle 180.0 town_number 0 
016C: restart_if_wasted_at 2494.5 -1668.5 13.4 angle 180.0 town_number 1 
016D: restart_if_busted_at 2494.5 -1668.5 13.4 angle 180.0 town_number 1 
016C: restart_if_wasted_at 2494.5 -1668.5 13.4 angle 180.0 town_number 2 
016D: restart_if_busted_at 2494.5 -1668.5 13.4 angle 180.0 town_number 2
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
004F: create_thread @MissionStart1
032B: 1@ = create_weapon_pickup #AK47 15 ammo 3000 at 2490.0 -1662.0 13.5


:MAIN_3
0001: wait 2500 ms
//end_thread
0002: jump @MAIN_3






:MissionStart1
thread "MST"

:MissionStart2
wait  0
if
0256:   player $PLAYER_CHAR defined
else_jump @MissionStart2
if
$ONMISSION ==  0  // integer values
else_jump @MissionStart2
if
00FF:   actor $PLAYER_ACTOR  1 (in-sphere)near_point_on_foot 2498.5  -1678.5  13.35 radius  2.0  2.0  1.0
else_jump @MissionStart2
$ONMISSION =  1  // integer values
0417: start_mission  0   // originally: TestMission
jump @MissionStart2





//-------------Mission 1---------------
// Originally: TestMission


:TestMission_1
thread "TMISS"  
gosub @TestMission_main_1 
if
0112:   wasted_or_busted
else_jump @TestMission_end_1
gosub @TestMission_fail_1                    

:TestMission_end_1
gosub @TestMission_clep_1
004E: end_thread

:TestMission_main_1
0317: increment_mission_attempts//here starts the missionscript
$ONMISSION =  1

0247: request_model #VMAFF4
0247: request_model #AK47

:Load_models1
0001: wait  0 ms
if  and
0248:   model #VMAFF4 available
0248:   model #AK47 available
else_jump @Load_models1

009A: 1@ = create_actor  24 #VMAFF4 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 #VMAFF4

:TestM_Loop_1
wait  0
if
8118:   NOT   actor 1@ dead
else_jump @TestMission_passed_1
if
0104:   actor $PLAYER_ACTOR near_actor 1@ radius  80.0  80.0  10.0 sphere  0
else_jump @TestMission_fail_1
jump @TestM_Loop_1

:TestMission_passed_1
00BA: text_styled 'M_PASSD'  5000 ms  1
0110: clear_player $PLAYER_CHAR wanted_level
0109: player $PLAYER_CHAR money +=  5000
0394: play_music  1
0051: return

:TestMission_fail_1
00BA: text_styled 'M_FAIL'  5000 ms  1  // MISSION FAILED!
0051: return

:TestMission_clep_1
01C2: remove_references_to_actor 1@ // Like turning an actor into a random pedestrian
$ONMISSION = 0  // integer values
00D8: mission_cleanup
return

 

Edited by ZAZ
Link to comment
Share on other sites

Thanks ZAZ, though what I meant to say by custom main.scm is that it was stripped to begin with before I added some scripts with "create_thread" that are running in the background. 

 

My "mission" was a thread until I turned it into a mission with DEFINE MISSION. So I find out that threads could be the problem, for instance I created a "gun reloading" thread but the game crashes whenever it reads that the thread is created (even though there isn't anything wrong with the code itself). It's only when I define the mission at the beginning that threads seem to become incompatible. 

Link to comment
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
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.