Commits

Rainer Hilmer committed 5e04146

Hopefully fixed Issue 4 but there is not much I can do because the crash happened in the .net Scripthook. I moved World.GetPeds and World.GetVehicles closer to the caller. Let's hope that does the trick. If not, we have to live with it.

  • Participants
  • Parent commits 443f276

Comments (0)

Files changed (3)

File EmergencyRecover/EmergencyRecover/Core.cs

-using System.Collections.Generic;
-using GTA;
+using GTA;
 
 namespace EmergencyRecover
 {
    public class Core : Script
    {
+      private static readonly object SyncLock = new object();
       private readonly KeyHandling _keyHandling;
 
       public Core()
 
       public void Recover()
       {
-         var actualPosition = Player.Character.Position;
-         foreach (var ped in PedsAround(actualPosition))
+         lock (SyncLock)
          {
-            if (ReferenceEquals(Player.Character, ped))
-               continue;
-            ped.FreezePosition = false;
-            ClearTasksIfRequested(ped);
-            DeletePedIfRequested(ped);
+            var actualPosition = Player.Character.Position;
+            foreach (var ped in World.GetPeds(actualPosition, 5.0f))
+            {
+               if (ReferenceEquals(Player.Character, ped))
+                  continue;
+               ped.FreezePosition = false;
+               ClearTasksIfRequested(ped);
+               DeletePedIfRequested(ped);
+            }
+            foreach (var vehicle in World.GetVehicles(actualPosition, 5.0f))
+            {
+               vehicle.FreezePosition = false;
+               UnlockVehicleIfRequested(vehicle);
+               DeleteVehicleIfRequested(vehicle);
+            }
+            CommonFunctions.DisplayText("Emergency recovery done.", 4000);
          }
-         foreach (var vehicle in VehiclesAround(actualPosition))
-         {
-            vehicle.FreezePosition = false;
-            UnlockVehicleIfRequested(vehicle);
-            DeleteVehicleIfRequested(vehicle);
-         }
-         CommonFunctions.DisplayText("Emergency recovery done.", 4000);
       }
 
       private bool AffectPlayerVehicleIfRequested(Vehicle vehicle)
             vehicle.DoorLock = DoorLock.None;
          }
       }
-
-      private static IEnumerable<Ped> PedsAround(Vector3 actualPosition)
-      {
-         return World.GetPeds(actualPosition, 5.0f);
-      }
-
-      private static IEnumerable<Vehicle> VehiclesAround(Vector3 actualPosition)
-      {
-         return World.GetVehicles(actualPosition, 5.0f);
-      }
    }
 }

File EmergencyRecover/EmergencyRecover/Properties/AssemblyInfo.cs

 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2.0.1.*")]
+[assembly: AssemblyVersion("2.0.2.*")]
 //[assembly: AssemblyFileVersion("1.0.0.0")]
 [assembly: InternalsVisibleTo("EmergencyRecover.Tests")]

File EmergencyRecover/EmergencyRecover/bin/x86/Release/EmergencyRecover.net.dll

Binary file modified.