Exemplo n.º 1
0
        private void PurchaseVehicleEvent(object[] args)
        {
            // Get the colors variables
            int primaryRed = 0, primaryGreen = 0, primaryBlue = 0;
            int secondaryRed = 0, secondaryGreen = 0, secondaryBlue = 0;

            // Get the vehicle's data
            var model = previewVehicle.Model.ToString();

            previewVehicle.GetCustomPrimaryColour(ref primaryRed, ref primaryGreen, ref primaryBlue);
            previewVehicle.GetCustomSecondaryColour(ref secondaryRed, ref secondaryGreen, ref secondaryBlue);

            // Get color strings
            var firstColor  = string.Format("{0},{1},{2}", primaryRed, primaryGreen, primaryBlue);
            var secondColor = string.Format("{0},{1},{2}", secondaryRed, secondaryGreen, secondaryBlue);

            // Destroy preview menu
            CloseCatalogEvent(null);

            // Destroy preview vehicle
            previewVehicle.Destroy();
            previewVehicle = null;

            // Enable the HUD
            Ui.DisplayHud(true);
            Ui.DisplayRadar(true);

            // Position the camera behind the character
            Cam.DestroyCam(previewCamera, true);
            Cam.RenderScriptCams(false, false, 0, true, false, 0);

            // Purchase the vehicle
            Events.CallRemote("purchaseVehicle", model, firstColor, secondColor);
        }
Exemplo n.º 2
0
        private static MapObject GetCrateInRange(Vehicle truck, float distance)
        {
            foreach (var crate in crateList)
            {
                if (crate.Position.DistanceTo(truck.Position) <= distance)
                {
                    return(crate);
                }
            }

            return(null);
        }
Exemplo n.º 3
0
        public static void RemoveSpeedometerEvent(object[] args)
        {
            if (seatbelt)
            {
                seatbelt = false;
                Events.CallRemote("toggleSeatbelt", seatbelt);
            }

            // Reset the vehicle's position
            lastPosition = null;

            // Save the kilometers and gas
            Events.CallRemote("saveVehicleConsumes", lastVehicle, kms, gas);

            // Reset the player's vehicle
            lastVehicle = null;
        }
Exemplo n.º 4
0
        private void PreviewCarShopVehicleEvent(object[] args)
        {
            // Get the variables from the arguments
            var model = args[0].ToString();

            if (previewVehicle != null)
            {
                previewVehicle.Destroy();
            }

            // Destroy the catalog
            Browser.DestroyBrowserEvent(null);

            switch (dealership)
            {
            case 2:
                previewVehicle = new Vehicle(Misc.GetHashKey(model), new Vector3(-878.5726f, -1353.408f, 0.1741f),
                                             90.0f);
                previewCamera = Cam.CreateCameraWithParams(Misc.GetHashKey("DEFAULT_SCRIPTED_CAMERA"), -882.3361f,
                                                           -1342.628f, 5.0783f, -20.0f, 0.0f, 200.0f, 90.0f, true, 2);
                break;

            default:
                previewVehicle = new Vehicle(Misc.GetHashKey(model), new Vector3(-31.98111f, -1090.434f, 26.42225f),
                                             180.0f);
                previewCamera = Cam.CreateCameraWithParams(Misc.GetHashKey("DEFAULT_SCRIPTED_CAMERA"), -37.83527f,
                                                           -1088.096f, 27.92234f, -20.0f, 0.0f, 250, 90.0f, true, 2);
                break;
            }

            // Make the camera point the vehicle
            Cam.SetCamActive(previewCamera, true);
            Cam.RenderScriptCams(true, false, 0, true, false, 0);

            // Disable the HUD
            Ui.DisplayHud(false);
            Ui.DisplayRadar(false);

            // Vehicle preview menu
            Browser.CreateBrowserEvent(new object[]
                                       { "package://statics/html/vehiclePreview.html", "checkVehiclePayable" });
        }
Exemplo n.º 5
0
        private void ShowCatalogEvent(object[] args)
        {
            // Destroy preview menu
            Browser.DestroyBrowserEvent(null);

            // Destroy the vehicle
            previewVehicle.Destroy();
            previewVehicle = null;

            // Enable the HUD
            Ui.DisplayHud(true);
            Ui.DisplayRadar(true);

            // Position the camera behind the character
            Cam.DestroyCam(previewCamera, true);
            Cam.RenderScriptCams(false, false, 0, true, false, 0);

            // Show the catalog
            Browser.CreateBrowserEvent(new object[]
                                       { "package://statics/html/vehicleCatalog.html", "populateVehicleList", dealership, carShopVehiclesJson });
        }
Exemplo n.º 6
0
        private void TestVehicleEvent(object[] args)
        {
            // Get the vehicle's data
            var model = previewVehicle.Model.ToString();

            // Destroy preview menu
            CloseCatalogEvent(null);

            // Destroy preview vehicle
            previewVehicle.Destroy();
            previewVehicle = null;

            // Enable the HUD
            Ui.DisplayHud(true);
            Ui.DisplayRadar(true);

            // Position the camera behind the character
            Cam.DestroyCam(previewCamera, true);
            Cam.RenderScriptCams(false, false, 0, true, false, 0);

            // Purchase the vehicle
            Events.CallRemote("testVehicle", model);
        }
Exemplo n.º 7
0
 private void OnPlayerEnterVehicleEvent(RAGE.Elements.Vehicle vehicle, int seatId)
 {
     Browser.ExecuteFunctionEvent(new object[] { "package://statics/statusBars/index.html", "showSpeedo" });
 }
Exemplo n.º 8
0
        public static void UpdateSpeedometer()
        {
            lastVehicle = Player.LocalPlayer.Vehicle;
            var currentPosition = lastVehicle.Position;

            // Get speedometer's data
            var velocity  = lastVehicle.GetVelocity();
            var health    = lastVehicle.GetHealth();
            var maxHealth = lastVehicle.GetMaxHealth();

            var healthPercent = (int)Math.Round((decimal)(health * 100) / maxHealth);
            var speed         = (int)Math.Round(
                Math.Sqrt(velocity.X * velocity.X + velocity.Y * velocity.Y + velocity.Z * velocity.Z) * 3.6f);

            // Get the distance and consume
            distance     = Vector3.Distance(currentPosition, lastPosition);
            consumed     = distance * Constants.CONSUME_PER_METER;
            lastPosition = currentPosition;

            if (gas - consumed <= 0.0f)
            {
                // The fuel tank is empty
                Events.CallRemote("stopPlayerCar");
                consumed = 0.0f;
            }

            // Get the total gas and kms
            var totalKms = Math.Round((double)(kms + distance) / 10) / 100 + " km";
            var totalGas = Math.Round((double)(gas - consumed) * 100) / 100 + " litros";

            // Draw the speedometer
            UIText.Draw("Combustible: ", new Point(1025, 560), 0.5f, Color.White, Font.ChaletComprimeCologne, false);
            UIText.Draw(totalGas, new Point(1175, 560), 0.5f, Color.White, Font.ChaletComprimeCologne, false);
            UIText.Draw("Kilometraje: ", new Point(1025, 590), 0.5f, Color.White, Font.ChaletComprimeCologne, false);
            UIText.Draw(totalKms, new Point(1175, 590), 0.5f, Color.White, Font.ChaletComprimeCologne, false);
            UIText.Draw("Kmph: ", new Point(1025, 650), 0.5f, Color.White, Font.ChaletComprimeCologne, false);
            UIText.Draw(speed.ToString(), new Point(1175, 650), 0.75f, Color.White, Font.ChaletComprimeCologne, false);
            UIText.Draw("Integridad: ", new Point(1025, 620), 0.5f, Color.White, Font.ChaletComprimeCologne, false);

            if (healthPercent < 30)
            {
                UIText.Draw(healthPercent + "%", new Point(1175, 620), 0.5f, Color.Red, Font.ChaletComprimeCologne,
                            false);
            }
            else if (healthPercent < 60)
            {
                UIText.Draw(healthPercent + "%", new Point(1175, 620), 0.5f, Color.Yellow, Font.ChaletComprimeCologne,
                            false);
            }
            else
            {
                UIText.Draw(healthPercent + "%", new Point(1175, 620), 0.5f, Color.White, Font.ChaletComprimeCologne,
                            false);
            }

            // Update the vehicle's values
            kms += distance;
            gas -= consumed;

            // Reinitialize the variables
            distance = 0.0f;
            consumed = 0.0f;
        }