Kieran_S Posted February 17, 2021 Share Posted February 17, 2021 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 More sharing options...
LeeC22 Posted February 17, 2021 Share Posted February 17, 2021 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 More sharing options...
Kieran_S Posted February 17, 2021 Author Share Posted February 17, 2021 (edited) 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 February 17, 2021 by Kieran_S Link to comment Share on other sites More sharing options...
LeeC22 Posted February 17, 2021 Share Posted February 17, 2021 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 More sharing options...
Kieran_S Posted February 17, 2021 Author Share Posted February 17, 2021 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 More sharing options...
LeeC22 Posted February 17, 2021 Share Posted February 17, 2021 (edited) 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 February 17, 2021 by LeeC22 Link to comment Share on other sites More sharing options...
Kieran_S Posted February 17, 2021 Author Share Posted February 17, 2021 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 More sharing options...
LeeC22 Posted February 17, 2021 Share Posted February 17, 2021 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 More sharing options...
Kieran_S Posted February 17, 2021 Author Share Posted February 17, 2021 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 More sharing options...
LeeC22 Posted February 17, 2021 Share Posted February 17, 2021 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. Kieran_S 1 Link to comment Share on other sites More sharing options...
Kieran_S Posted February 17, 2021 Author Share Posted February 17, 2021 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now