Fix broken radio sync
This commit is contained in:
@ -38,6 +38,8 @@ namespace RageCoop.Client
|
||||
internal static Resources MainRes = null;
|
||||
|
||||
public static Ped P;
|
||||
public static Vehicle V;
|
||||
public static Vehicle LastV;
|
||||
public static float FPS;
|
||||
private static bool _lastDead;
|
||||
public static bool CefRunning;
|
||||
@ -129,9 +131,23 @@ namespace RageCoop.Client
|
||||
protected override void OnTick()
|
||||
{
|
||||
base.OnTick();
|
||||
P = Game.Player.Character;
|
||||
|
||||
var lastVehicleHandle = Call<int>(GET_PLAYERS_LAST_VEHICLE);
|
||||
var playerHandle = Call<int>(PLAYER_PED_ID);
|
||||
|
||||
if (LastV?.Handle != lastVehicleHandle)
|
||||
LastV = Entity.FromHandle(lastVehicleHandle) as Vehicle;
|
||||
|
||||
if (P?.Handle != playerHandle)
|
||||
P = (Ped)Entity.FromHandle(playerHandle);
|
||||
|
||||
var playerVehHandle = Call<int>(GET_VEHICLE_PED_IS_IN, P.Handle, false);
|
||||
if (V?.Handle != playerVehHandle)
|
||||
V = Entity.FromHandle(playerVehHandle) as Vehicle;
|
||||
|
||||
PlayerPosition = P.ReadPosition();
|
||||
FPS = Game.FPS;
|
||||
|
||||
#if CEF
|
||||
if (CefRunning)
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ namespace RageCoop.Client
|
||||
var attri = field.GetCustomAttribute<DebugTunableAttribute>();
|
||||
if (attri == null)
|
||||
continue;
|
||||
var item = new NativeItem($"{t}.{field.Name}");
|
||||
var item = new NativeItem(field.Name);
|
||||
item.AltTitle = field.GetValue(null).ToString();
|
||||
item.Activated += (s, e) =>
|
||||
{
|
||||
|
@ -136,7 +136,8 @@ namespace RageCoop.Client
|
||||
packet.LockStatus = veh.LockStatus;
|
||||
packet.LicensePlate = Call<string>(GET_VEHICLE_NUMBER_PLATE_TEXT, veh);
|
||||
packet.Livery = Call<int>(GET_VEHICLE_LIVERY, veh);
|
||||
if (v.MainVehicle == Game.Player.LastVehicle) packet.RadioStation = Util.GetPlayerRadioIndex();
|
||||
packet.RadioStation = v.MainVehicle == LastV
|
||||
? Util.GetPlayerRadioIndex() : byte.MaxValue;
|
||||
if (packet.EngineHealth > v.LastEngineHealth) packet.Flags |= VehicleDataFlags.Repaired;
|
||||
v.LastEngineHealth = packet.EngineHealth;
|
||||
}
|
||||
|
@ -150,6 +150,9 @@ namespace RageCoop.Client
|
||||
}
|
||||
|
||||
MainVehicle.SetDamageModel(DamageModel);
|
||||
|
||||
if (MainVehicle.Handle == V?.Handle && Util.GetPlayerRadioIndex() != RadioStation)
|
||||
Util.SetPlayerRadioIndex(MainVehicle.Handle, RadioStation);
|
||||
}
|
||||
|
||||
LastUpdated = Ticked;
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using GTA;
|
||||
@ -176,14 +177,24 @@ namespace RageCoop.Client
|
||||
return v;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the current radio index for player, returns 255 if there's none
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static byte GetPlayerRadioIndex()
|
||||
{
|
||||
return (byte)Call<int>(GET_PLAYER_RADIO_STATION_INDEX);
|
||||
}
|
||||
|
||||
public static void SetPlayerRadioIndex(int index)
|
||||
public static void SetPlayerRadioIndex(int playerVeh, int index)
|
||||
{
|
||||
Call(SET_RADIO_TO_STATION_INDEX, index);
|
||||
if (playerVeh == 0)
|
||||
playerVeh = Call<int>(GET_VEHICLE_PED_IS_IN, P.Handle, false);
|
||||
|
||||
if (index == byte.MaxValue)
|
||||
Call(SET_VEH_RADIO_STATION, playerVeh, "OFF");
|
||||
else
|
||||
Call(SET_RADIO_TO_STATION_INDEX, index);
|
||||
}
|
||||
|
||||
public static EntityPopulationType GetPopulationType(int handle)
|
||||
@ -200,7 +211,7 @@ namespace RageCoop.Client
|
||||
|
||||
[LibraryImport("kernel32.dll", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
|
||||
public static partial IntPtr GetModuleHandleW([MarshalAs(UnmanagedType.LPWStr)] string lpModuleName);
|
||||
|
||||
|
||||
#region -- POINTER --
|
||||
|
||||
private static int _steeringAngleOffset { get; set; }
|
||||
|
Submodule libs/ScriptHookVDotNetCore updated: 43df04d914...855995970d
Reference in New Issue
Block a user