Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

[C#] Marker issue


Kieran_S
 Share

Recommended Posts

Hi all,

Recently I have had this issue where my marker is flickering in-game. I have use markers in this exact way in the past and they have worked OK. If you can spot anything wrong with this code, it would be great if you could let me know.

 

case 100:
                        {                            
                            if (!player.IsInRangeOf(new Vector3(1000.872f, -1558.48f, 30.76293f), 3f))
                            {
                                World.DrawMarker(MarkerType.VerticalCylinder, new Vector3(1000.872f, -1558.48f, 29.76293f), Vector3.Zero, Vector3.Zero, new Vector3(3.5f, 3.5f, 1.1f), System.Drawing.Color.Yellow);
                            }
                            //check to see if player at van drop off
                            if (World.GetDistance(player.Position, new Vector3(1000.872f, -1558.48f, 29.76293f)) < 3f && LostMCVan.IsStopped)
                            {
                                //delete van dropoff blip
                                VanDropOffBlip.Remove();
                                Blips.Remove(VanDropOffBlip);
                                //create motorcycle blip
                                MotorCycleBlip = World.CreateBlip(MotorCycle.Position);
                                MotorCycleBlip.Sprite = BlipSprite.GangBike;
                                MotorCycleBlip.Color = BlipColor.Blue;
                                MotorCycleBlip.Name = "Motorcycle";
                                MotorCycleBlip.IsShortRange = true;
                                MotorCycleBlip.ShowRoute = false;
                                Blips.Add(MotorCycleBlip);
                                SceneIndex = 105;
                            }
                            break;
                        }

 

Any help would be great.

 

Thanks.

Link to comment
Share on other sites

Two things spring to mind.

1) That case condition isn't being triggered every frame, causing the marker to not be drawn when it isn't.

2) The interval on your Tick is longer than the interval between frame updates.

 

Markers have to be drawn every frame, so only missing a frame can generally cause them to flicker.

Link to comment
Share on other sites

11 minutes ago, LeeC22 said:

Two things spring to mind.

1) That case condition isn't being triggered every frame, causing the marker to not be drawn when it isn't.

2) The interval on your Tick is longer than the interval between frame updates.

 

Markers have to be drawn every frame, so only missing a frame can generally cause them to flicker.

OK, thanks. How do I fix this issue then as I don't want the marker to be there all the time? Just when the van is being to be dropped off.

Edited by Kieran_S
Link to comment
Share on other sites

1 minute ago, Kieran_S said:

OK, thanks. How do I fix this issue then as I don't want the marker to be there all the time. Just when the van is being to be dropped off?

Only you know how the rest of your code works, so you have to work out if it's one of the things I mentioned first.

Link to comment
Share on other sites

2 minutes ago, LeeC22 said:

Only you know how the rest of your code works, so you have to work out if it's one of the things I mentioned first.

OK, how do I know what my tick interval is?

Link to comment
Share on other sites

3 minutes ago, Kieran_S said:

OK, how do I know what my tick interval is?

If you don't set it yourself it will be zero by default as far as I know. I always set it to zero as part of my default setup.

 

Every project I create comes default with this in the constructor:

Tick += onTick;
KeyUp += onKeyUp;
Aborted += onAborted;

Interval = 0;

 

Edited by LeeC22
Link to comment
Share on other sites

9 minutes ago, LeeC22 said:

If you don't set it yourself it will be zero by default as far as I know. I always set it to zero as part of my default setup.

 

Every project I create comes default with this in the constructor:

Tick += onTick;
KeyUp += onKeyUp;
Aborted += onAborted;

Interval = 0;

 

OK, I use the same template for all my scripts. I can't remember where I got it from though. 

Tick += onTick;
KeyDown += onKeyDown;

That is all that is in mine.

Link to comment
Share on other sites

3 minutes ago, Kieran_S said:

OK, I use the same template for all my scripts. I can't remember where I got it from though. 

Tick += onTick;
KeyDown += onKeyDown;

That is all that is in mine.

 

Then your interval will be zero, so that isn't the problem unless part of your mod is taking so much time that it is taking longer than a frame update to run, causing it to skip a frame.

 

I would advise adding the Aborted handler because that fires when you hit insert, so you can do any cleanup code in there before the script closes... like getting rid of created Blips etc...

 

But based on what you have said, then I guess your case condition isn't being met every frame.

Link to comment
Share on other sites

3 minutes ago, LeeC22 said:

 

Then your interval will be zero, so that isn't the problem unless part of your mod is taking so much time that it is taking longer than a frame update to run, causing it to skip a frame.

 

I would advise adding the Aborted handler because that fires when you hit insert, so you can do any cleanup code in there before the script closes... like getting rid of created Blips etc...

 

But based on what you have said, then I guess your case condition isn't being met every frame.

On the mission currently the I have coded I have added some aborted for the vehicles, peds and blips. I have even tried to add the marker to its own case with no other code to see if it was the other code in the case slowing it down but didn't have much luck with that either.

Link to comment
Share on other sites

16 minutes ago, Kieran_S said:

On the mission currently the I have coded I have added some aborted for the vehicles, peds and blips. I have even tried to add the marker to its own case with no other code to see if it was the other code in the case slowing it down but didn't have much luck with that either.

 

Move the marker code outside the switch statement, so it will happen every time, check if it still flickers.

 

Switch-Case is a brilliant system but you can get caught out by its linearity. You can only process one case each time, so sometimes you have to move things outside that conditional checking to make sure it can exist in every possible situation.

Link to comment
Share on other sites

12 minutes ago, LeeC22 said:

 

Move the marker code outside the switch statement, so it will happen every time, check if it still flickers.

 

Switch-Case is a brilliant system but you can get caught out by its linearity. You can only process one case each time, so sometimes you have to move things outside that conditional checking to make sure it can exist in every possible situation.

OK, thanks for the advice. I will move it outside of the switch.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.