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. Los Santos Tuners
      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. Red Dead Redemption 2

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

    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. 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
    1. Announcements

      1. GTANet 20th Anniversary
    2. Support

    3. Suggestions

Game crash when clearing ped tasks and marking them as no needed


SayagoHren
 Share

Recommended Posts

Hello everybody, I have encountered a new problem why trying to create my first mod (more agressive wanted level). When I clear tasks for created peds and marking them as no longer needed (when player has wanted level 0) the game just crashes. Strange thing is that if I do not have much peds this function works properly. I also use in mod custom cars but I think it is not reason because this function does not affect directly car spawning, but maybe i am mistaking. Hope you can help me. Was searching for hours information about such kind of problem but did not found. Problem aso is not linked with system file corruption e.t.c because i made full windows reinstall with latest drivers, microsoft visual redist c++ and other simular things. The system is clean.

Application error in windows event viewer

Spoiler
Bad application name: GTA5.exe, version: 1.0.1868.1, timestamp: 0x5e7d1d62
Failed module name: KERNELBASE.dll, version: 10.0.19041.292, timestamp: 0x84cd251b
Exception Code: 0xe0434352
Error offset: 0x0000000000023e49
Process ID: 0x3454
Application start-up time: 0x01d6421f2f3e5e07
Bad application path: C: \ Program Files (x86) \ Steam \ steamapps \ common \ Grand Theft Auto V \ GTA5.exe
Failed module path: C: \ Windows \ System32 \ KERNELBASE.dll
Report ID: b8a0baf3-449a-40cc-8f81-70582a17d297

.NET runtime error in windows event viewer

Spoiler
 
Application: GTA5.exe
Platform Version: v4.0.30319
Description. The process was completed due to an unhandled exception.
Exception Details: System.AccessViolationException
   at SHVDN.NativeFunc.NativeCall ()
   at SHVDN.NativeFunc.NativeTask.Run ()
   at SHVDN.ScriptDomain.DoTick ()
   at SHVDN.ScriptDomain.DoTick ()
   in <Module>.? A0xc1aa4bd5.ScriptHookVDotnet_ManagedTick ()

 

Edited by SayagoHren
Link to post
Share on other sites

Are you able to post a code example? Or can you give a more descriptive example of what you're doing so we can test ourselves? e.g. "spawn 25 peds, then clear tasks and mark as not needed for all of them."

Link to post
Share on other sites

Thank you for the answer, sorry thought that information mentioned in my post was enough. In my mod I spawn random (random model) extra police cars, when wanted level is zero I clean tasks for peds in cars and mark all peds as no longer needed so they drive away and free memory. All these things happen in OnTick Event with interval 5 seconds. Under spoiler added spawn code.

if (Function.Call<int>(Hash.GET_PLAYER_WANTED_LEVEL, Game.Player) == 0)
{
ClearAllLawForcesTasks();                                                // this code in OnTick event
}
  
  private void ClearAllLawForcesTasks()
  {
     CleanPedTasks(ref peds_3_1, 16);
     CleanPedTasks(ref peds_6_1, 16);
     CleanPedTasks(ref peds_6_2, 16);
     CleanPedTasks(ref peds_6_3, 16);
     CleanPedTasks(ref peds_6_4, 16);
     CleanPedTasks(ref peds_6_5, 16);
  }
  
  private void CleanPedTasks(ref Ped[] peds_to_clean_task, int size_of_peds_array)
{
for (int i = 0; i < size_of_peds_array; i++)
{
if ( Function.Call<bool>(Hash.DOES_ENTITY_EXIST, peds_to_clean_task[i]) & !Function.Call<bool>(Hash.IS_ENTITY_DEAD, peds_to_clean_task[i]))
{
peds_to_clean_task[i].Task.ClearAll();
peds_to_clean_task[i].MarkAsNoLongerNeeded();
}
}
}
Spoiler
SpawnAnyCar("Rhino", ref v_6_1, ref peds_6_1, 5, 150.0F);// on tick event

private void SpawnAnyCar(Model VehicleModel, ref Vehicle AnyCar, ref Ped[] PedsAnyCar, int peds_type, float SpawnDistance)
{
         car_spawn_position = GenerateSpawnPos(Game.Player.Character.Position + Game.Player.Character.ForwardVector * SpawnDistance, Nodetype.Road, false);
           
         AnyCar = World.CreateVehicle(VehicleModel, car_spawn_position);
         AnyCar.PlaceOnGround();
         if (Game.Player.Character.IsInVehicle()) {
    AnyCar.Heading = Game.Player.Character.CurrentVehicle.Heading - 180;
} 
     else
   {
        AnyCar.Heading = Game.Player.Character.Heading - 180;
   }
         AnyCar.EngineRunning = true;
         AnyCar.SirenActive = true;
        
        
        PassengerCapacity = Function.Call<int>(Hash.GET_VEHICLE_MAX_NUMBER_OF_PASSENGERS, AnyCar);
                    for (int i = -1; i < PassengerCapacity; i++)
            {   
                switch (peds_type)
                {   
                    case 0:
                     if (i > -1){ped_index = ped_index +1;}//synchronising ped index with cycle counter
                     pedselect_cops();
                PedsAnyCar[ped_index] = AnyCar.CreatePedOnSeat((VehicleSeat)i, pedmodel_cops);
                    break;  
                case 1:
                if (i > -1){ped_index = ped_index +1;}//synchronising ped index with cycle counter
               PedsAnyCar[ped_index] = AnyCar.CreatePedOnSeat((VehicleSeat)i, "s_m_y_swat_01");
               break;

               case 2:
                if (i > -1){ped_index = ped_index +1;}//synchronising ped index with cycle counter
                pedselect_fbi();
                PedsAnyCar[ped_index] = AnyCar.CreatePedOnSeat((VehicleSeat)i, pedmodel_fbi);
               break;

               case 3:
                if (i > -1){ped_index = ped_index +1;}//synchronising ped index with cycle counter
                pedselect_medic();
                PedsAnyCar[ped_index] = AnyCar.CreatePedOnSeat((VehicleSeat)i, pedmodel_medic);
               break;

               case 4:
                if (i > -1){ped_index = ped_index +1;}//synchronising ped index with cycle counter
                pedselect_detective();
                PedsAnyCar[ped_index] = AnyCar.CreatePedOnSeat((VehicleSeat)i, pedmodel_detective);
               break;

                case 5:
                if (i > -1){ped_index = ped_index +1;}//synchronising ped index with cycle counter
                pedselect_army();
                PedsAnyCar[ped_index] = AnyCar.CreatePedOnSeat((VehicleSeat)i, pedmodel_army);
               break;
               
               default:
               if (i > -1){ped_index = ped_index +1;}//synchronising ped index with cycle counter
                PedsAnyCar[ped_index] = AnyCar.CreatePedOnSeat((VehicleSeat)i, "s_m_y_swat_01");
               break;
                }
               weapselect();
               PedsAnyCar[ped_index].Weapons.Give(weaphash, 999, true, true);
               Function.Call(Hash.SET_PED_AS_COP, PedsAnyCar[ped_index], true);
             } 
                
               
               
            
            if (!Game.Player.Character.IsInVehicle()) 
            {
               PedsAnyCar[0].Task.DriveTo(AnyCar, Game.Player.Character.Position, 10, 50);
            } 
            else 
           {
              PedsAnyCar[0].Task.VehicleChase(Game.Player.Character);
           }

           PedsAnyCar[0].AlwaysKeepTask = true;
           
            

        
            ped_index = 0;

    

}// End of SpawnAnyCar method

 

 

Edited by SayagoHren
Link to post
Share on other sites

  • 2 weeks later...

If I call directly this native it causes the crash with the same error even when the amount of peds is not big

 

Code of function:

Spoiler
private void CleanPedTasks(ref Ped[] peds_to_clean_task, int size_of_peds_array)
{

     
for (int i = 0; i < size_of_peds_array; i++)
{
if ( Function.Call<bool>(Hash.DOES_ENTITY_EXIST, peds_to_clean_task[i]) & !Function.Call<bool>(Hash.IS_ENTITY_DEAD, peds_to_clean_task[i]))
{
//peds_to_clean_task[i].MarkAsNoLongerNeeded(); 
Function.Call(Hash.SET_ENTITY_AS_NO_LONGER_NEEDED, peds_to_clean_task[i]);
}
}
}

 

 

Error in windows events viewer:

Spoiler
 
Application: GTA5.exe
Platform Version: v4.0.30319
Description. The process was completed due to an unhandled exception.
Exception Details: System.AccessViolationException
   at SHVDN.NativeFunc.NativeCall ()
   at SHVDN.NativeFunc.NativeTask.Run ()
   at SHVDN.ScriptDomain.DoTick ()
   at SHVDN.ScriptDomain.DoTick ()
   in <Module>.? A0xc1aa4bd5.ScriptHookVDotnet_ManagedTick ()

 

 

Link to post
Share on other sites

Checked it out, using array is not the problem.

Test code:

Spoiler
Ped test_ped_1;
Ped test_ped_2;
Ped test_ped_3;
Ped test_ped_4;

private void TestCleanPedTasks(ref Ped peds_to_clean_task)
{

{
if ( Function.Call<bool>(Hash.DOES_ENTITY_EXIST, peds_to_clean_task) & !Function.Call<bool>(Hash.IS_ENTITY_DEAD, peds_to_clean_task))
{
//peds_to_clean_task[i].MarkAsNoLongerNeeded(); 
Function.Call(Hash.SET_ENTITY_AS_NO_LONGER_NEEDED, peds_to_clean_task);
}
}

}
  
   private void onKeyDown(object sender, KeyEventArgs e)
        {
             if (e.KeyCode == Keys.H)
            {
                Vector3 peds_spawn_position = World.GetNextPositionOnSidewalk(Game.Player.Character.Position + Game.Player.Character.ForwardVector * 5);
                test_ped_1 = World.CreateRandomPed(peds_spawn_position);
                test_ped_2 = World.CreateRandomPed(peds_spawn_position);
                test_ped_3 = World.CreateRandomPed(peds_spawn_position);
                test_ped_4 = World.CreateRandomPed(peds_spawn_position);
            }

            if (e.KeyCode == Keys.J)
            {
                TestCleanPedTasks(ref test_ped_1);
                TestCleanPedTasks(ref test_ped_2);
                TestCleanPedTasks(ref test_ped_3);
                TestCleanPedTasks(ref test_ped_4);
            }
            
        
        }// end of keydown

.

Game crashes with same error code "system access violation" after trying to press "J".

Edited by SayagoHren
Link to post
Share on other sites

  • 4 weeks later...

I did two more tests about this problem:

 

TEST 1:
- More than 45 police riots spawned in game;
- For each riot, there was only one ped(COP01 SMY) as driver;
- Mark all police riot driver as no longer needed.
Result: everything ok.

TEST 2:
- Around 45 police riots spawned in game;
- For each riot, there were two peds (COP01 SMY);
- Mark all police riot ped as no longer needed.
Result: game crash.

It seems the problem depend on how many peds are spawned in vehicles and how many vehicles are spawned in game. For example, if you spawn five vehicles with seven seats each and then occupy all those seats with peds, when you call MarkAsNoLongerNeeded() for each ped, everything always will be fine because 7 peds * 5 vehicles = 35 (the game will handle it correctly). If you make the same test with more than 38 - 42 peds, the game will crash because it seems RAGE Engine fails to mark all peds as no longer needed. I don't know if the problem is related to the max spawnable entities that set to gameconfig files. 

Link to post
Share on other sites

  • 11 months later...

Did you figure out a fix to this problem, I have a similar issue with the exact same error code and I also using mark as no longer needed on cops.

 

?A0xc1aa4bd5.ScriptHookVDotnet_ManagedTick()

 

Edited by briancatmaster
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
 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.