public static async Task SetNumberplateTextAsync(this IVehicle vehicle, string numberPlateText) { var numberPlateTextPtr = AltNative.StringUtils.StringToHGlobalUtf8(numberPlateText); await AltVAsync.Schedule(() => { vehicle.CheckIfEntityExists(); AltNative.Vehicle.Vehicle_SetNumberplateText(vehicle.NativePointer, numberPlateTextPtr); }); Marshal.FreeHGlobal(numberPlateTextPtr); }
public static async Task <string> GetNumberplateTextAsync(this IVehicle vehicle) { var ptr = IntPtr.Zero; await AltVAsync.Schedule( () => { vehicle.CheckIfEntityExists(); AltNative.Vehicle.Vehicle_GetNumberplateText(vehicle.NativePointer, ref ptr); }); return(ptr == IntPtr.Zero ? string.Empty : Marshal.PtrToStringUTF8(ptr)); }