Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Cayo Perico Heist
      2. The Diamond Casino Heist
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

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

    1. Red Dead Redemption 2

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

    1. Grand Theft Auto Series

    2. GTA VI

      1. St. Andrews Cathedral
    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. Guides & Strategies
      2. Help & Support
    6. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    7. GTA III

      1. Guides & Strategies
      2. 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. 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
    3. Gangs

    1. Announcements

    2. Support

    3. Suggestions

Sign in to follow this  
atheoang3l0_old

[SA] Disabling sub-missions via CLEO

Recommended Posts

atheoang3l0_old

Is it possible to disable sub-missions like Taxi Driver and Vigilante via a CLEO script?

I'm currently working on a "Disguise" mod, where I'm hoping to make it so that the player needs a specific outfit to unlock and play a specific sub-mission, e.g. the Cop outfit is required to unlock and play Vigilante. This is more of a personal mod of mine made to work alongside other mods by myself and others, so I'm not sure if I'd want to release this.

Edited by Darchang310

Share this post


Link to post
Share on other sites
ZAZ

with 0459: is it possible with a cleo script to terminate a running thread of main.scm

but you can't start a script of main.scm, so it will problematical, because...

if you terminate the mission starter script you can't play anymore the submissions

if you terminate the running mission script, then the created stuff remains, like timer, actors, vehicles, markers

 

It's easier to set the onmission var to 1, which prevent the ability to start any mission script

or, if it's just for your own use, just give your player the desired outfit and play then the mission

Share this post


Link to post
Share on other sites
OrionSR

I'm not convinced that shutting down and relaunching the R3 thread is the best solution, but if you wanted to go this route it should be possible. Threads in main.scm can be launched by calling their global offset. I've been using this trick for quite a while to launch the race and school threads early in the game, and also to repair saves of people who tweaked the cities unlocked stat too soon.

// Repair for altering City Unlocked during LA1 mission strand0629: change_integer_stat 181 to 0//004F: create_thread @MOB_LA1_180158004F: create_thread 180158 // @MOB_LA1 PCv1//004F: create_thread 180137 // @MOB_LA1 PCv2

The tricky part for the R3 mission however is finding the correct global offset. Usually all I need to do is decompile with the thread+global offset option, but the R3 thread has an unusual label -- ":MS_Vehicle_SubMissions" with no global offset despite the correct setting. I'm sure it's still possible to launch it anyway but you'll have to tease out the correct address.

Edited by OrionSR

Share this post


Link to post
Share on other sites
Seemann

but the R3 thread has an unusual label -- ":MS_Vehicle_SubMissions" with no global offset despite the correct setting.

that offset is defined in the CustomLabels.ini

 

 

76402=MS_Vehicle_SubMissions

Share this post


Link to post
Share on other sites
OrionSR

I figured it was something like that but I suspect this strategy may not be the best solution to the problem so I didn't follow through to the end. But... does CustomLabels.ini allow the use of 004F: create_thread @MS_Vehicle_SubMissions in cleo scripts (if the v1 scripts are installed)?

Share this post


Link to post
Share on other sites
Seemann

I figured it was something like that but I suspect this strategy may not be the best solution to the problem so I didn't follow through to the end. But... does CustomLabels.ini allow the use of 004F: create_thread @MS_Vehicle_SubMissions in cleo scripts (if the v1 scripts are installed)?

nope, you cant use any label that's not present in the source file. however it's an interesting idea.

Share this post


Link to post
Share on other sites
atheoang3l0_old

Hmm. So disabling missions is more complicated than I thought..

 

Here's a code I came up with using Zaz's idea (setting $ONMISSION to 1). How is it? Will it break any missions?

:COPNARMYwait 0if or    0500: player $PLAYER_CHAR skin == "POLICETR" on_bodypart 17    0500: player $PLAYER_CHAR skin == "FIELD" on_bodypart 0then    Player.WantedLevel($PLAYER_CHAR) = 0else    if        $ONMISSION == 0    then        if or            00DD: actor $PLAYER_ACTOR driving_car_with_model 427            00DD: actor $PLAYER_ACTOR driving_car_with_model 490            00DD: actor $PLAYER_ACTOR driving_car_with_model 523            00DD: actor $PLAYER_ACTOR driving_car_with_model 596            00DD: actor $PLAYER_ACTOR driving_car_with_model 597            00DD: actor $PLAYER_ACTOR driving_car_with_model 598            00DD: actor $PLAYER_ACTOR driving_car_with_model 599        then            $ONMISSION = 1            repeat                wait 0            until 80DF: not actor $PLAYER_ACTOR driving            $ONMISSION = 0        end    end    end

Note that this code is set to loop, so as long as CJ is wearing either the cop uniform or the combat jacket, Wanted Level is always set to 0.

 

How about just disabling the Submission key? Is it possible? It would be much simpler and mission-friendly if it is.

You know, I may just release a variant of this mod, anyway, to give those "special" outfits some purpose (apart from the paramedic uniform, which Zaz's mod has already covered)

Edited by Darchang310

Share this post


Link to post
Share on other sites
OrionSR

Another imperfect option is set $390 bit 1. This flag indicates that CJ is on a date, which disables the submissions, but obviously it'll mess with the girlfriends, probably the airport tickets, and I'm not sure what else. Still, with careful flag management you might be able to get it to work without too many consequences.

Share this post


Link to post
Share on other sites
Seemann

An overkill solution is to use

 

09BD: 1
to forbid all text boxes to be shown. The R3 thread has this check in its very beginning:

 

89BE:   not are_text_boxes_locked_to_any_thread
which will fail due to 09BD. So, no submissions will be allowed. To make all things work again use

 

09BD: 0

Share this post


Link to post
Share on other sites
OrionSR

I'm still stuck on vigilante but for the other R3 missions try adjusting these variables to turn the submissions on or off as required.

0004: $ONMISSION_TAXI = 10004: $ONMISSION_Paramedic = 1 0004: $ONMISSION_Firefighter = 1 0004: $ONMISSION_Burglary = 10004: $160 = 1 // On Freight Train Sub-Mission(?)0004: $159 = 1 // On Pimping Sub-Mission(?)

Share this post


Link to post
Share on other sites
atheoang3l0_old

Those may just be the codes I'm looking for. Will most likely make things easier. Thanks, OrionSR. I hope that you may also find out the one for Vigilante.

Edited by Darchang310

Share this post


Link to post
Share on other sites
OrionSR

I looked. I couldn't find anything in the R3 trigger thread that looked like it would do the trick and hasn't already been mentioned. How about, if the vigilante mission is started and the cop outfit isn't equipped then end the vigilante thread before it has a chance to spawn any actors, vehicles, or markers that might want to stick around and display a mission abort message specifying the new requirement? Maybe even give CJ a 3 start wanted level. If you wanted to go this route there are probably more elegant ways to coax the vigilante mission into shutting down properly so you don't need to worry about mission cleanup.

Share this post


Link to post
Share on other sites
Markuza

Vigilante is mission started with opcode 0417

 

{78369} 0417: start_mission COPCAR // Vigilante Sub-Mission

{78660} 0417: start_mission COPCAR // Vigilante Sub-Mission

 

Disable vigilante

0A8C: write_memory 0xA5CB81 size 4 value 0 virtual_protect 10A8C: write_memory 0xA5CCA4 size 4 value 0 virtual_protect 1

Enable vigilante

0A8C: write_memory 0xA5CB81 size 4 value 0x7C040417 virtual_protect 10A8C: write_memory 0xA5CCA4 size 4 value 0x7C040417 virtual_protect 1

This will replace opcode 0417 with 0000 (NOP) so game will simply ignore it. You will still get "VIGILANTE" text but we can remove that easily later.

 

This requires original main.scm and GTA San Andreas v1.0 [uS] HOODLUM EXE.

 

Share this post


Link to post
Share on other sites
Seemann

You can use advantage of CLEO scripting and hook the R3 thread, its wakeup value. The game will think you use a wait opcode, and the R3 thread loop will wait long enough for the next iteration. To make it normal, just reset the timer value.

 

{$cleo}0000:while true    wait 250    if        0AB0:   key_pressed 45 // Insert    then        [email protected] = 99999999        gosub @UpdateR3Thread    end    if        0AB0:   key_pressed 46 // Home    then        [email protected] = 0        gosub @UpdateR3Thread    endend:UpdateR3Thread0AAA: [email protected] = thread 'R3' pointerif [email protected] > 0then    [email protected] += 0xCC    0A8C: write_memory [email protected] size 4 value [email protected] virtual_protect 0endwait 1000 return
Edited by Seemann

Share this post


Link to post
Share on other sites
OrionSR

Ooh! I think we have a winner. This would eliminate most of my concerns about modifications persisting in the save if your mod is removed or altered. One last thing - the wakeup timer will be saved, which could leave the R3 missions bugged indefinitely unless,,,

 

Instead of setting a really high wakeup timer, set it a few seconds ahead of the current time (I think this will work, I haven't used it quite this way) as part of your loop. When the script stops running the R3 thread will quickly heal itself.

 

Suggestion: Let it sleep. Copy the entire R3 thread into your script, modify it as required, and manage the launching of missions within your script.

Edited by OrionSR

Share this post


Link to post
Share on other sites
atheoang3l0_old

Thanks for the help, guys. Really appreciate the ideas. For now, setting $ONMISSION to 1 works just fine. It's yet to break any of the missions I've tested so far.

Share this post


Link to post
Share on other sites
Wesser

A proper way requires hooking the main "r3" script code and injecting a check which tests the untruthfulness of the $ONMISSION_VIGILANTE variable, declared by yourself, in order to start "Vigilante" mission, just like the other submission triggers. This code takes advantage of DMA to read the value of our switcher variable owned by the hooking script:

 

{$CLEO}const    LOCALID                   = 0endconst    _CTheScripts__ScriptSpace = 0x00A49960endconst    _memcmp                   = [email protected]: script_name 'R3HOOK'0A8D: [email protected] = read_process_memory 0x008E3070 size 4 vp 00A8E: [email protected] = [email protected] + 0x01150A8E: [email protected] = [email protected] + 0x01190A8D: [email protected] = read_process_memory [email protected] size 4 vp 00A8E: _memcmp = [email protected] + [email protected]_memcmp -= 0xB8// Check if "r3" has been started and by the main script.0AAA: [email protected] = get_script_with_this_name 'R3' pointerif or    [email protected] == 0    [email protected] <  0x00A8B430 // CTheScripts::ScriptsArray[0]    [email protected] >= 0x00A90830 // CTheScripts::ScriptsArray[96]then    0A93: terminate_this_custom_scriptend0A9F: [email protected] = get_script_pointer0A8E: [email protected] = [email protected] + 0x10 // CRunningScript.m_pBaseAddress0A8D: [email protected] = read_process_memory [email protected] size 4 vp 00A8F: [email protected] = [email protected] - @_aR3CommandScriptNamegosub @GetR3ScriptCodeAddr0A8F: [email protected] = [email protected] - _CTheScripts__ScriptSpace0A8E: [email protected] = [email protected] + 0x065B // r3+65Bh0A8E: [email protected] = [email protected] + 0x08DD // r3+8DDh0A8F: [email protected] = [email protected] - @_HOOK_OFF_00000654_r30A8F: [email protected] = [email protected] - _CTheScripts__ScriptSpace0A8E: [email protected] = [email protected] + 0x3C // CRunningScript.m_aLocals0A90: [email protected] = LOCALID * 4005A: [email protected] += [email protected]@ -= [email protected] /= 4// 00000654 GOTO HOOK_OFF_00000654_r30A8E: [email protected] = [email protected] + 0x0654 // r3.thread.ba+654h0A8C: write_process_memory [email protected] size 2 value 0x0002 vp [email protected] += 20A8C: write_process_memory [email protected] size 1 value 0x01 vp [email protected] += 10A8C: write_process_memory [email protected] size 4 value [email protected] vp 00A8E: [email protected] = [email protected] + 3 // r3hook.thread.ba+30A8C: write_process_memory [email protected] size 4 value [email protected] vp 00A8E: [email protected] = [email protected] + 0x0D // r3hook.thread.ba+0Dh0A8C: write_process_memory [email protected] size 4 value [email protected] vp 00A8E: [email protected] = [email protected] + 0x23 // r3hook.thread.ba+23h0A8C: write_process_memory [email protected] size 4 value [email protected] vp 00A8E: [email protected] = [email protected] + 0x2A // r3hook.thread.ba+2Ah0A8C: write_process_memory [email protected] size 4 value [email protected] vp 0while true    wait 0    // [email protected] = false/true - Vigilante enabled/disabledend:GetR3ScriptCodeAddr0A8E: [email protected] = [email protected] + 0x14 // CRunningScript.m_iIP0A8D: [email protected] = read_process_memory [email protected] size 4 vp 00A8E: [email protected] = [email protected] + 0xCC // CRunningScript.m_uiWakeTime0A8D: [email protected] = read_process_memory [email protected] size 4 vp 001BD: [email protected] = get_game_timer0062: [email protected] -= [email protected]    [email protected] == 70then    0A8F: [email protected] = [email protected] - 0x0F    0AA7: call_function _memcmp num_params 3 pop 3 num 6 ptr2 [email protected] ptr1 [email protected] ret [email protected]    if        [email protected] == 0    then        0085: [email protected] = [email protected]        return    end    [email protected] += 0x0F    0A8D: [email protected] = read_process_memory [email protected] size 4 vp 0    [email protected] -= 4    [email protected] += _CTheScripts__ScriptSpaceelse    if        [email protected] <> 5000    then        [email protected] = 0        return    end    [email protected] += 3end0A8D: [email protected] = read_process_memory [email protected] size 4 vp [email protected] -= [email protected] += _CTheScripts__ScriptSpacereturn:_aR3CommandScriptNamehex    A403 09 "R3" 00end:_HOOK_OFF_00000654_r3hex    4D00 01 00000000              // 00000000 GOTO_IF_FALSE r3+8DDh                                  // 00000007 {                                  // 00000007 LVAR_INT var_index    0600 03 0000 01 00000000      // 00000007 SET_LVAR_INT var_index r3hook.thread.tls[LOCALID]-scrblock    D600 04 00                    // 00000011 ANDOR 0    3800 07 0000 0000 01 00 04 00 // 00000015 IS_INT_VAR_EQUAL_TO_NUMBER DMA[var_index] 0    4D00 01 00000000              // 00000020 GOTO_IF_FALSE r3+8DDh    0200 01 00000000              // 00000027 GOTO r3+65Bh                                  // 0000002E }end
  • Like 1

Share this post


Link to post
Share on other sites
NTAuthority

>actually exposing a lack of range checks as a feature

 

I know early Sanny is to blame for this, but really, are III modders this bad?

Share this post


Link to post
Share on other sites
Wesser

Where are they missed? I forgot to say the code works on a modified main script and an untouched "r3" script.

 

Anyway, what does SB matters?

Edited by Wesser

Share this post


Link to post
Share on other sites
Silent

What's wrong with the constant tiny wait applied to the script from another script? This way is simpler and not to mention, compatible with modified SCMs

Share this post


Link to post
Share on other sites
NTAuthority

Where are they missed? I forgot to say the code works on a modified main script and an untouched "r3" script.

talking about this 'dma' thing

 

 

What's wrong with the constant tiny wait applied to the script from another script? This way is simpler and not to mention, compatible with modified SCMs

but doesn't Wesser's code scan for the script name command, and therefore work with anything having r3.sc?

Share this post


Link to post
Share on other sites
Silent

but doesn't Wesser's code scan for the script name command, and therefore work with anything having r3.sc?

as if I could read code conveniently here.

Share this post


Link to post
Share on other sites
Wesser

Don't know if you noticed, we are dealing with workarounds, not definitive solutions.

Share this post


Link to post
Share on other sites
Silent

A definitive solution would be to apply changes to main.scm, and I don't think the OP wants it. Your code behaves the same way as if the changes were applied to the SCM directly, but if there's a WAY less complex solution which behaves the same way to the end user and, what's important, has no side effects, why not use it and save hassle?

Share this post


Link to post
Share on other sites
Wesser

The point is they do not behave in the same way, they just aim to achieve the same thing, each one has its own side effects (excluding those stated to demonize my script). If you believe that changing the wake time is a reliable method it's just your opinion I do not approve.

 

EDIT: You led me to confusion. The OP asked for a way to enable a specific submission trigger only when the player wears a particular outfit which fits the job he is going to carry out. My script gives the ability to selectively allow/disallow doing the "Vigilante" submission, not simply disable the whole "r3" script temporarily.

Edited by Wesser

Share this post


Link to post
Share on other sites
turbocoder32

Hey guys , use $390 I read over the post. This works and tested , tried and true.

 

 

 


{$CLEO .cs}
//0735: is_keyboard_key_pressed 49
//0736: is_keyboard_key_just_pressed 32
//00E1: player 0 pressed_key 19
thread 'MISSIONTEST'

:MISSIONTEST_11
wait 0
if //AND
Player.Defined($PLAYER_CHAR)
// $ONMISSION == 0
jf @MISSIONTEST_11

:MISSIONTEST_14
if or
Actor.DrivingTaxiVehicle($PLAYER_ACTOR)
Actor.DrivingVehicleType($PLAYER_ACTOR, #AMBULAN)
Actor.DrivingVehicleType($PLAYER_ACTOR, #FIRETRUK)
Actor.DrivingVehicleType($PLAYER_ACTOR, #HUNTER)
Actor.DrivingVehicleType($PLAYER_ACTOR, #BOXBURG)
Actor.DrivingPoliceVehicle($PLAYER_ACTOR)
jf @MISSIONTEST_15
IF AND
8500: not player $PLAYER_CHAR skin == "POLICETR" on_bodypart 17
8500: not player $PLAYER_CHAR skin == "MEDICTR" on_bodypart 17
jf @MISSIONTEST_11
08BA: set $390 bit 1
jump @MISSIONTEST_11

:MISSIONTEST_15
if or
Actor.DrivingTaxiVehicle($PLAYER_ACTOR)
Actor.DrivingVehicleType($PLAYER_ACTOR, #AMBULAN)
Actor.DrivingVehicleType($PLAYER_ACTOR, #FIRETRUK)
Actor.DrivingVehicleType($PLAYER_ACTOR, #HUNTER)
Actor.DrivingVehicleType($PLAYER_ACTOR, #BOXBURG)
Actor.DrivingPoliceVehicle($PLAYER_ACTOR)
jf @MISSIONTEST_16
IF AND
0500: player $PLAYER_CHAR skin == "POLICETR" on_bodypart 17
0500: player $PLAYER_CHAR skin == "MEDICTR" on_bodypart 17
jf @MISSIONTEST_11
$390 = 0
jump @MISSIONTEST_11

:MISSIONTEST_16
IF
8449: not actor $PLAYER_ACTOR in_a_car
jf @MISSIONTEST_11
$390 = 0

jump @MISSIONTEST_11
end_thread

 

 

 

 

Edited by turbocoder32

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • 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.