예제 #1
0
        private async Task CheckSave()
        {
            if (mainMenu.requestSave)
            {
                mainMenu.requestSave = false;
                //TriggerServerEvent("rs:SaveRace", mainMenu.raceName, RaceEditor.GetCheckpointPos());
                TriggerServerEvent("rs:SaveRaceJson", mainMenu.raceName, RaceEditor.GetCheckpointPosJson());
                while (!isReceived)
                {
                    await Delay(100);

                    timerLocal += 100;

                    if (timerLocal >= 1500)
                    {
                        timerLocal = 0;
                        break;
                    }
                }

                // Notification above mini map
                API.SetNotificationTextEntry("STRING");
                API.AddTextComponentString(response == "OK" ? "Saved Successfully!" : "Save Failed!");
                API.DrawNotification(false, true);
            }
        }
예제 #2
0
        public static void Draw3DText(Vector3 Position, string text, int size, int font, int range)
        {
            Vector3 CameraPosition = API.GetGameplayCamCoord();
            float   Distance       = API.GetDistanceBetweenCoords(CameraPosition.X, CameraPosition.Y, CameraPosition.Z, Position.X, Position.Y, Position.Z, true);

            if (Distance <= TextRanges[range])
            {
                float SimpleScale   = (1 / Distance) * TextSizes[size];
                float FOV           = (1 / API.GetGameplayCamFov()) * 100;
                float AdjustedScale = SimpleScale * FOV;

                API.SetDrawOrigin(Position.X, Position.Y, Position.Z, 0);

                API.SetTextScale(0 * AdjustedScale, .35f * AdjustedScale);
                API.SetTextFont(TextFonts[font]);
                API.SetTextProportional(true);
                API.SetTextColour(255, 255, 255, 255);
                API.SetTextDropshadow(0, 0, 0, 0, 255);
                API.SetTextEdge(2, 0, 0, 0, 150);
                API.SetTextDropShadow();
                API.SetTextOutline();
                API.SetTextEntry("STRING");
                API.SetTextCentre(true);
                API.AddTextComponentString(text);
                API.DrawText(0, 0);

                API.ClearDrawOrigin();
            }
        }
예제 #3
0
        public async static void Summon()
        {
            Ped player = Game.Player.Character;

            Screen.ShowNotification("The coroner is on his way to you now!");

            // Van
            Vector3 spawnLocation = new Vector3();
            float   spawnHeading  = 0F;
            int     unusedVar     = 0;

            API.GetNthClosestVehicleNodeWithHeading(player.Position.X, player.Position.Y, player.Position.Z, 80, ref spawnLocation, ref spawnHeading, ref unusedVar, 9, 3.0F, 2.5F);
            await LoadModel((uint)VehicleHash.Burrito3);

            cVanEntity = await World.CreateVehicle(VehicleHash.Burrito3, spawnLocation, spawnHeading);

            cVanEntity.Mods.PrimaryColor      = VehicleColor.MetallicBlack;
            cVanEntity.Mods.LicensePlate      = $"SA C {random.Next(10)}";
            cVanEntity.Mods.LicensePlateStyle = LicensePlateStyle.BlueOnWhite3;

            // Van Blip
            cVanBlip = API.AddBlipForEntity(cVanEntity.Handle);
            API.SetBlipColour(cVanBlip, 40);
            API.BeginTextCommandSetBlipName("STRING");
            API.AddTextComponentString("Coroner");
            API.EndTextCommandSetBlipName(cVanBlip);

            // Driver
            await LoadModel((uint)PedHash.Doctor01SMM);

            cVanPed1 = await World.CreatePed(PedHash.Doctor01SMM, spawnLocation);

            cVanPed1.SetIntoVehicle(cVanEntity, VehicleSeat.Driver);
            cVanPed1.CanBeTargetted = false;

            // Passenger
            await LoadModel((uint)PedHash.Scientist01SMM);

            cVanPed2 = await World.CreatePed(PedHash.Scientist01SMM, spawnLocation);

            cVanPed2.SetIntoVehicle(cVanEntity, VehicleSeat.Passenger);
            cVanPed2.CanBeTargetted = false;

            // Configuration
            Vector3 targetLocation = new Vector3();
            float   targetHeading  = 0F;

            API.GetClosestVehicleNodeWithHeading(player.Position.X, player.Position.Y, player.Position.Z, ref targetLocation, ref targetHeading, 1, 3.0F, 0);
            cVanPed1.Task.DriveTo(cVanEntity, targetLocation, 10F, 20F, 262972);
            eventSpawned = true;
        }
예제 #4
0
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
        public async Task OnTick()
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
        {
            // Watermark
            API.SetTextFont(1);
            API.SetTextProportional(true);
            API.SetTextScale(0.0F, 0.6F);
            API.SetTextColour(192, 192, 192, 255);
            API.SetTextDropshadow(0, 0, 0, 0, 255);
            API.SetTextEdge(1, 0, 1, 0, 255);
            API.SetTextDropShadow();
            API.SetTextOutline();
            API.SetTextEntry("STRING");
            API.AddTextComponentString("~b~We~w~RP");
            API.DrawText(0.005F, 0.005F);

            API.SetTextFont(4);
            API.SetTextProportional(true);
            API.SetTextScale(0.0F, 0.5F);
            API.SetTextColour(192, 192, 192, 255);
            API.SetTextDropshadow(0, 0, 0, 0, 255);
            API.SetTextEdge(1, 0, 1, 0, 255);
            API.SetTextDropShadow();
            API.SetTextOutline();
            API.SetTextEntry("STRING");
            API.AddTextComponentString("v" + Assembly.GetExecutingAssembly().GetName().Version);
            API.DrawText(0.044F, 0.0058F);

            // Player Location Display
            // Coordinates
            int     playerPed      = API.GetPlayerPed(-1);
            Vector3 playerPosition = API.GetEntityCoords(playerPed, true);
            String  posX           = String.Format("{0:0.00}", playerPosition.X);
            String  posY           = String.Format("{0:0.00}", playerPosition.Y);
            String  posZ           = String.Format("{0:0.00}", playerPosition.Z);

            API.SetTextFont(4);
            API.SetTextScale(0.0F, 0.5F);
            API.SetTextColour(255, 255, 255, 255);
            API.SetTextDropshadow(0, 0, 0, 0, 255);
            API.SetTextEdge(1, 0, 1, 0, 255);
            API.SetTextDropShadow();
            API.SetTextOutline();
            API.SetTextEntry("STRING");
            API.AddTextComponentString("~r~X~w~: " + posX + "\n~r~Y~w~: " + posY + "\n~r~Z~w~: " + posZ);
            API.DrawText(0.005F, 0.042F);

            // Location
            String direction    = this.GetPlayerDirection(playerPed);
            float  safezoneSize = API.GetSafeZoneSize();
            float  screenWidth  = Screen.Width;
            float  screenHeight = Screen.Height;
            PointF offset       = new PointF((int)Math.Round((screenWidth - (screenWidth * safezoneSize)) / 2 + 1), (int)Math.Round((screenHeight - (screenHeight * safezoneSize)) / 2 - 2));

            Vector3 position  = API.GetEntityCoords(playerPed, true);
            float   xPosition = (0.145F + ((1.0F - safezoneSize) / 2));
            float   yPosition = (0.825F - ((1.0F - safezoneSize) / 2));

            uint streetNameHash   = 0;
            uint crossingRoadHash = 0;

            API.GetStreetNameAtCoord(position.X, position.Y, position.Z, ref streetNameHash, ref crossingRoadHash);

            String streetName       = API.GetStreetNameFromHashKey(streetNameHash);
            String streetNameOutput = streetName;
            String crossingRoad     = API.GetStreetNameFromHashKey(crossingRoadHash);

            if (crossingRoad != "")
            {
                streetNameOutput += " / " + crossingRoad;
            }

            String zoneName = Helper.GetZoneFullname(API.GetNameOfZone(position.X, position.Y, position.Z));

            API.SetTextFont(2);
            API.SetTextScale(0.0F, 0.9F);
            API.SetTextColour(255, 255, 255, 255);
            API.SetTextDropshadow(0, 0, 0, 0, 255);
            API.SetTextEdge(1, 0, 1, 0, 255);
            API.SetTextDropShadow();
            API.SetTextOutline();
            API.SetTextEntry("STRING");
            API.AddTextComponentString(direction);
            API.DrawText(xPosition, yPosition);

            API.SetTextFont(4);
            API.SetTextScale(0.0F, 0.6F);
            API.SetTextColour(198, 198, 198, 255);
            API.SetTextDropshadow(0, 0, 0, 0, 255);
            API.SetTextEdge(1, 0, 1, 0, 255);
            API.SetTextDropShadow();
            API.SetTextOutline();
            API.SetTextEntry("STRING");
            API.AddTextComponentString(streetNameOutput);
            API.DrawText(xPosition, yPosition + 0.047F);

            API.SetTextFont(2);
            API.SetTextScale(0.0F, 0.4F);
            API.SetTextColour(240, 200, 80, 255);
            API.SetTextDropshadow(0, 0, 0, 0, 255);
            API.SetTextEdge(1, 0, 1, 0, 255);
            API.SetTextDropShadow();
            API.SetTextOutline();
            API.SetTextEntry("STRING");
            API.AddTextComponentString(zoneName);
            API.DrawText(xPosition, yPosition + 0.085F);
        }