How can I make the player lose the cops before the next part of the mission goes on?
-
Hi, I am making a script and wondered how i can make it so when i have a wanted level the next blip will not show and a subtitle of "lose the cops" will stay at the bottom, therefore, making me lose the cops before going forward in the mission.
Any help would be great.
Thanks.
-
exactly how you implement it would depend on the structure of your code.
But checking the wanted level is the basis.If (Game.Player.WantedLevel != 0) { // Player is wanted so display your subtitle. } else { // Player is not wanted, so the mission can continue. }
-
@mcal9909 Thanks a load
-
@mcal9909 Would it be possible for me to upload some code for you to guide me to where to put it as i have tried many differant ways but can not figure it out. i got it reading the "Lose the cops" at the bottom and then i lose them and it goes but the rest does not carry on after i lost them.
Thanks.
-
Discord would probably be the easiest way mcal9909#4168
Or upload it to pastebin / github or something and send me a link.
-
@mcal9909 Here is a pastebin link of my code.
Processing.cs - https://pastebin.com/SQ7L007.
Mission.cs - https://pastebin.com/iV8Wdth.Thanks.
-
Ok looking at your code, i think the easiest way is to add a new case for when the player is finished the mission but has a wanted level, enter this case after the robbery has happened. and leave it when the player is no longer wanted.
case MissionTask.LoseCops: { If (Game.Player.WantedLevel != 0) { GTA.UI.Screen.ShowSubtitle("Lose the cops"); } else { task = MissionTask.GoToSecretLocation; } break; }
or add another MissionTask variable called something like
previousTask
, and then in the relevant MissionTasks check if the player is wanted. If so store the current taskpreviousTask = task;
and then settask = MissionTask.LoseCops;
and break out of the current task, then at the end of LoseCops when the player is no longer wanted settask = previousTask;
to carry on with the mission.
-
@mcal9909 OK. Thank you a tonne for the help. I'll be sure to add that to my script.
-
@mcal9909 I have put it into my code and i get the 'lose the cops' at the bottom but it also shows the waypoint. Is there something i have don wrong there? https://pastebin.com/P5ztiCE I implemented it like this.
-
not sure, do you mean destinationBlip? if so just hide it or delete it when set
task = MissionTask.LoseCops;
and unhide it / add it back in when you settask = MissionTask.GotoSecretLocation;
-
@mcal9909 Not the destinationBlip. It is the getawayVehicle blip that is showing when it shouldn't.
Thanks.
-
void Processing_LoseCops() { if(getawayVehicle.AttachedBlip.Exists()) getawayVehicle.AttachedBlip.Delete(); if(Game.Player.WantedLevel != 0) { GTA.UI.Screen.ShowSubtitle("Lose the cops"); } else { task = MissionTask.GoToSecretLocation; } }
You are only removing the blip in Processing_GetBackIntoVehicle(), if the player is in the vehicle, but you are moving to LoseCops no matter the state. So you are moving to LoseCops before the blip gets a chance to be removed.
-
@mcal9909 When i use that script here https://pastebin.com/zYmb4s5 i crashes saying there is an error on line 173. I checked but I can not see and issue, however, i am quite new to the coding.
Thanks.
-
@Kieran_S
Tryif(getawayVehicle.AttachedBlip != null && getawayVehicle.AttachedBlip.Exists()) getawayVehicle.AttachedBlip.Delete();
Or make sure the player enters the vehicle and you delete the blip before moving into LoseCops.
-
@mcal9909 This works. Thank you for the help you gave. Just to ask 1 more thing if that is ok. Do you know why sometimes when i make a blip on the map it makes the one i want it to but then add thousands more standard red ones on top? It happened quite a few times but i moved things randomly and it seemed to work. I can't find anything online about it either. If you could let me know why this happens it would be great so I can avoid it from happening.
-
@Kieran_S sounds like the code for adding or creating the blip is running on concurrent frames. Always check
if (blip == null && !blip.Exists())
to make sure the blip isnt already present before.
-
@mcal9909 Nice one. Thanks a lot. You have been a massive help
-
This post is deleted!