Log in to reply
 

C# Assassination script not working anymore!



  • So, I've been trying to make a script where you spawn this target and you have to kill them to get money. But recently when I have been trying to get the script to check if the target is dead every second, it has stopped working. This is a link to the error code that shows up the SHVDN2 command log.

    Code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Drawing;
    using System.Windows.Forms;
    using GTA;
    using GTA.Math;
    using GTA.Native;
    using GTA.NaturalMotion;
    using NativeUI;
    
    
    namespace Assassination_Script_V_1._0
    {
        public class Class1 : Script
        {
            //Varibles
            public Ped target;
            public bool yesDead = false;
            Vector3 playerNorth = Game.Player.Character.ForwardVector * 100;
            Vector3 playerSouth = Game.Player.Character.ForwardVector * 100;
            Vector3 PlayerEast = Game.Player.Character.RightVector * 100;
            Vector3 PlayerWest = Game.Player.Character.RightVector * 100;
            Vector3 pos = new Vector3();
            public int posRandomizer;
            public Blip targetBlip;
    
            public Class1()
            {
    
                Tick += OnTick;
                KeyDown += OnKeyDown;
                KeyUp += OnKeyUp;
            }
    
            public void OnTick(object sender, EventArgs e)
            {
                checkTargetDead();
                //var myPool = new TimerBarPool();
                //myPool.Draw();
            }
    
            void checkTargetDead()
            {
                if (target.IsDead )
                {
                    yesDead = true;
                }
            }
    
            public void OnKeyUp(object sender, KeyEventArgs e)
            {
    
            }
    
            public void OnKeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.P)
                {
                    posRandomizer = Function.Call<int>(Hash.GET_RANDOM_INT_IN_RANGE, 1, 100);
    
                    if (posRandomizer <= 25)
                    {
                        pos = playerNorth;
                    }
    
                    if (posRandomizer > 25 && posRandomizer <= 50)
                    {
                        pos = playerSouth;
                    }
    
                    if (posRandomizer > 50 && posRandomizer <= 75)
                    {
                        pos = PlayerEast;
                    }
    
                    if (posRandomizer > 75 && posRandomizer <= 100)
                    {
                        pos = PlayerWest;
                    }
    
                    GTA.UI.ShowSubtitle("Assassinate the ~r~target!");
                    target = World.CreateRandomPed(Game.Player.Character.Position + (Game.Player.Character.ForwardVector * 5));
                    target.CurrentBlip.Scale = 1;
                    target.CurrentBlip.IsFriendly = false;
                    target.CurrentBlip.Sprite = BlipSprite.Crosshair2;
                    World.GetSafeCoordForPed(pos, true);
    
                    if (yesDead == true)
                    {
                        GTA.UI.Notify("~g~Target has been assassinated! $2,000 has been sucessfully transfered to your bank account!");
                        Game.Player.Money = Game.Player.Money + 2000;
                    }
                }
    
                if(e.KeyCode == Keys.K)
                {
                    GTA.UI.ShowSubtitle("GTA 5 is still reading this file!");
                }
            }
        }
    }
    
    

    It worked before but it stopped working once I added something to check whether or not the target was dead of not. I put in the extra keycode k to test whether or not it reads to script but it seems to just pop up with the error in the command thing when the game loads up.

    Anyways any help would be much appreciated.


Log in to reply
 

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