Log in to reply
 

Problem with blips



  • Hi I have problem with blips when my script is loaded and I start delivery work its create like 1458 blips. I don't have idea what's wrong here. Can somebody help me and explain what I did wrong?

    using System;
    using System.Windows.Forms;
    using System.Drawing;
    using GTA;
    using GTA.Native;
    using GTA.Math;
    using GTA_V_Praca;
    
    namespace GTA_V_Praca
    {
        public class Main : Script
        {
            int workIndex = 0;
            bool workActive = true;
            static Blip mainBlip;
            static Vector3 createMainBlip = new Vector3(-195.4144f, -835.4664f, 30.72412f);
            Vehicle car;
    
            Blip destinationBlip;
            Vector3 destinationBlipPos = new Vector3(-2972.131f, 483.4448f, 15.42669f);
    
            Blip destinationBankBlip;
            Vector3 destinationBankBlipPos = new Vector3(-2957.326f, 480.4447f, 15.80684f);
    
            Blip bringBackCar;
            Vector3 bringBackCarPos = new Vector3(-178.5027f, -831.7009f, 30.4908f);
    
            public static void startWorkFunc()
            {
                UI.Notify("Mod Loaded");
                mainBlip = World.CreateBlip(createMainBlip);
                mainBlip.Sprite = (BlipSprite)408;
                mainBlip.Color = BlipColor.Yellow6;
                mainBlip.Name = "Praca";
                mainBlip.ShowRoute = false;
            }
    
            public void createDestinationBlip()
            {
                destinationBlip = World.CreateBlip(destinationBlipPos);
                if (destinationBlip.Exists())
                {
                    destinationBlip.Color = BlipColor.Green2;
                    destinationBlip.Sprite = (BlipSprite)207;
                    destinationBlip.Name = "Cel";
                    destinationBlip.ShowRoute = true;
                }
            }
    
            public void createDestinationBankBlip()
            {
                destinationBankBlip = World.CreateBlip(destinationBankBlipPos);
                if (destinationBankBlip.Exists())
                {
                    destinationBankBlip.Color = BlipColor.Yellow4;
                    destinationBankBlip.Sprite = (BlipSprite)1;
                    destinationBankBlip.Name = "Cel";
                    destinationBankBlip.ShowRoute = false;
                }
            }
    
            public void createBringBackCarBlip()
            {
                bringBackCar = World.CreateBlip(bringBackCarPos);
                if (bringBackCar.Exists())
                {
                    bringBackCar.Color = BlipColor.Red;
                    bringBackCar.Sprite = (BlipSprite)50;
                    bringBackCar.Name = "Cel";
                    bringBackCar.ShowRoute = true;
                }
            }
    
            public Main()
            {
                startWorkFunc();
                Tick += onTick;
                KeyDown += onKeyDown;
            }
    
            private void onTick(object sender, EventArgs e)
            {
                if (workActive)
                {
                    switch (workIndex)
                    {
                        case 0:
                            {
                                Vector3 spawnCarPos = new Vector3(-180.9704f, -838.5579f, 30.16903f);
                                World.DrawMarker(MarkerType.VerticalCylinder, createMainBlip, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(1.5f, 1.5f, 0.3f), Color.FromArgb(255, 200, 0));
                                if (Game.Player.Character.Position.DistanceTo(createMainBlip) < 1.5)
                                {
                                    Main.displayHelpTextThisFrame("Naciśnij ~INPUT_CONTEXT~, żeby wyjąć pojazd.");
                                    if (Game.IsEnabledControlJustPressed(2, GTA.Control.Context))
                                    {
                                        car = World.CreateVehicle(VehicleHash.Stockade, spawnCarPos, 160.7435f);
                                        Blip carBlip = car.AddBlip();
                                        carBlip.Sprite = (BlipSprite)477;
                                        carBlip.Color = BlipColor.Blue;
                                        Game.Player.Character.SetIntoVehicle(car, VehicleSeat.Driver);
                                        workIndex = 5;
                                    }
                                }
                                break;
                            }
                        case 5:
                            {
                                if (Game.Player.Character.IsInVehicle(car) || Game.Player.Character.IsSittingInVehicle(car))
                                {
                                    workIndex = 10;
                                }
                                else
                                {
                                    UI.ShowSubtitle("Wsiądź do pojazdu");
                                }
                                break;
                            }
                        case 10:
                            {
                                createDestinationBlip();
                                World.DrawMarker(MarkerType.VerticalCylinder, destinationBlipPos, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(5f, 5f, 2.2f), Color.FromArgb(255, 255, 0));
                                UI.ShowSubtitle("Zawieź worki z pieniędzmi do banku Fleeca.");
                                if (car.Position.DistanceTo(destinationBlipPos) < 5f)
                                {
                                    destinationBlip.Remove();
                                    workIndex = 15;
                                }
                                break;
                            }
                        case 15:
                            {
                                createDestinationBankBlip();
                                UI.ShowSubtitle("Zanieś worki z pieniędzmi na zaplecze banku.");
                                World.DrawMarker(MarkerType.VerticalCylinder, destinationBankBlipPos, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(1f, 1f, 0.3f), Color.FromArgb(255, 200, 0));
                                if (Game.Player.Character.Position.DistanceTo(destinationBankBlipPos) < 0.5f)
                                {
                                    UI.ShowSubtitle("Odłóż worki z pieniędzmi.");
                                    Main.displayHelpTextThisFrame("Naciśnij ~INPUT_CONTEXT~, żeby odłożyć worki.");
                                    if (Game.IsControlJustPressed(2, GTA.Control.Context))
                                    {
                                        destinationBankBlip.Remove();
                                        workIndex = 20;
                                    }
                                }
                                break;
                            }
                        case 20:
                            {
                                UI.Notify("Odkładanie worków...");
                                Game.Player.Character.FreezePosition = true;
                                Wait(3000);
                                Game.Player.Character.FreezePosition = false;
                                workIndex = 35;
                                break;
                            }
                        case 35:
                            {
                                Main.chooseRandomReward();
                                workIndex = 40;
                                break;
                            }
                        case 40:
                            {
                                createBringBackCarBlip();
                                World.DrawMarker(MarkerType.VerticalCylinder, bringBackCarPos, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(5f, 5f, 2.2f), Color.FromArgb(255, 200, 0));
                                UI.Notify("Odstaw pojazd");
                                if (car.Position.DistanceTo(bringBackCarPos) < 5f)
                                {
                                    car.Delete();
                                    workIndex = 0;
                                }
                                break;
                            }
                    }
                }
            }
    
            private void onKeyDown(object sender, KeyEventArgs e)
            {
    
            }
    
            public static void displayHelpTextThisFrame(string text)
            {
                Function.Call(Hash._SET_TEXT_COMPONENT_FORMAT, "STRING");
                Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text);
                Function.Call(Hash._0x238FFE5C7B0498A6, 0, 0, 1, -1);
            }
    
            public static void chooseRandomReward()
            {
                int randomMoney = Function.Call<int>(Hash.GET_RANDOM_INT_IN_RANGE, 500, 1500);
                Game.Player.Money += randomMoney;
                UI.Notify("You earned ~g~$" + randomMoney);
            }
    
            public static int GetRandomFromRange(int a, int b)
            {
                var rnd = new Random(DateTime.Now.Millisecond);
                int rs = rnd.Next(a, b);
                return rs;
            }
        }
    }
    
    

Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.