Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Forms;
  7. using GTA;
  8. using GTA.Native;
  9.  
  10. namespace TrackersV
  11. {
  12.     public class TrackersV : Script
  13.     {
  14.         public TrackersV()
  15.         {
  16.             KeyDown += OnKeyDown;
  17.         }
  18.        
  19.         private void OnKeyDown(object source, EventArgs e)
  20.         {
  21.             if (e.KeyCode == Keys.J)
  22.             {
  23.                 AddBlipToTargetedEntity();
  24.             }
  25.         }
  26.        
  27.         private void AddPlayerBlip()
  28.         {
  29.             Entity Target;
  30.             Target = Game.Player.GetTargetedEntity();
  31.             // Instead of Entity == null, you could also use "Exists()", which checks both
  32.             // if the entity is null and if not, runs DOES_ENTITY_EXIST (so you don't use stale entity handles)
  33.             if (Target != null)
  34.             {
  35.                 if (Target.CurrentBlip == null)
  36.                 {
  37.                     BlipColor blipColor;
  38.                     if (Game.Player.Character.Model == PedHash.Michael)
  39.                     {
  40.                         blipColor = BlipColor.Michael;
  41.                     }
  42.                     else if (Game.Player.Character.Model == PedHash.Franklin)
  43.                     {
  44.                         blipColor = BlipColor.Franklin;
  45.                     }
  46.                     else if (Game.Player.Character.Model == PedHash.Trevor)
  47.                     {
  48.                         blipColor = BlipColor.Trevor;
  49.                     }
  50.                     else
  51.                     {
  52.                         blipColor = BlipColor.Freemode;
  53.                     }
  54.                     Target.AddBlip();
  55.                     Target.CurrentBlip.Sprite = BlipSprite.BigCircle;
  56.                     Target.CurrentBlip.Color = blipColor;
  57.                     Target.CurrentBlip.Name = Target.Model.ToString();
  58.                 }
  59.                 else // "if (Target.CurrentBlip != null)" is not needed here
  60.                 {
  61.                     Target.CurrentBlip.Remove();
  62.                 }
  63.             }
  64.             // Here was your "else", and Target is always null here
  65.         }
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement