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 Contract
      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. GTA San Andreas

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

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

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    4. Bugs*

    1. Grand Theft Auto Series

      1. 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. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    6. 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

      1. GTANet 20th Anniversary
    2. Support

    3. Suggestions

How do I restart a script I stopped?


c39687
 Share

Recommended Posts

currently using the following code (I have wrapped all native functions in my own class so you wont recognize the native calls but my methods simply wrap them)

internal static void LoadNewScript(string name, int stack = 16000){   while (!NF_Script.HasScriptLoaded(name))    {        NF_Script.RequestScript(name);        GameFiber.Yield();//this is WAIT(0)    }   try { NF_System.StartNewScript(name, stack); } catch { }//im using rph and this can throw exceptions    NF_Script.SetScriptAsNoLongerNeeded(name);}

so first i stop the cellphone script with another wrapped native call...

NF_Gameplay.TerminateAllScriptsWithThisName("cellphone_controller");

then when i want the mobile script to restart i call the method i defined above, like this...

LoadNewScript("cellphone_controller");

the script will never restart and RPH throws an exception

Link to comment
Share on other sites

InfamousSabre

Looking through the decompiled R* scripts, it appears they use something like this.

bool StartScript(Hash scriptHash, int stackSize) //returns whether script starting was successful.{     SCRIPT::_REQUEST_STREAMED_SCRIPT(scriptHash);     if (SCRIPT::_HAS_STREAMED_SCRIPT_LOADED(scriptHash) > 0)     {           SYSTEM::_START_NEW_STREAMED_SCRIPT(scriptHash, stackSize);           SCRIPT::_SET_STREAMED_SCRIPT_AS_NO_LONGER_NEEDED(scriptHash);           return true;     }     return false;}
Edited by InfamousSabre
Link to comment
Share on other sites

streamed scripts i guess is the difference, ill test that, thanks... IS to the rescue again lol

Link to comment
Share on other sites

ok i tried using those natives and then converted the script name using Game.GetHashKey (RPH = Jenkins One At A Time)

 

and i cant start that phone again.Now the native does not throw an exception so it is an improvement but maybe i need to start a couple scripts... maybe stopping controller stops other stuff??

Link to comment
Share on other sites

InfamousSabre

Did you use the right stack size?

StartScript(GAMEPLAY::GET_HASH_KEY("cellphone_controller"), 1424);

Also, use
SCRIPT::_GET_NUMBER_OF_INSTANCES_OF_STREAMED_SCRIPT

to make sure it isn't already running before you start it.

Edited by InfamousSabre
Link to comment
Share on other sites

did you just pull that from the game scripts? i was using a large value, like 16000, just to give the scripts more stack space if needed... i figured the game's 64 bit so i could go nuts xD

Link to comment
Share on other sites

InfamousSabre

Sure did. Was in main_persistent.ysc

Edited by InfamousSabre
Link to comment
Share on other sites

unknown modder

did you just pull that from the game scripts? i was using a large value, like 16000, just to give the scripts more stack space if needed... i figured the game's 64 bit so i could go nuts xD

script stack sizes and counts are stored in game config. Trying to start a script with a stack size that's undefined will probably cause errors
  • Like 2
Link to comment
Share on other sites

 

did you just pull that from the game scripts? i was using a large value, like 16000, just to give the scripts more stack space if needed... i figured the game's 64 bit so i could go nuts xD

script stack sizes and counts are stored in game config. Trying to start a script with a stack size that's undefined will probably cause errors

 

good to know, thanks... i will refer to the config file in the future

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.