@@ -11,15 +11,8 @@ namespace AltV.Net.Async
1111{
1212 public static partial class AltAsync
1313 {
14- public static async Task < IVehicle > CreateVehicle ( uint model , Position pos , Rotation rot )
15- {
16- ushort id = default ;
17- var vehiclePtr = await AltVAsync . Schedule ( ( ) =>
18- AltNative . Server . Server_CreateVehicle ( ( ( Server ) Alt . Server ) . NativePointer , model , pos , rot ,
19- ref id ) ) ;
20- Alt . Module . VehiclePool . Create ( vehiclePtr , id , out var vehicle ) ;
21- return vehicle ;
22- }
14+ public static Task < IVehicle > CreateVehicle ( uint model , Position pos , Rotation rot ) => AltVAsync . Schedule ( ( ) =>
15+ Alt . Module . Server . CreateVehicle ( model , pos , rot ) ) ;
2316
2417 public static Task < IVehicle > CreateVehicle ( VehicleModel model , Position pos , Rotation rot ) =>
2518 CreateVehicle ( ( uint ) model , pos , rot ) ;
@@ -36,14 +29,8 @@ public static IVehicleBuilder CreateVehicleBuilder(VehicleModel model, Position
3629 public static IVehicleBuilder CreateVehicleBuilder ( string model , Position pos , Rotation rot ) =>
3730 new VehicleBuilder ( Alt . Hash ( model ) , pos , rot ) ;
3831
39- public static async Task < IPlayer > GetDriverAsync ( this IVehicle vehicle )
40- {
41- var entityPointer =
42- await AltVAsync . Schedule ( ( ) =>
43- ! vehicle . Exists ? IntPtr . Zero : AltNative . Vehicle . Vehicle_GetDriver ( vehicle . NativePointer ) ) ;
44- if ( entityPointer == IntPtr . Zero ) return null ;
45- return Alt . Module . PlayerPool . GetOrCreate ( entityPointer , out var player ) ? player : null ;
46- }
32+ public static Task < IPlayer > GetDriverAsync ( this IVehicle vehicle ) => AltVAsync . Schedule ( ( ) =>
33+ ! vehicle . Exists ? null : vehicle . Driver ) ;
4734
4835 public static Task < byte > GetModKitAsync ( this IVehicle vehicle ) =>
4936 AltVAsync . Schedule ( ( ) => vehicle . ModKit ) ;
@@ -235,22 +222,22 @@ public static Task<bool> IsRoofOpenAsync(this IVehicle vehicle) =>
235222
236223 public static Task SetRoofOpenAsync ( this IVehicle vehicle , bool roofOpen ) =>
237224 AltVAsync . Schedule ( ( ) => vehicle . RoofOpened = roofOpen ) ;
238-
225+
239226 public static Task < byte > GetDoorStateAsync ( this IVehicle vehicle , byte doorId ) =>
240227 AltVAsync . Schedule ( ( ) => vehicle . GetDoorState ( doorId ) ) ;
241-
228+
242229 public static Task SetDoorStateAsync ( this IVehicle vehicle , byte doorId , byte state ) =>
243230 AltVAsync . Schedule ( ( ) => vehicle . SetDoorState ( doorId , state ) ) ;
244-
231+
245232 public static Task < VehicleDoorState > GetDoorStateAsync ( this IVehicle vehicle , VehicleDoor door ) =>
246233 AltVAsync . Schedule ( ( ) => vehicle . GetDoorState ( door ) ) ;
247-
234+
248235 public static Task SetDoorStateAsync ( this IVehicle vehicle , VehicleDoor door , VehicleDoorState state ) =>
249236 AltVAsync . Schedule ( ( ) => vehicle . SetDoorState ( door , state ) ) ;
250-
237+
251238 public static Task < bool > IsWindowOpenedAsync ( this IVehicle vehicle , byte windowId ) =>
252239 AltVAsync . Schedule ( ( ) => vehicle . IsWindowOpened ( windowId ) ) ;
253-
240+
254241 public static Task SetWindowOpenedAsync ( this IVehicle vehicle , byte windowId , bool state ) =>
255242 AltVAsync . Schedule ( ( ) => vehicle . SetWindowOpened ( windowId , state ) ) ;
256243
@@ -286,19 +273,19 @@ public static Task<bool> IsFlamethrowerActiveAsync(this IVehicle vehicle) =>
286273
287274 public static Task < bool > HasArmoredWindowsAsync ( this IVehicle vehicle ) =>
288275 AltVAsync . Schedule ( ( ) => vehicle . HasArmoredWindows ) ;
289-
276+
290277 public static Task SetSpecialLightDamaged ( this IVehicle vehicle , byte specialLightId , bool isDamaged ) =>
291278 AltVAsync . Schedule ( ( ) => vehicle . SetSpecialLightDamaged ( specialLightId , isDamaged ) ) ;
292-
279+
293280 public static Task < bool > IsSpecialLightDamaged ( this IVehicle vehicle , byte specialLightId ) =>
294281 AltVAsync . Schedule ( ( ) => vehicle . IsSpecialLightDamaged ( specialLightId ) ) ;
295-
282+
296283 public static Task SetWindowDamaged ( this IVehicle vehicle , byte windowId , bool isDamaged ) =>
297284 AltVAsync . Schedule ( ( ) => vehicle . SetWindowDamaged ( windowId , isDamaged ) ) ;
298-
285+
299286 public static Task < bool > IsWindowDamaged ( this IVehicle vehicle , byte windowId ) =>
300287 AltVAsync . Schedule ( ( ) => vehicle . IsWindowDamaged ( windowId ) ) ;
301-
288+
302289 // TODO: Add: SetLightDamaged, IsLightDamaged, SetPartBulletHoles, GetPartBulletHoles, SetPartDamageLevel, GetPartDamageLevel
303290 // TODO: GetArmoredWindowHealth, SetArmoredWindowHealth, GetArmoredWindowShootCount, SetArmoredWindowShootCount
304291 // TODO: GetBumperDamageLevel, SetBumperDamageLevel
@@ -341,31 +328,31 @@ public static Task<Tuple<bool, bool, bool, bool>> GetNeonActiveAsync(this IVehic
341328 public static Task
342329 SetNeonActiveAsync ( this IVehicle vehicle , bool left , bool right , bool front , bool back ) =>
343330 AltVAsync . Schedule ( ( ) => vehicle . SetNeonActive ( left , right , front , back ) ) ;
344-
331+
345332 public static Task < string > GetAppearanceDataAsync ( this IVehicle vehicle ) =>
346333 AltVAsync . Schedule ( ( ) => vehicle . AppearanceData ) ;
347334
348335 public static Task SetAppearanceDataAsync ( this IVehicle vehicle , string text ) =>
349336 AltVAsync . Schedule ( ( ) => vehicle . AppearanceData = text ) ;
350-
337+
351338 public static Task < uint > GetRadioStationAsync ( this IVehicle vehicle ) =>
352339 AltVAsync . Schedule ( ( ) => vehicle . RadioStation ) ;
353340
354341 public static Task SetRadioStationAsync ( this IVehicle vehicle , uint radioStation ) =>
355342 AltVAsync . Schedule ( ( ) => vehicle . RadioStation = radioStation ) ;
356-
343+
357344 public static Task < bool > GetManualEngineControlAsync ( this IVehicle vehicle ) =>
358345 AltVAsync . Schedule ( ( ) => vehicle . ManualEngineControl ) ;
359346
360347 public static Task SetManualEngineControlAsync ( this IVehicle vehicle , bool state ) =>
361348 AltVAsync . Schedule ( ( ) => vehicle . ManualEngineControl = state ) ;
362-
349+
363350 public static Task < string > GetScriptDataAsync ( this IVehicle vehicle ) =>
364351 AltVAsync . Schedule ( ( ) => vehicle . ScriptData ) ;
365352
366353 public static Task SetScriptDataAsync ( this IVehicle vehicle , string text ) =>
367354 AltVAsync . Schedule ( ( ) => vehicle . ScriptData = text ) ;
368-
355+
369356 public static Task RemoveAsync ( this IVehicle vehicle ) => AltVAsync . Schedule ( vehicle . Remove ) ;
370357 }
371358}
0 commit comments