NicusorN5 Posted June 14, 2018 Share Posted June 14, 2018 (edited) Hello. I need some help with the mission code I made. :INITIAL_A /*1st cutscene */ //load actor 1@ = 0 01B4: set_player $PLAYER_CHAR frozen_state 0 $PLAYER_CHAR.CanMove = False while 823D:not special_actor 20 loaded wait 1 023C: load_special_actor 20 'BURGER' end Actor.Create(2@,CivMale,#SPECIAL20,420.1907,90.274,11.2881) //start cutscene 02A3: enable_widescreen 1 wait 1000 //first dialog 0372: set_actor $PLAYER_ACTOR anim 19 wait_state_time 2000 ms Actor.Angle(2@) = 218.4445 Actor.Angle($PLAYER_ACTOR) = 40.0 015F: set_camera_position 417.9948 87.6003 12.4301 0.0 rotation 0.0 0.0 Camera.PointAt(421.0572,88.7748,11.2801,2) 054C: use_GXT_table 'INTRO' 00BB: text_lowpriority 'DIALOG1' 2000 ms 1 wait 2000 //second dialog 015F: set_camera_position 423.3226 91.6754 12.5067 0.0 rotation 0.0 0.0 Camera.PointAt(420.1907,90.274,11.2881,2) 0372: set_actor 2@ anim 19 wait_state_time 2000 ms 00BB: text_lowpriority 'DIALOG2' 2000 ms 1 wait 2000 //third dialog 015F: set_camera_position 424.1574 87.4424 12.2591 0.0 rotation 0.0 0.0 Camera.PointAt(421.0572,88.7748,11.2801,2) 052B: actor $PLAYER_ACTOR hold_cellphone 1 00BB: text_lowpriority 'OBJ1' 1000 ms 1 wait 1000 00BB: text_lowpriority 'DIALOG3' 2000 ms 1 wait 2000 00BB: text_lowpriority 'DIALOG4' 2000 ms 1 wait 2000 052B: actor $PLAYER_ACTOR hold_cellphone 0 wait 1500 0372: set_actor $PLAYER_ACTOR anim 19 wait_state_time 2000 ms 00BB: text_lowpriority 'DIALOG5' 2000 ms 1 015F: set_camera_position 423.3226 91.6754 12.5067 0.0 rotation 0.0 0.0 Camera.PointAt(420.1907,90.274,11.2881,2) wait 2000 Camera.Restore() 02A3: enable_widescreen 0 01B4: set_player $PLAYER_CHAR frozen_state 1 $PLAYER_CHAR.CanMove = True wait 0 1@ = 1 //end cutscene //start first objective : enter a car 00BB: text_lowpriority 'OBJ2' 2000 ms 1 Model.Load(#ADMIRAL) 038B: load_requested_models Car.Create(3@,#ADMIRAL,428.2926 66.0054 10.9891) Car.Angle(3@) = 308.3486 Marker.CreateAboveCar(4@,3@) while true wait 0 6@ = Car.Health(3@) if 00DC: player $PLAYER_CHAR driving 3@ then if 1@ == 1 then //start second objective : drive to the club 00BB: text_lowpriority 'OBJ3' 2000 ms 1 Marker.Disable(4@) 02A7: 5@ = create_icon_marker_and_sphere 20 at 97.0645 -1470.8845 10.4318 //0168: set_blip $marker2 size 3 1@ = 2 end end if 6@ < 200 then gosub @INITIAL_B break end if 0101: actor $PLAYER_ACTOR stopped_near_point 97.0645 -1470.8845 10.4318 radius 3.0 3.0 1.5 sphere 0 then if 1@ == 2 then Marker.Disable(4@) 03BD: destroy_sphere 4@ 0164: disable_marker 4@ Actor.DestroyWithFade(2@) 0296: unload_special_actor 20 $missionspassed = 1 01E3: text_1number_styled 'M_PASS' number 0 time 6000 style 3 0394: play_music 1 1@ = 3 break end end end return :INITIAL_B 00BA: text_styled 'M_FAIL' 2000 ms 5 02a7: $initialmissmar create_icon_marker_and_sphere 19 at 421.1947 88.5849 11.2764 $missionspassed = 0 $onmission_alt = 0 return :INITIAL_C 03BD: destroy_sphere 4@ 0164: disable_marker 4@ 03BD: destroy_sphere 5@ 0164: disable_marker 5@ mission_cleanup $ONMISSION = 0 return The code does not create any crashes, BUT when I fail it nothing happends. Edited June 15, 2018 by NicusorN5 Script updated again. Link to comment Share on other sites More sharing options...
NicusorN5 Posted June 14, 2018 Author Share Posted June 14, 2018 I just realised I posted this into the wrong board. Please any mod move this thread. Link to comment Share on other sites More sharing options...
spaceeinstein Posted June 15, 2018 Share Posted June 15, 2018 (edited) Try to minimize your use of global variables and use local variables instead. Sanny Builder allows you to assign local variables to a name so that it's easier to keep track of them. For example: const car1 = [email protected] marker1 = [email protected] // etc... end // ... Car.Create(car1,#ADMIRAL,428.2926 66.0054 10.9891) Car.Angle(car1) = 308.3486 Marker.CreateAboveCar(marker1,car1) Your line "while 8112: not wasted_or_busted" will not work as you expect. Your line "if 0112:wasted_or_busted" uses a specialized opcode that allows the game to persistently check if you are wasted or busted so you don't need to repeat using that opcode anywhere else. Once you are wasted or busted, the game will break away from whatever it is doing in the script and automatically jump to label "INITIAL_B" for you. Edited June 15, 2018 by spaceeinstein Link to comment Share on other sites More sharing options...
NicusorN5 Posted June 15, 2018 Author Share Posted June 15, 2018 (edited) So if I use 'while true' in :INITIAL_A it will still break if i get arrested or busted? Also if I exceed the local variables number, what will happen? Edited June 15, 2018 by NicusorN5 Link to comment Share on other sites More sharing options...
NicusorN5 Posted June 15, 2018 Author Share Posted June 15, 2018 (edited) [BUMP] I got the problem with the :INITIAL_B and :INITIAL_C not beign called. But the second sphere won't show up. EDIT: Script updated again. Icon marker does show up. 02A7: 5@ = create_icon_marker_and_sphere 20 at 97.0645 -1470.8845 10.4318 0168: set_blip 5@ size 3 ^ 5 @ is the sphere. It only shows up if $ONMISSION is 0. Edited June 15, 2018 by NicusorN5 Link to comment Share on other sites More sharing options...
spaceeinstein Posted June 15, 2018 Share Posted June 15, 2018 (edited) Do you plan to make a very large script? You can reuse local variables if needed. Assigning local variables to constant names makes them easier to manage. Here's my example of reusing local variables multiple times, even taking advantage of bitwise operations in CLEO to squeeze more uses out of the limited number of local variables. If you must need to use global variables, you have to make sure your global variable numbers have no conflict with any other scripts. When Sanny Builder compiles $variable and it doesn't exist in CustomVariables.ini, it uses the next smallest number available in the current file, e.g. $123. When you decompile your compiled script, you can see exactly what number it compiled as. Your initial edit with the first 0112 was correct, it was your second use of 0112 that was incorrect. It only needs to be used once. For example: :simple_mission 0050: gosub @simple_mission_begin if 0112: wasted_or_busted // only use once here // This allows the game to persistently check for wasted/busted and when it does happen, the game stops whatever the script is doing and gosub to simple_mission_failed automatically. then 0050: gosub @simple_mission_failed end 0050: gosub @simple_mission_cleanup 004E: end_thread :simple_mission_begin // Place the contents of your mission // No need to check for any wasted/busted scenarios here 0051: return :simple_mission_failed // Died or got busted during your mission // You can jump to this section of your code from simple_mission_begin, but don't gosub into this from there. 0051: return :simple_mission_cleanup // Clean up the contents of your mission so you can end it $ONMISSION = 0 00D8: mission_cleanup 0051: return Edited June 15, 2018 by spaceeinstein deltaCJ and NicusorN5 2 Link to comment Share on other sites More sharing options...
NicusorN5 Posted June 16, 2018 Author Share Posted June 16, 2018 Ok, fixed, thank you. 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