Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using GTA;
- using GTA.Native;
- namespace TrackersV
- {
- public class TrackersV : Script
- {
- public TrackersV()
- {
- KeyDown += OnKeyDown;
- }
- private void OnKeyDown(object source, EventArgs e)
- {
- if (e.KeyCode == Keys.J)
- {
- AddBlipToTargetedEntity();
- }
- }
- private void AddPlayerBlip()
- {
- Entity Target;
- Target = Game.Player.GetTargetedEntity();
- // Instead of Entity == null, you could also use "Exists()", which checks both
- // if the entity is null and if not, runs DOES_ENTITY_EXIST (so you don't use stale entity handles)
- if (Target != null)
- {
- if (Target.CurrentBlip == null)
- {
- BlipColor blipColor;
- if (Game.Player.Character.Model == PedHash.Michael)
- {
- blipColor = BlipColor.Michael;
- }
- else if (Game.Player.Character.Model == PedHash.Franklin)
- {
- blipColor = BlipColor.Franklin;
- }
- else if (Game.Player.Character.Model == PedHash.Trevor)
- {
- blipColor = BlipColor.Trevor;
- }
- else
- {
- blipColor = BlipColor.Freemode;
- }
- Target.AddBlip();
- Target.CurrentBlip.Sprite = BlipSprite.BigCircle;
- Target.CurrentBlip.Color = blipColor;
- Target.CurrentBlip.Name = Target.Model.ToString();
- }
- else // "if (Target.CurrentBlip != null)" is not needed here
- {
- Target.CurrentBlip.Remove();
- }
- }
- // Here was your "else", and Target is always null here
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement