Exemplo n.º 1
0
        private void OnTick(object o, EventArgs e)
        {
            if (ArduinoInterface.IsAvailable())
            {
                if (WantedLevel != Game.Player.WantedLevel)
                {
                    WantedLevel = Game.Player.WantedLevel;
                    ArduinoInterface.SetLEDCount(WantedLevel);
                }

                Ped player = Game.Player.Character;
                if (player.Exists())
                {
                    if (player.IsAlive)
                    {
                        if (Function.Call <bool>(Hash.IS_PLAYER_BEING_ARRESTED, Game.Player.Handle, true))
                        {
                            SetHUDState(HUDState.Busted);
                        }
                        else
                        {
                            SetHUDState(HUDState.InfoCycle);
                            CheckCycle();
                            UpdateInfo();

                            if (Preferences.PrefersTimer())
                            {
                                Timer += Interval;
                                CheckTimer();
                            }
                        }
                    }
                    else
                    {
                        SetHUDState(HUDState.Wasted);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void OnTick(object o, EventArgs e)
        {
            if (ArduinoInterface.IsAvailable())
            {
                if (WantedLevel != Game.Player.WantedLevel)
                {
                    WantedLevel = Game.Player.WantedLevel;
                    ArduinoInterface.SetLEDCount(WantedLevel);
                }

                Ped player = Game.Player.Character;
                if (player.Exists())
                {
                    if (player.IsAlive)
                    {
                        if (Function.Call <bool>(Hash.IS_PLAYER_BEING_ARRESTED, player, true))
                        {
                            SetHUDState(HUDState.Busted);
                        }
                        else if (player.IsInVehicle())
                        {
                            Vehicle vehicle = player.CurrentVehicle;

                            Boolean stateChanged = false;
                            if (Timer >= MaxRotatingStateLength)
                            {
                                if (state == HUDState.VehicleHealth)
                                {
                                    SetHUDState(HUDState.VehicleSpeed);
                                }
                                else
                                {
                                    SetHUDState(HUDState.VehicleHealth);
                                }

                                stateChanged = true;
                            }
                            else if (state != HUDState.VehicleHealth && state != HUDState.VehicleSpeed)
                            {
                                stateChanged = SetHUDState(HUDState.VehicleSpeed);
                            }

                            switch (state)
                            {
                            case HUDState.VehicleSpeed:
                                if (stateChanged)
                                {
                                    ArduinoInterface.SetCursor(0, 0);
                                    ArduinoInterface.Print(vehicle.FriendlyName);
                                }

                                ArduinoInterface.SetCursor(0, 1);
                                float speed = vehicle.Speed;
                                if (Preferences.SpeedFormat == "mph")
                                {
                                    speed *= 2.236936292054f;
                                }
                                else
                                {
                                    speed *= 3.6f;
                                }

                                ArduinoInterface.Print("Speed: " + (Math.Round(speed).ToString() + Preferences.SpeedFormat).MinLength(6));
                                break;

                            case HUDState.VehicleHealth:
                                if (vehicle.BodyHealth != VehicleBodyHealth)
                                {
                                    VehicleBodyHealth = vehicle.BodyHealth;
                                    ArduinoInterface.SetCursor(8, 0);
                                    ArduinoInterface.Print((Math.Round(VehicleBodyHealth / 10).ToString() + "%").MinLength(4));
                                }

                                if (vehicle.EngineHealth != VehicleEngineHealth)
                                {
                                    VehicleEngineHealth = vehicle.EngineHealth;
                                    ArduinoInterface.SetCursor(8, 1);
                                    ArduinoInterface.Print((Math.Round(VehicleEngineHealth / 10).ToString() + "%").MinLength(4));
                                }

                                break;
                            }
                        }
                        else
                        {
                            if (Timer >= MaxRotatingStateLength)
                            {
                                if (state == HUDState.WorldInfo)
                                {
                                    SetHUDState(HUDState.PlayerHealth);
                                }
                                else
                                {
                                    SetHUDState(HUDState.WorldInfo);
                                }
                            }
                            else if (state != HUDState.WorldInfo && state != HUDState.PlayerHealth)
                            {
                                SetHUDState(HUDState.WorldInfo);
                            }

                            switch (state)
                            {
                            case HUDState.WorldInfo:
                                DateTime currentTime = new DateTime(World.CurrentDayTime.Ticks);
                                ArduinoInterface.SetCursor(0, 0);
                                ArduinoInterface.Print((currentTime.ToString(Preferences.HourFormat == "12h" ? "h:mmtt" : "HH:mm").ToLower() + " - " + WorldExtension.Weather).MinLength(12));
                                ArduinoInterface.SetCursor(0, 1);
                                ArduinoInterface.Print(World.GetZoneName(player.Position).MinLength(12));
                                break;

                            case HUDState.PlayerHealth:
                                if (player.Health != PlayerHealth)
                                {
                                    PlayerHealth = player.Health;
                                    ArduinoInterface.SetCursor(8, 0);
                                    ArduinoInterface.Print((PlayerHealth.ToString() + "%").MinLength(4));
                                }

                                if (player.Armor != PlayerArmor)
                                {
                                    PlayerArmor = player.Armor;
                                    ArduinoInterface.SetCursor(8, 1);
                                    ArduinoInterface.Print((PlayerArmor.ToString() + "%").MinLength(4));
                                }

                                break;
                            }
                        }
                    }
                    else
                    {
                        SetHUDState(HUDState.Wasted);
                    }
                }
            }

            Timer += Interval;
        }