Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (86,337 visits to this link)

    2. News

    1. GTA Online

      1. Find Lobbies & Players
      2. Guides & Strategies
      3. Vehicles
      4. Content Creator
      5. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

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

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

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

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption 2

    2. Red Dead Redemption

    3. Rockstar Games

    1. Off-Topic

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

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

    2. Site Suggestions

Sign in to follow this  
serabella

Help with a main.scm mission

Recommended Posts

serabella

Hello!

 

So, I've just started coding again after a ~3 years break. I don't remember very much about it so sorry if I ask "too many" questions.

 

The mission I'm creating is kind of an introduction mission to my new story. It's a pretty simple mission where the player has to kill a ped. This will spawn a sphere which they player has to walk into. Once in the sphere, another sphere will spawn which the player has to step into to complete the mission.

 

The thing is that it doesn't work as I want it to. Nothing happens after you've killed the dude, no sphere spawns or anything.

 

This is my code:

 

The first part of the mission (which I guess isn't part of the problem)

 

 

:TUT_1thread 'TUT 1' gosub @TUT_1_47 if wasted_or_busted else_jump @TUT_1_38 gosub @TUT_1_385 :TUT_1_38gosub @TUT_1_410 end_thread :TUT_1_47Model.Load(#KNIFECUR)Model.Load(#BFYST)038B: load_requested_models :TUT_1_58wait 0 if and  Model.Available(#KNIFECUR)  Model.Available(#BMYST)else_jump @TUT_1_58 01B2: give_actor $PLAYER_ACTOR weapon 4 ammo 10000 // Load the weapon model before using this 01B9: set_actor $PLAYER_ACTOR armed_weapon_to 4 $VICTIM1 = Actor.Create(CivMale, #BMYST, 2265.723, -1105.599, 37.9766)Actor.Angle($VICTIM1) = 155.003E5: show_text_box 'HELP101'  

 

 

This is where the spheres should be created if the requirements are met (I guess that it's something here which is fu*ked up)

 

 

:TUT_1_144wait 0 if   Actor.Dead($VICTIM1)else_jump @TUT_1_144 jump @TUT_1_171 :TUT_1_171$SPHERE_BEFOREJUMP = Marker.CreateIconAndSphere(0, 2287.116, -1120.849, 39.375):TUT_1_193wait 0 if 00FF:   actor $PLAYER_ACTOR sphere 0 in_sphere 2287.116 -1120.849 39.375 radius 2.0 2.0 2.0 on_foot else_jump @TUT_1_193 jump @TUT_1_252 :TUT_1_252$SPHERE_AFTERJUMP = Marker.CreateIconAndSphere(0, 2287.091, -1132.956, 26.7332)

 

 

And this is the rest of the mission where the "mission complete" trigger etc are placed. As you can see, the mission should be completed once the player steps in the sphere but as it doesn't spawn, it isn't possible to complete it...

 

 

:TUT_1_274wait 0 if   Actor.Dead($PLAYER_ACTOR)else_jump @TUT_1_301 jump @TUT_1_385 :TUT_1_30100FF:   actor $PLAYER_ACTOR sphere 0 in_sphere 2287.091 -1132.956 26.7332 radius 2.0 2.0 2.0 on_foot else_jump @TUT_1_274 0394: play_music 1 $MISSIONS_PASSED += 1 Player.Money($PLAYER_CHAR) += 1000001E3: show_text_1number_styled GXT 'M_PASS' number 10000 time 5000 style 1  // MISSION PASSED!~n~~w~$~1~return :TUT_1_38500BA: show_text_styled GXT 'M_FAIL' time 5000 style 1  // ~r~MISSION FAILED!0555: remove_weapon 31 from_actor $PLAYER_ACTOR return :TUT_1_410$ONMISSION = 0 Marker.Disable($VICTIM_MARKER)Player.WantedLevel($PLAYER_CHAR) = 0Model.Destroy(#BFYST)Model.Destroy(#BMYST)Model.Destroy(#M4)mission_cleanup return 

 

 

Just in case if anyone bothers to read through the whole code, here it is:

 

 

:TUT_1thread 'TUT 1' gosub @TUT_1_47 if wasted_or_busted else_jump @TUT_1_38 gosub @TUT_1_385 :TUT_1_38gosub @TUT_1_410 end_thread :TUT_1_47Model.Load(#KNIFECUR)Model.Load(#BFYST)038B: load_requested_models :TUT_1_58wait 0 if and  Model.Available(#KNIFECUR)  Model.Available(#BMYST)else_jump @TUT_1_58 01B2: give_actor $PLAYER_ACTOR weapon 4 ammo 10000 // Load the weapon model before using this 01B9: set_actor $PLAYER_ACTOR armed_weapon_to 4 $VICTIM1 = Actor.Create(CivMale, #BMYST, 2265.723, -1105.599, 37.9766)Actor.Angle($VICTIM1) = 155.003E5: show_text_box 'HELP101'  // In this tutorial, you are going to learn what it takes to be a hitman. See that guy with a marker above his head? Sneak up behind him and press and hold the right mouse button to aim at him while crouching with your knife equipped. While raising your knife behind him, press the left mouse button to execute him.:TUT_1_144wait 0 if   Actor.Dead($VICTIM1)else_jump @TUT_1_144 jump @TUT_1_171 :TUT_1_171$SPHERE_BEFOREJUMP = Marker.CreateIconAndSphere(0, 2287.116, -1120.849, 39.375):TUT_1_193wait 0 if 00FF:   actor $PLAYER_ACTOR sphere 0 in_sphere 2287.116 -1120.849 39.375 radius 2.0 2.0 2.0 on_foot else_jump @TUT_1_193 jump @TUT_1_252 :TUT_1_252$SPHERE_AFTERJUMP = Marker.CreateIconAndSphere(0, 2287.091, -1132.956, 26.7332):TUT_1_274wait 0 if   Actor.Dead($PLAYER_ACTOR)else_jump @TUT_1_301 jump @TUT_1_385 :TUT_1_30100FF:   actor $PLAYER_ACTOR sphere 0 in_sphere 2287.091 -1132.956 26.7332 radius 2.0 2.0 2.0 on_foot else_jump @TUT_1_274 0394: play_music 1 $MISSIONS_PASSED += 1 Player.Money($PLAYER_CHAR) += 1000001E3: show_text_1number_styled GXT 'M_PASS' number 10000 time 5000 style 1  // MISSION PASSED!~n~~w~$~1~return :TUT_1_38500BA: show_text_styled GXT 'M_FAIL' time 5000 style 1  // ~r~MISSION FAILED!0555: remove_weapon 31 from_actor $PLAYER_ACTOR return :TUT_1_410$ONMISSION = 0 Marker.Disable($VICTIM_MARKER)Player.WantedLevel($PLAYER_CHAR) = 0Model.Destroy(#BFYST)Model.Destroy(#BMYST)Model.Destroy(#M4)mission_cleanup return 

 

 

Thanks in advance! smile.gif

Share this post


Link to post
Share on other sites
Silent

1) No point in using global variables for these, it'd be much better if you switch globals to locals.

2) The script was working fine - the problem is, 02A7 (Marker.CreateIconAndSphere) are supposed to be used with mission TRIGGERS and therefore they don't show with $ONMISSION flag set to 1.

 

I'd like to point some other minor issues too:

 

- Using 038B removes the need for checking if models are loaded - the opcode pauses the game and loads models as soon as possible - if all that stuff is done onscreen (I guess it is, since there's no fadeout afterwards) you might want to remove that opcode, or it may freeze the game for a short moment on slower PCs.

- No need to check if CJ died - the game does that internally and in case you're dead/wasted (hence not so accurate "wasted_or_busted" opcode definition at the very top of your code).

 

I have rewritten the code in high-level syntax - it may be a bit confusing for you now, but the sooner you learn it, the better. I have also made some other changes and documented them in the code:

 

 

:TUT_103A4: name_thread 'TUT 1'gosub @TUT_1__MISSIONif 0112:   wasted_or_bustedthen   gosub @TUT_1__FAILendgosub @TUT_1__CLEANUP004E: end_thread:TUT_1__MISSION0247: load_model #KNIFECUR0247: load_model #BMYST// R* used that sort of loop - it's a bit better, since it looks clean when written in high-level and also won't execute WAIT even once// if models are somehow loaded straight awaywhile true   if or       8248:   not model #KNIFECUR available       8248:   not model #BMYST available   jf break   0001: wait 0 msend01B2: give_actor $PLAYER_ACTOR weapon 4 ammo 1  // ammo 1 is enough for melee weapons// 01B9 removed - given weapons are selected automatically009A: [email protected] = create_actor_pedtype 4 model #BMYST at 2265.723 -1105.599 37.9766    // Removed classes (Actor.Create) since they DON'T help keeping// the code look clean and consistent + switched to a local variable0173: set_actor [email protected] Z_angle_to 155.003E5: show_text_box 'HELP101'  // In this tutorial, you are going to learn what it takes to be a hitman. See that guy with a marker above his head? Sneak up behind him and press and hold the right mouse button to aim at him while crouching with your knife equipped. While raising your knife behind him, press the left mouse button to execute him.// 1) Isn't this text a bit too long?// 2) I'd advice to replace 'right mouse button' and 'left mouse button' with proper keycodes - respectively ~k~~PED_LOCK_TARGET~ and ~k~~PED_FIREWEAPON~// 3) There's no marker above his head;)while 8118:   not actor [email protected] dead   0001: wait 0 ms     // For one check within a loop, you can shorten it like that - it gets compiled in the same way as the previous model loading check doesend// Jump removed - no point to jump to a label which is directly below - labels aren't being compiled, the code is being executed line-by-line018A: [email protected] = create_checkpoint_at 2287.116 -1120.849 39.375   // I think that's what you wanted to achievewhile 80FF:   not actor $PLAYER_ACTOR sphere 1 in_sphere 2287.116 -1120.849 39.375 radius 2.0 2.0 2.0 on_foot   // Notice 'sphere 1'   0001: wait 0 msend0164: disable_marker [email protected] // I think you'd want to add it aswell018A: [email protected] = create_checkpoint_at 2287.091 -1132.956 26.7332while 80FF:   not actor $PLAYER_ACTOR sphere 1 in_sphere 2287.091 -1132.956 26.7332 radius 2.0 2.0 2.0 on_foot   // Notice 'sphere 1'   0001: wait 0 msend0164: disable_marker [email protected]: play_music 1$MISSIONS_PASSED += 10109: player $PLAYER_CHAR money += 10000// R* always cleans wanted level after mission, but only after a success - you might prefer that way0110: clear_player $PLAYER_CHAR wanted_level01E3: show_text_1number_styled GXT 'M_PASS' number 10000 time 5000 style 1  // MISSION PASSED!~n~~w~$~1~return:TUT_1__FAIL00BA: show_text_styled GXT 'M_FAIL' time 5000 style 1  // ~r~MISSION FAILED!0555: remove_weapon 31 from_actor $PLAYER_ACTOR // Are you sure you wanted that?return:TUT_1__CLEANUP0249: release_model #KNIFECUR0249: release_model #BMYST// Let's remove markers in case mission is failed - won't hurt0164: disable_marker [email protected]: disable_marker [email protected]$ONMISSION = 0mission_cleanupreturn

 

Share this post


Link to post
Share on other sites
serabella

Thank you very much! You can always except to get great help here at GTAF. Thanks again! smile.gif

Share this post


Link to post
Share on other sites
serabella

Oh, I hate being so bad at coding sad.gif @SilentPL So, I followed your tutorial and it looked a lot better and cleaner than my code. However, I wanted to add one thing to the end which should be the mission complete trigger. It works together with my "bribe" mod, you should bribe the cops by pressing the "5" button to complete the mission after jumping down into the sphere.

 

I added this thing at the end of your code:

 

 

010D: set_player $PLAYER_CHAR wanted_level_to 3while 80E1:   not player 0 pressed_key 53   0001: wait 0 msend

 

 

The thing is that nothing happens. After I pressed the 5 button, nothing happens. If I add "00E1: player 0 pressed_key 53", the mission will complete as soon as you enter the sphere but with the "not key pressed", nothing happens sad.gif

 

Full code:

 

 

:TUT_103A4: name_thread 'TUT 1'gosub @TUT_1__MISSIONif 0112:   wasted_or_bustedthen   gosub @TUT_1__FAILendgosub @TUT_1__CLEANUP004E: end_thread:TUT_1__MISSION0247: load_model #KNIFECUR0247: load_model #BMYST// R* used that sort of loop - it's a bit better, since it looks clean when written in high-level and also won't execute WAIT even once// if models are somehow loaded straight awaywhile true   if or       8248:   not model #KNIFECUR available       8248:   not model #BMYST available   jf break   0001: wait 0 msend01B2: give_actor $PLAYER_ACTOR weapon 4 ammo 1  // ammo 1 is enough for melee weapons// 01B9 removed - given weapons are selected automatically009A: [email protected] = create_actor_pedtype 4 model #BMYST at 2265.723 -1105.599 37.9766    // Removed classes (Actor.Create) since they DON'T help keeping// the code look clean and consistent + switched to a local variable0173: set_actor [email protected] Z_angle_to 155.003E5: show_text_box 'HELP101'  // In this tutorial, you are going to learn what it takes to be a hitman. See that guy with a marker above his head? Sneak up behind him and press and hold the right mouse button to aim at him while crouching with your knife equipped. While raising your knife behind him, press the left mouse button to execute him.// 1) Isn't this text a bit too long?// 2) I'd advice to replace 'right mouse button' and 'left mouse button' with proper keycodes - respectively ~k~~PED_LOCK_TARGET~ and ~k~~PED_FIREWEAPON~// 3) There's no marker above his head;)while 8118:   not actor [email protected] dead   0001: wait 0 ms     // For one check within a loop, you can shorten it like that - it gets compiled in the same way as the previous model loading check doesend// Jump removed - no point to jump to a label which is directly below - labels aren't being compiled, the code is being executed line-by-line018A: [email protected] = create_checkpoint_at 2287.116 -1120.849 39.375   // I think that's what you wanted to achievewhile 80FF:   not actor $PLAYER_ACTOR sphere 1 in_sphere 2287.116 -1120.849 39.375 radius 2.0 2.0 2.0 on_foot   // Notice 'sphere 1'   0001: wait 0 msend0164: disable_marker [email protected] // I think you'd want to add it aswell018A: [email protected] = create_checkpoint_at 2287.091 -1132.956 26.7332while 80FF:   not actor $PLAYER_ACTOR sphere 1 in_sphere 2287.091 -1132.956 26.7332 radius 2.0 2.0 2.0 on_foot   // Notice 'sphere 1'   0001: wait 0 msend0164: disable_marker [email protected]: set_player $PLAYER_CHAR wanted_level_to 3while 80E1:   not player 0 pressed_key 53   0001: wait 0 msend0394: play_music 1$MISSIONS_PASSED += 10109: player $PLAYER_CHAR money += 500// R* always cleans wanted level after mission, but only after a success - you might prefer that way0110: clear_player $PLAYER_CHAR wanted_level01E3: show_text_1number_styled GXT 'M_PASS' number 500 time 5000 style 1  // MISSION PASSED!~n~~w~$~1~return:TUT_1__FAIL00BA: show_text_styled GXT 'M_FAIL' time 5000 style 1  // ~r~MISSION FAILED!0555: remove_weapon 31 from_actor $PLAYER_ACTOR // Are you sure you wanted that?return:TUT_1__CLEANUP0249: release_model #KNIFECUR0249: release_model #BMYST// Let's remove markers in case mission is failed - won't hurt0164: disable_marker [email protected]: disable_marker [email protected]$ONMISSION = 0mission_cleanupreturn

 

Share this post


Link to post
Share on other sites
Wesser

The WHILE loop iterates the embedded code until its check becomes false. If you check whether a key is pressed when it hasn't been pushed yet, the while loop will break immediately because of the condition returning false. Plus, you test for the wrong key here. To show a list of all virtual key codes, go to Help->Contents->CLEO 3 Code Library->Virtual key codes (for 0AB0). If you choose to use Hex values you must add 0x before the number.

Edited by Wesser

Share this post


Link to post
Share on other sites
serabella

Ah okay, thanks for explaining. I'll try to rewrite it then.

Share this post


Link to post
Share on other sites
fireguy109

 

The WHILE loop iterates the embedded code until its check becomes false. If you check whether a key is pressed when it hasn't been pushed yet, the while loop will break immediately because of the condition returning false. Plus, you test for the wrong key here. To show a list of all virtual key codes, go to Help->Contents->CLEO 3 Code Library->Virtual key codes (for 0AB0). If you choose to use Hex values you must add 0x before the number.

If this is all main.scm like he said, then 0AB0 won't work. He actually needs this list - http://www.gtamodding.com/index.php?title=00E1

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

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