public void HandlePacket(IClient client, PedSyncPacket packet) { List <PedSyncData> pedsToSync = new(); foreach (var syncData in packet.Syncs) { Ped pedElement = (Ped)this.elementCollection.Get(syncData.SourceElementId) !; if (pedElement != null) { if (pedElement.Syncer?.Client == client && pedElement.CanUpdateSync(syncData.TimeSyncContext)) { pedElement.RunAsSync(() => { if (syncData.Position != null) { pedElement.Position = syncData.Position.Value; } if (syncData.Rotation != null) { pedElement.PedRotation = syncData.Rotation.Value * (180 / MathF.PI); } if (syncData.Velocity != null) { pedElement.Velocity = syncData.Velocity.Value; } if (syncData.Health != null) { pedElement.Health = syncData.Health.Value; } if (syncData.Armor != null) { pedElement.Armor = syncData.Armor.Value; } if (syncData.IsOnFire != null) { pedElement.IsOnFire = syncData.IsOnFire.Value; } if (syncData.IsInWater != null) { pedElement.IsInWater = syncData.IsInWater.Value; } }); pedsToSync.Add(syncData); } } } var players = this.middleware.GetPlayersToSyncTo(client.Player, packet); packet.Syncs = pedsToSync; packet.SendTo(players); }