Skip to content

Commit

Permalink
fix iscript async events
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianTerhorst committed Apr 30, 2021
1 parent 8c3b63d commit cbe1652
Showing 1 changed file with 29 additions and 23 deletions.
52 changes: 29 additions & 23 deletions api/AltV.Net.Async/AltAsync.RegisterEvents.cs
Expand Up @@ -307,9 +307,10 @@ public static void RegisterEvents(object target)
if (scriptFunction == null) return;
OnFire += (player, fireInfos) =>
{
scriptFunction.Set(player);
scriptFunction.Set(fireInfos);
return scriptFunction.CallAsync();
var currScriptFunction = scriptFunction.Clone();
currScriptFunction.Set(player);
currScriptFunction.Set(fireInfos);
return currScriptFunction.CallAsync();
};
break;
case ScriptEventType.StartProjectile:
Expand All @@ -322,12 +323,13 @@ public static void RegisterEvents(object target)
if (scriptFunction == null) return;
OnStartProjectile += (player, startPosition, direction, ammoHash, weaponHash) =>
{
scriptFunction.Set(player);
scriptFunction.Set(startPosition);
scriptFunction.Set(direction);
scriptFunction.Set(ammoHash);
scriptFunction.Set(weaponHash);
return scriptFunction.CallAsync();
var currScriptFunction = scriptFunction.Clone();
currScriptFunction.Set(player);
currScriptFunction.Set(startPosition);
currScriptFunction.Set(direction);
currScriptFunction.Set(ammoHash);
currScriptFunction.Set(weaponHash);
return currScriptFunction.CallAsync();
};
break;
case ScriptEventType.PlayerWeaponChange:
Expand All @@ -339,10 +341,11 @@ public static void RegisterEvents(object target)
if (scriptFunction == null) return;
OnPlayerWeaponChange += (player, oldWeapon, newWeapon) =>
{
scriptFunction.Set(player);
scriptFunction.Set(oldWeapon);
scriptFunction.Set(newWeapon);
return scriptFunction.CallAsync();
var currScriptFunction = scriptFunction.Clone();
currScriptFunction.Set(player);
currScriptFunction.Set(oldWeapon);
currScriptFunction.Set(newWeapon);
return currScriptFunction.CallAsync();
};
break;
case ScriptEventType.NetOwnerChange:
Expand All @@ -354,10 +357,11 @@ public static void RegisterEvents(object target)
if (scriptFunction == null) return;
OnNetworkOwnerChange += (targetEntity, oldNetOwner, newNetOwner) =>
{
scriptFunction.Set(targetEntity);
scriptFunction.Set(oldNetOwner);
scriptFunction.Set(newNetOwner);
return scriptFunction.CallAsync();
var currScriptFunction = scriptFunction.Clone();
currScriptFunction.Set(targetEntity);
currScriptFunction.Set(oldNetOwner);
currScriptFunction.Set(newNetOwner);
return currScriptFunction.CallAsync();
};
break;
case ScriptEventType.VehicleAttach:
Expand All @@ -369,9 +373,10 @@ public static void RegisterEvents(object target)
if (scriptFunction == null) return;
OnVehicleAttach += (targetVehicle, attachedVehicle) =>
{
scriptFunction.Set(targetVehicle);
scriptFunction.Set(attachedVehicle);
return scriptFunction.CallAsync();
var currScriptFunction = scriptFunction.Clone();
currScriptFunction.Set(targetVehicle);
currScriptFunction.Set(attachedVehicle);
return currScriptFunction.CallAsync();
};
break;
case ScriptEventType.VehicleDetach:
Expand All @@ -383,9 +388,10 @@ public static void RegisterEvents(object target)
if (scriptFunction == null) return;
OnVehicleDetach += (targetVehicle, detachedVehicle) =>
{
scriptFunction.Set(targetVehicle);
scriptFunction.Set(detachedVehicle);
return scriptFunction.CallAsync();
var currScriptFunction = scriptFunction.Clone();
currScriptFunction.Set(targetVehicle);
currScriptFunction.Set(detachedVehicle);
return currScriptFunction.CallAsync();
};
break;
}
Expand Down

0 comments on commit cbe1652

Please sign in to comment.