Bicycle color synchronization. Fixed server crash

This commit is contained in:
EntenKoeniq
2021-11-24 00:12:25 +01:00
parent f6a49fe87f
commit 902acdd798
3 changed files with 11 additions and 14 deletions

View File

@ -297,6 +297,13 @@ namespace CoopClient
} }
#region -- VEHICLE SYNC -- #region -- VEHICLE SYNC --
if (VehicleColors != null && VehicleColors != LastVehicleColors)
{
Function.Call(Hash.SET_VEHICLE_COLOURS, MainVehicle, VehicleColors[0], VehicleColors[1]);
LastVehicleColors = VehicleColors;
}
if (Character.IsOnBike && MainVehicle.ClassType == VehicleClass.Cycles) if (Character.IsOnBike && MainVehicle.ClassType == VehicleClass.Cycles)
{ {
bool isFastPedaling = Function.Call<bool>(Hash.IS_ENTITY_PLAYING_ANIM, Character.Handle, PedalingAnimDict(), "fast_pedal_char", 3); bool isFastPedaling = Function.Call<bool>(Hash.IS_ENTITY_PLAYING_ANIM, Character.Handle, PedalingAnimDict(), "fast_pedal_char", 3);
@ -320,13 +327,6 @@ namespace CoopClient
return; return;
} }
if (VehicleColors != null && VehicleColors != LastVehicleColors)
{
Function.Call(Hash.SET_VEHICLE_COLOURS, MainVehicle, VehicleColors[0], VehicleColors[1]);
LastVehicleColors = VehicleColors;
}
if (VehicleMods != null && VehicleMods != LastVehicleMods) if (VehicleMods != null && VehicleMods != LastVehicleMods)
{ {
Function.Call(Hash.SET_VEHICLE_MOD_KIT, MainVehicle, 0); Function.Call(Hash.SET_VEHICLE_MOD_KIT, MainVehicle, 0);

View File

@ -88,12 +88,9 @@ namespace CoopClient
return result; return result;
} }
public static Entities.EntitiesPlayer GetPlayer( long playerId ) public static Entities.EntitiesPlayer GetPlayer(long playerId)
{ {
if (Main.Players.ContainsKey(playerId)) return Main.Players.ContainsKey(playerId) ? Main.Players[playerId] : null;
return Main.Players[playerId];
else
return null;
} }
public static bool IsMenuVisible() public static bool IsMenuVisible()

View File

@ -36,7 +36,7 @@ namespace CoopServer
private void ThreadLoop() private void ThreadLoop()
{ {
while (_hasToStop) do
{ {
if (_actionQueue.Count != 0) if (_actionQueue.Count != 0)
{ {
@ -48,7 +48,7 @@ namespace CoopServer
// 16 milliseconds to sleep to reduce CPU usage // 16 milliseconds to sleep to reduce CPU usage
Thread.Sleep(1000 / 60); Thread.Sleep(1000 / 60);
} } while (_hasToStop);
} }
public bool InvokeModPacketReceived(long from, long target, string mod, byte customID, byte[] bytes) public bool InvokeModPacketReceived(long from, long target, string mod, byte customID, byte[] bytes)