kocel Posted May 26, 2008 Share Posted May 26, 2008 (edited) Hi! I'm a beginner, so tried out the tuts, and learned a lot of things. And I wanna create my own mission. The game didnt crash, but there's a problem. When I go in the sphere, it creates a car, and gives me 1000 $. But the marker didnt show on the radar and there wasnt the sphere, where i put the second. Please help me, whats wrong. Here's the code. DEFINE MISSIONS 1DEFINE MISSION 0 AT @DEMOL1 // Initial 1{$VERSION 3.1.0027}var$PLAYER_CHAR: Playerend // var 03A4: name_thread 'MAIN' 01F0: set_max_wanted_level_to 6 0111: toggle_wasted_busted_check 0 00C0: set_current_time_hours_to 8 minutes_to 0 04E4: unknown_refresh_game_renderer_at 2488.56 -1666.84 03CB: set_rendering_origin_at 2488.56 -1666.84 13.38 0053: $PLAYER_CHAR = create_player #NULL at -1856.094 -1640.09 30.2 01F5: $PLAYER_ACTOR = create_player_actor $PLAYER_CHAR 07AF: $PLAYER_GROUP = player $PLAYER_CHAR group 0373: set_camera_directly_behind_player 01B6: set_weather 0 0001: wait 0 ms 087B: set_player $PLAYER_CHAR clothes_texture "PLAYER_FACE" model "HEAD" body_part 1 087B: set_player $PLAYER_CHAR clothes_texture "JEANSDENIM" model "JEANS" body_part 2 087B: set_player $PLAYER_CHAR clothes_texture "SNEAKERBINCBLK" model "SNEAKER" body_part 3 087B: set_player $PLAYER_CHAR clothes_texture "VEST" model "VEST" body_part 0 070D: rebuild_player $PLAYER_CHAR 01B4: toggle_player $PLAYER_CHAR can_move 1 016A: fade 1 time 0 04BB: select_interior 0 0629: change_integer_stat 181 to 4 016C: restart_if_wasted_at 2027.77 -1420.52 15.99 angle 137.0 town_number 0 016D: restart_if_busted_at 1550.68 -1675.49 14.51 angle 90.0 town_number 0 0180: set_on_mission_flag_to $ONMISSION // Note: your missions have to use the variable defined here 0004: $DEFAULT_WAIT_TIME = 25003E6: remove_text_box 004F: create_thread @DEMOL1 //-------------Mission 0---------------:DEMOL103A4: name_thread 'DEMOL1'start_mission 0$ONMISSION = 0 0180: set_on_mission_flag_to $ONMISSION0186: $demo1_mark1 = create_icon_marker_and_sphere 55 at -1856.094 -1628.596 21.89905 0001: wait 0 ms 00D6: if0100: actor $PLAYER_ACTOR in_sphere -1856.094 -1628.596 21.89905 radius 2.0 2.0 2.0 sphere 1 in_car004D: jump_if_false @DEMOL1 Marker.Disable($demo1_mark1)0109: player $PLAYER_CHAR money += 1000014B: $demo1_car1 = init_parked_car_generator #EUROS 15 15 1 alarm 0 door_lock 0 0 0 at -1823.982 -1750.69 31.44871 angle 0.0 014C: set_parked_car_generator $demo1_car1 cars_to_generate_to 1010002: jump @DEMOL2 :DEMOL20001: wait 0 ms 0186: $demo1_mark2 = create_icon_marker_and_sphere 55 at -1823.982 -1750.69 31.4487102A7: $demo1_mark3 = create_icon_marker_and_sphere 6 at -2392.508 -2207.914 33.2890600D6: if0100: actor $PLAYER_ACTOR in_sphere -2392.508 -2207.914 33.28906 radius 2.0 2.0 2.0 sphere 1 in_car $demo1_car1004D: jump_if_false @DEMOL2$tec9 = Pickup.Create(#TEC9, 15, -2400.508, -2207.914, 33.3)0002: jump @DEMOL3:DEMOL30001: wait 0 ms if Pickup.Picked_up($tec9)004D: jump_if_false @DEMOL3Pickup.Destroy($tec9)Marker.Disable($demo1_mark3)Marker.Disable($demo1_mark2)02A7: $demo1_mark4 = create_icon_marker_and_sphere 15 at -1857.094 -1628.596 21.899050002: jump @DEMOL4 :DEMOL40001: wait 0 msif0100: actor $PLAYER_ACTOR in_sphere 1857.094 -1628.596 21.89905 radius 2.0 2.0 2.0 sphere 1 in_car $demo1_car1004D: jump_if_false @DEMOL4 0109: player $PLAYER_CHAR money += 100000002: jump @MAIN_LOOP0318: set_latest_mission_passed 'DEMOL1'mission_cleanup return Edited May 26, 2008 by kocel Link to comment Share on other sites More sharing options...
SteaVor Posted May 26, 2008 Share Posted May 26, 2008 If that's indeed the complete script (i.e. nothing left out between '004F: create_thread @DEMOL1' and the beginning of mission 0) the game will execute the thread DEMOL1 twice because it will just continue with the following piece of code after executing the create_thread command. Now you have both the continued MAIN thread and the newly created thread both execute the same code, but it gets worse since you've put a start_mission opcode within the mission code itself. I don't really know why that code isn't crashing the game because every time the misison is started it creates another instance of itself. To prevent this you'll need to delete the start_mission line and create a dead end (infinite loop - don't forget the WAIT!!!) for the main thread or simply end it with end_thread. I don't think you should get into missions at this stage, just make the code run as normal thread, tweak it to make it work perfectly, and only then you should think of converting the thread into a mission. Now there's one important thing you're missing entirely: Checks for the existence of the entitities you're about to refer to (player_defined, actor_defined,...) You should definitely begin with FAR simpler codes before trying something like this, really. One very, very basic you're obviously not aware of is that the engine reads the code linearily from top to bottom and will not stop at the end of a label! That's why you have to add an end_thread or jump opcode at the end of the main thread (or in fact any thread you're about to create) nad that's why all of your 'jump' lines at the end of the labels are obsolete. To make the engine continue at another point in the script you'd need to add a jump, jump_if_false or gosub/return opcode. It goes on and on, so you really, really should re-start with smaller steps. Link to comment Share on other sites More sharing options...
ZAZ Posted May 26, 2008 Share Posted May 26, 2008 Beginners like you allways want to write a mission script. But you must know that there is a difference between simple scripts and mission scripts. The scripts in the decompiled main.scm are called THREAD. The mission script is also a thread. But the mission script needs more knowledge and more effort for constellation. The engine reads the scripts downwards and Thread means that JUMP-instructions can send the reading engine back, upwards to a adress to read the same script again downwards. It loops. And conditional checks can select different JUMP-instructions. Simple threads are placed in the main part and they must be initialized with the create_thread-command 004F: create_thread @DEMOL_THREAD Your posted script is a stripped main text including your script and the main thread You can understand the main thread as the kernel of the main.scm In your main thread is a big failure: There is missing the end, the engine reads more downwards, directly into your DEMOL1 thread But the main thread dont have an end, it must have a JUMP-instructions to send the reading engine back, upwards to a adress to read the same script again downwards. It must loop. Just add a little loop at the end of the main thread :MAIN_30001: wait 2500 ms0002: jump @MAIN_3 In your DEMOL1 thread are also much failures: 1. 0186: $demo1_mark1 = create_icon_marker_and_sphere 55 at -1856.094 -1628.596 21.89905 the opcode 0186 = create_marker_above_vehicle this vehicle must exist and defined with a variable I assume opcode 02A7 is what you want 02A7: $demo1_mark1 = create_icon_marker_and_sphere 55 at -1856.094 -1628.596 21.89905 2. Add "player-defined-checks" 3. 0100: actor $PLAYER_ACTOR in_sphere 1857.094 -1628.596 21.89905 radius 2.0 2.0 2.0 sphere 1 in_car $demo1_car1 opcode 0100 is to check if the player or an actor is in a vehicle near this point there cant be defined a car like $demo1_car1 Note: sphere 1 means that a red marker is displayed sphere 0 means that no marker is displayed 0100: actor $PLAYER_ACTOR in_sphere -1857.094 -1628.596 21.89905 radius 2.0 2.0 2.0 sphere 1 in_car This is a complete stripped main. Replace your stripped main text with the script below: DEFINE OBJECTS 6 DEFINE OBJECT (unbenutzt) // This is an unused object. You can put anything here.DEFINE OBJECT INFO // Object number -1DEFINE OBJECT KEYCARD // Object number -2DEFINE OBJECT PICKUPSAVE // Object number -3DEFINE OBJECT BODYARMOUR // Object number -4DEFINE OBJECT BRIBE // Object number -5DEFINE MISSIONS 1DEFINE MISSION 0 AT @INITIAL_1 // originally: Initial 1DEFINE EXTERNAL_SCRIPTS 0DEFINE UNKNOWN_EMPTY_SEGMENT 0DEFINE UNKNOWN_THREADS_MEMORY 0//-------------MAIN---------------:MAIN_103A4: name_thread 'MAIN'016A: fade 0 () 0 ms042C: set_total_missions_to 0030D: set_total_mission_points_to 001F0: set_max_wanted_level_to 60111: set_wasted_busted_check_to 0 (disabled)00C0: set_current_time 10 004E4: unknown_refresh_game_renderer_at 2494.5 -1668.503CB: set_camera 2494.5 -1668.5 13.40053: $PLAYER_CHAR = create_player #NULL at 2494.5 -1668.5 13.407AF: $PLAYER_GROUP = player $PLAYER_CHAR group01F5: $PLAYER_ACTOR = create_emulated_actor_from_player $PLAYER_CHAR0173: set_actor $PLAYER_ACTOR z_angle_to 180.00373: set_camera_directly_behind_player0629: change_stat 181 (islands unlocked) to 4 // integer see statdisp.dat087B: set_player $PLAYER_CHAR clothes "bballjackrstar" "bbjack" 0087B: set_player $PLAYER_CHAR clothes "JEANSDENIM" "JEANS" 2087B: set_player $PLAYER_CHAR clothes "SNEAKERBINCBLK" "SNEAKER" 3087B: set_player $PLAYER_CHAR clothes "PLAYER_FACE" "HEAD" 1070D: $PLAYER_CHAR0109: player $PLAYER_CHAR money += 5000000180: set_on_mission_flag_to $ONMISSION01B6: set_weather 104BB: select_interior 0 // select render area01B4: set_player $PLAYER_CHAR frozen_state 1 (unfrozen)01B7: release_weather016C: restart_if_wasted at 2494.5 -1668.5 13.4 angle 180.0 unknown 0016D: restart_if_busted at 2494.5 -1668.5 13.4 angle 180.0 unknown 00417: start_mission 0004F: create_thread @DEMOL_THREAD//the create_thread command to init your thread016A: fade 1 () 1000 ms0001: wait 100 ms03E6: remove_text_box:MAIN_30001: wait 2500 ms0002: jump @MAIN_3//this is the end of the main thread, it loops permanent (jumps to label MAIN_3, waits 2500ms and jumps again to label MAIN_3 and so on):DEMOL_THREAD03A4: name_thread 'DEMOL'02A7: $demo1_mark1 = create_icon_marker_and_sphere 55 at -1856.094 -1628.596 21.89905:DEMOL10001: wait 0 ms00D6: if 00256: player $PLAYER_CHAR defined004D: jump_if_false @DEMOL100D6: if0100: actor $PLAYER_ACTOR in_sphere -1856.094 -1628.596 21.89905 radius 2.0 2.0 2.0 sphere 1 in_car004D: jump_if_false @DEMOL1Marker.Disable($demo1_mark1)0109: player $PLAYER_CHAR money += 1000014B: $demo1_car1 = init_parked_car_generator #EUROS 15 15 1 alarm 0 door_lock 0 0 0 at -1823.982 -1750.69 31.44871 angle 0.0014C: set_parked_car_generator $demo1_car1 cars_to_generate_to 10102A7: $demo1_mark2 = create_icon_marker_and_sphere 55 at -1823.982 -1750.69 31.4487102A7: $demo1_mark3 = create_icon_marker_and_sphere 6 at -2392.508 -2207.914 33.289060002: jump @DEMOL2:DEMOL20001: wait 0 ms00D6: if 00256: player $PLAYER_CHAR defined004D: jump_if_false @DEMOL200D6: if0100: actor $PLAYER_ACTOR in_sphere -2392.508 -2207.914 33.28906 radius 2.0 2.0 2.0 sphere 1 in_car004D: jump_if_false @DEMOL2$tec9 = Pickup.Create(#TEC9, 15, -2400.508, -2207.914, 33.3)0002: jump @DEMOL3:DEMOL30001: wait 0 ms00D6: if 00256: player $PLAYER_CHAR defined004D: jump_if_false @DEMOL3if Pickup.Picked_up($tec9)004D: jump_if_false @DEMOL3Pickup.Destroy($tec9)Marker.Disable($demo1_mark3)Marker.Disable($demo1_mark2)02A7: $demo1_mark4 = create_icon_marker_and_sphere 15 at -1857.094 -1628.596 21.899050002: jump @DEMOL4:DEMOL40001: wait 0 ms00D6: if 00256: player $PLAYER_CHAR defined004D: jump_if_false @DEMOL4if0100: actor $PLAYER_ACTOR in_sphere -1857.094 -1628.596 21.89905 radius 2.0 2.0 2.0 sphere 1 in_car004D: jump_if_false @DEMOL40109: player $PLAYER_CHAR money += 100000318: set_latest_mission_passed 'LACRAK'//<---this entry must exist in the german.gxt004E: end_thread//-------------Mission 0---------------// Originally: Initial 1:INITIAL_103A4: name_thread 'INITIAL'014B: $MR1 = init_parked_car_generator #PCJ600 0 17 1 alarm 0 door_lock 0 0 10000 at 2490.0 -1682.0 13.5 angle 90.0014C: set_parked_car_generator $MR1 cars_to_generate_to 101032B: $WP1 = create_weapon_pickup #AK47 15 ammo 3000 at 2490.0 -1662.0 13.5032B: $WP2 = create_weapon_pickup #JETPACK 15 ammo 0 at 2492.0 -1662.0 13.50213: $OP1 = create_pickup #BODYARMOUR type 15 at 2494.0 -1662.0 13.50213: $OP2 = create_pickup #GUN_PARA type 15 at 2496.0 -1662.0 13.50213: $OP3 = create_pickup #BRIBE type 15 at 2498.0 -1662.0 13.5004E: end_thread This stripped main text includes a very simple mission script. Its only used to set up stuff. In the original main are also used 2 missions to setup very much stuff by starting new game DEFINE MISSION 0 AT @INITIAL DEFINE MISSION 1 AT @INITIL2 The mission must be defined in the mission table DEFINE MISSIONS 1DEFINE MISSION 0 AT @INITIAL_1 // originally: Initial 1 the opcode 0417 starts the mission script 0417: start_mission 0 opcode 004E is the real end of a thread, it deactivate the single script. 004E: end_thread CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
kocel Posted May 27, 2008 Author Share Posted May 27, 2008 Thank you! I learned a lot of things about coding (again ) And i developed it, and it works. Thank you again. Sry for my bad english Link to comment Share on other sites More sharing options...
kocel Posted May 28, 2008 Author Share Posted May 28, 2008 Why crashes the game when I use a marker above car, object, or actor? Here's the code. It continues, but there isnt any problem with the following script. :DEMOL_THREAD03A4: name_thread 'DEMOL'02A7: $demo1_mark1 = create_icon_marker_and_sphere 15 at -1856.094 -1628.596 21.8990504CE: $demo1_prop1 = create_icon_marker_without_sphere 32 at -1866.323 -1635.197 21.75641 0517: $demo1_assetpickup = create_unavailable_asset_pickup 'PROP_1' at -1866.323 -1635.197 21.75641 // nem megvenni , mind után [0]:DEMOL10001: wait 0 ms00D6: if 00256: player $PLAYER_CHAR defined004D: jump_if_false @DEMOL100D6: if //or//80FF: actor $PLAYER_ACTOR in_sphere -1856.094 -1628.596 21.89905 radius 2.0 2.0 2.0 sphere 1 on_foot0100: actor $PLAYER_ACTOR in_sphere -1856.094 -1628.596 21.89905 radius 2.0 2.0 2.0 sphere 1 in_car004D: jump_if_false @DEMOL1Marker.Disable($demo1_mark1)014B: $demo1_car1 = init_parked_car_generator #EUROS 15 15 1 alarm 0 door_lock 0 0 0 at -1872.409 -1727.545 21.75 angle 0.0014C: set_parked_car_generator $demo1_car1 cars_to_generate_to 10102A7: $demo1_mark5 = create_icon_marker_and_sphere 55 at -1872.409 -1727.545 21.750002: jump @DEMOL1_2 :DEMOL1_20001: wait 0 ms00D6: if 00256: player $PLAYER_CHAR defined004D: jump_if_false @DEMOL10186: $marker = create_marker_above_car $demo1_car100D6: if 0100: actor $PLAYER_ACTOR in_sphere -1872.409 -1727.545 21.75 radius 2.0 2.0 2.0 sphere 1 in_car004D: jump_if_false @DEMOL1_2 Marker.Disable($demo1_mark5)02A7: $demo1_mark3 = create_icon_marker_and_sphere 6 at -2392.508 -2207.914 33.289060002: jump @DEMOL2_2IT CONTINUES... Link to comment Share on other sites More sharing options...
SteaVor Posted May 28, 2008 Share Posted May 28, 2008 This may not be obvious at the first glance, especially for new coders, but the reason for the crash is that 0186 create_marker_above_car expects a car as parameter while you are feeding it a car generator! The car generator variable set up with 014B and used in 014C, $demo1_car1 in your code, cannot be used in any opcode but these two! To create a marker above your car you'll need to create it via create_car. This way you'll get a valid car handle that can be used with every vehicle-related opcode. Link to comment Share on other sites More sharing options...
kocel Posted May 29, 2008 Author Share Posted May 29, 2008 Thanks (again ) Link to comment Share on other sites More sharing options...
kocel Posted May 29, 2008 Author Share Posted May 29, 2008 (edited) Edited June 4, 2008 by kocel Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now