Beispiel #1
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);
        }