Jump to content
Fiskey111

Secondary Callouts Help!

Recommended Posts

So I'm going to use this as a thread for all my questions!  (Saw someone recommend this and I think it's a great idea!

Edited by fiskey111
Updated topic

Share this post


Link to post
Share on other sites

Let's try solving the first problem first (haha?). Make sure that your End method is even being called in the first place, by ensuring that your vehicles / peds are being deleted on call out completion. If not, then your end method is not being called / executed.

Try getting the call out to end by:

Killing the suspect / arresting the suspect / force ending the call out by pressing X.

I'm thinking that your if statement isn't even being called because your state  does not equal your enum. 

If you'd like to post more of your code, please do :)

Share this post


Link to post
Share on other sites

The problem with your EMS callout is in OnBeforeCalloutDisplayed(). You put " if (Ambulance.Exists()) return false; " so everytime the ambulance exists your callout will be aborted, it should be " if (!Ambulance.Exists()) return false; ", note the "!" symbol

Share this post


Link to post
Share on other sites
8 hours ago, tanu1215 said:

Let's try solving the first problem first (haha?). Make sure that your End method is even being called in the first place, by ensuring that your vehicles / peds are being deleted on call out completion. If not, then your end method is not being called / executed.

Try getting the call out to end by:

Killing the suspect / arresting the suspect / force ending the call out by pressing X.

I'm thinking that your if statement isn't even being called because your state  does not equal your enum. 

If you'd like to post more of your code, please do :)

Thanks! I just figured it out!  It was a stupid mistake!

36 minutes ago, alexguirre said:

The problem with your EMS callout is in OnBeforeCalloutDisplayed(). You put " if (Ambulance.Exists()) return false; " so everytime the ambulance exists your callout will be aborted, it should be " if (!Ambulance.Exists()) return false; ", note the "!" symbol

Oh my goodness, I can't believe the mistake was that simple! I didn't even notice that!! Thank you so much!

Share this post


Link to post
Share on other sites
3 hours ago, Stealth22 said:

The computer only does what it's told to do. :turned:

At least we don't get a certain robot war problem cough cough

8 hours ago, fiskey111 said:

Thanks! I just figured it out!  It was a stupid mistake!

Oh my goodness, I can't believe the mistake was that simple! I didn't even notice that!! Thank you so much!

What was the mistake ?

Share this post


Link to post
Share on other sites
2 hours ago, tanu1215 said:

At least we don't get a certain robot war problem cough cough

What was the mistake ?

If you look here:

  //A simple check, if our pursuit has ended we end the callout
                if (state == EShootingState.DecisionMade && !Functions.IsPursuitStillRunning(pursuit))
                {
                    this.End();
                }
            }

The bolded bracket was from the original "if" statement from the callout logic, which I accidentally carried below to that if statement.

 

Thanks for all your help!  I have two more questions:

What's the best way to spawn perps?

I'm currently using

                            perp3 = new Ped(Cop1.GetOffsetPosition(new Vector3(0, 10f, 0)));
                            perp4 = new Ped(Cop1.GetOffsetPosition(new Vector3(0, 12f, 0)));

to spawn them, but I've noticed the spawning is a bit annoying (twice I've had them spawn in buildings, and once on the roof).  Is there any other way to spawn them?

Last question:

How can I achieve more randomness in my callouts.  Currently I'm using the

"int r = new Random().Next(1, 4);" and then within the if statement an "if (new Random().Next (1, 3) == 2)" but I've found you can only use that twice and only in the "if" part.  Any other methods?

Share this post


Link to post
Share on other sites

Create one Random()  instance and use it everywhere in your Plugin instead of making a new random() every time. 

For spawning you could use World. GetNextPositionOnStreet() to get a relatively safe spawn location for a ped :) 

Share this post


Link to post
Share on other sites
21 hours ago, Albo1125 said:

Create one Random()  instance and use it everywhere in your Plugin instead of making a new random() every time. 

For spawning you could use World. GetNextPositionOnStreet() to get a relatively safe spawn location for a ped :) 

This...there is also a native for finding ped-safe coordinates. I forget exactly what it's called. Its not 100% reliable though...I ended up running that native 5 times I think, expanding the distance each time. If it still fails, then I use GetNextPositionOnStreet(). It at least minimizes the amount of times that they spawn in the middle of the road.

Share this post


Link to post
Share on other sites
47 minutes ago, Stealth22 said:

This...there is also a native for finding ped-safe coordinates. I forget exactly what it's called. Its not 100% reliable though...I ended up running that native 5 times I think, expanding the distance each time. If it still fails, then I use GetNextPositionOnStreet(). It at least minimizes the amount of times that they spawn in the middle of the road.

This native GET_SAFE_COORD_FOR_PED

Share this post


Link to post
Share on other sites
23 hours ago, Albo1125 said:

Create one Random()  instance and use it everywhere in your Plugin instead of making a new random() every time. 

For spawning you could use World. GetNextPositionOnStreet() to get a relatively safe spawn location for a ped :) 

So do I do my Random() in the beginning in the namespace, then just refer back to it when I want?  What do I put under it, normally I do 

spawn perp3, give gun, make them fight, make them run, or any combination of them.  (Sorry, I'm still not too good with coding!)

1 hour ago, Stealth22 said:

This...there is also a native for finding ped-safe coordinates. I forget exactly what it's called. Its not 100% reliable though...I ended up running that native 5 times I think, expanding the distance each time. If it still fails, then I use GetNextPositionOnStreet(). It at least minimizes the amount of times that they spawn in the middle of the road.

Right, I use that for the spawnpoint, but the issue is that I spawn vehicles and peds off of that spawnpoint.  I'm going to try something using this though and will report back!

1 hour ago, alexguirre said:

This native GET_SAFE_COORD_FOR_PED

Haha, that is way above my skill level!  I wish I could understand how to use it!

Another question, too.  How in the world do I get a route to my blips?  I've tried "CopBlip.EnableRoute(Color.Blue);" and it only works when I do it inside my if, else statements.  The issue is I have those set up not to start the callout spawning until a certain distance away, which means the person won't have the route for half the distance.  I tried putting it below Process() and base.Process() but  it won't work and just crashes.  Any ideas? 

 

Thank you guys for helping me!  (I'm assuming you tried my plugin and saw how bad the spawns are, haha)

Edited by fiskey111
Added another question!

Share this post


Link to post
Share on other sites
4 hours ago, fiskey111 said:

So do I do my Random() in the beginning in the namespace, then just refer back to it when I want?  What do I put under it, normally I do 

spawn perp3, give gun, make them fight, make them run, or any combination of them.  (Sorry, I'm still not too good with coding!)

Right, I use that for the spawnpoint, but the issue is that I spawn vehicles and peds off of that spawnpoint.  I'm going to try something using this though and will report back!

Haha, that is way above my skill level!  I wish I could understand how to use it!

Another question, too.  How in the world do I get a route to my blips?  I've tried "CopBlip.EnableRoute(Color.Blue);" and it only works when I do it inside my if, else statements.  The issue is I have those set up not to start the callout spawning until a certain distance away, which means the person won't have the route for half the distance.  I tried putting it below Process() and base.Process() but  it won't work and just crashes.  Any ideas? 

 

Thank you guys for helping me!  (I'm assuming you tried my plugin and saw how bad the spawns are, haha)

Did you put the EnableRoute() under your Attatchblip()?

 CopBlip = myCopCar.AttachBlip();
  CopBlip.Color = Color.Blue;

CopBlip.EnableRoute();

Share this post


Link to post
Share on other sites

I have two questions so far:

1. How do I make an ambient scenario?  I assume it's using "WorldEventInfoAttribute.WorldEventInfoAttribute(string, int)" but I have no clue how to use that...

2. Is there a way to give my ped body armor?

Thank you!

Share this post


Link to post
Share on other sites
9 hours ago, fiskey111 said:

I have two questions so far:

1. How do I make an ambient scenario?  I assume it's using "WorldEventInfoAttribute.WorldEventInfoAttribute(string, int)" but I have no clue how to use that...

2. Is there a way to give my ped body armor?

Thank you!

1. What exactly are you thinking of?

2. ped.Armor = 100;

Share this post


Link to post
Share on other sites
1 hour ago, Albo1125 said:

1. What exactly are you thinking of?

2. ped.Armor = 100;

1. Well my hope is to basically have a ped (either spawned or grabbed from the environment a small distance away) get a gun and start shooting the player.

2. Wow I literally could not find that anywhere....  Didn't know that was so simple....

And the third question I forgot...

3. I want to make the unit spawning in my callouts specific to the area.  Like in Blaine County a sheriff unit spawns.  I'm assuming it's using EWorldZone._____, but I can't figure out how to use it to register the area....

4. Any idea why these cops don't leave after my callouts done?  These are the backup units that responded CODE3 to the location.  I can't figure out why they don't leave.

Spoiler

help2.thumb.jpg.ef08b5126e89646135c190a6

 

Edited by fiskey111
Added a 4th question!

Share this post


Link to post
Share on other sites

What I'm doing for ambient events, is starting a new GameFiber as part of my "OnDuty" function. This fiber then does the random check for an ambient event, calling the relevant code if one gets triggered, then sleeps for 60 seconds, all within a while(true) loop (the 60 seconds is primarily for testing, it should be longer than that to avoid spamming the user with events). Not sure if this is the best way to do it, but it works.

Share this post


Link to post
Share on other sites

Hi everyone,

So I'm running into something new with 0.3 (at least from what I've noticed)- in my Gang Attack callout I call in backup units CODE 3 to the scene (I don't put the suspects in a pursuit since they'll flee and not fight).

However, when the callout ends and calls CODE 4 the backup units just sit there and don't leave the scene (even if the cops are alive).  

Check this video- you can see the units just sitting there with one officer standing at his car)

 

Any ideas on how to fix this?  Or is this just something with 0.3?  (I haven't played 0.3 much [only like 15 mins] so I'm not sure how the backup usually acts with CODE 3 response)

Thanks!

Share this post


Link to post
Share on other sites

Hi guys!

Another question!  I want to check to see if a callout is in a specific state (like state == EOfficerShotState.Arrived)

How can I accomplish this?  I've tried but I can't figure it out. Here's my code:

Spoiler

        public static void OnItemSelect(UIMenu sender, UIMenuItem selectedItem, int index)
        {
            if (sender != mainMenu) return;

            if (selectedItem == saveofficer && OfficerDown.EOfficerDownState.OnScene)
            {
                Call SaveOfficer(); somehow too
            }

That isn't working- so how can I do that?  Is there another way?  I don't want to player to crash if they select the wrong thing.

Thanks!!

Share this post


Link to post
Share on other sites
9 hours ago, fiskey111 said:

Hi guys!

Another question!  I want to check to see if a callout is in a specific state (like state == EOfficerShotState.Arrived)

How can I accomplish this?  I've tried but I can't figure it out. Here's my code:

  Hide contents

        public static void OnItemSelect(UIMenu sender, UIMenuItem selectedItem, int index)
        {
            if (sender != mainMenu) return;

            if (selectedItem == saveofficer && OfficerDown.EOfficerDownState.OnScene)
            {
                Call SaveOfficer(); somehow too
            }

That isn't working- so how can I do that?  Is there another way?  I don't want to player to crash if they select the wrong thing.

Thanks!!

if (OfficerDown == EOfficerDownState.OnScene) or something similar. You should check a custom enum variable against one of the values; in the code above, you don't seem to be checking an enum but a bool.

Share this post


Link to post
Share on other sites
12 hours ago, Albo1125 said:

if (OfficerDown == EOfficerDownState.OnScene) or something similar. You should check a custom enum variable against one of the values; in the code above, you don't seem to be checking an enum but a bool.

 

4 hours ago, Stealth22 said:

See my inheritance example on the GitHub repo: https://github.com/LMSDev/LSPDFR-API/tree/master/API%20Examples/InheritanceExample

I've got a callout state enum in there. Its in the CalloutBase class, which is inherited by each of the callout classes.

There are two issues I'm running into:

1.  Apparently you can't use an enum in a static class (I'm still not 100% sure with all the names in coding, but I have an idea of what each are)

I try to but it won't register the enum (I even made a common one like yours, Stealth22)

2.  I can't call another process from a callout inside the static voids (again, not quite sure why)

I try to call OfficerDown.Process() inside a part of the RageNativeUI [ public static void OnItemSelect(.....) ] but it won't let me either!

I'm pretty fed up!  I wanted to make this work so the player can select audio files to add realism and variation (and interaction) but I might just end up forcing specific audio if I can't get this to work.

Share this post


Link to post
Share on other sites

You can't call your Process function from Rage Native UI. In fact, you don't call it at all, LSPDFR does. 

Your callout class should not be static. Think of static classes as one entity. You can't create an instance of a static class. Non static classes, you have to create an instance of in order to use. 

I'm on my phone at the moment, so I can't explain it to you in much detail. I suggest you look up some C# tutorials to get an idea of the terminology. You can also check out the examples in the GitHub repository. 

Share this post


Link to post
Share on other sites
9 hours ago, Stealth22 said:

You can't call your Process function from Rage Native UI. In fact, you don't call it at all, LSPDFR does. 

Your callout class should not be static. Think of static classes as one entity. You can't create an instance of a static class. Non static classes, you have to create an instance of in order to use. 

I'm on my phone at the moment, so I can't explain it to you in much detail. I suggest you look up some C# tutorials to get an idea of the terminology. You can also check out the examples in the GitHub repository. 

Right, sorry.  I probably should have explained myself better...  I know you can't call process, I was using that as a general function; I'd like to call a function that is in my callouts and is called from my process function, OfficerShotSave(), a separate function that is inside the callout class.

The static classes I was talking about were a part of the NativeUI, sorry, I should have been more specific!

I'm definitely going to try to find some tutorials on using static classes and calling things from them!

Thanks!

Share this post


Link to post
Share on other sites

Just as an update, I found a way to solve my problems!  I'm able to check the enum state of the RageNativeUI, which will allow me to check in my Callouts if a certain button has been pressed!  (I hope that makes sense, haha).  Thank you for your help guys!

Share this post


Link to post
Share on other sites

Hi Everyone!

So I'm coding for my restraining order callout (preparing for the audio, so when you see a subtitle it'll be audio).

For some reason when I get to process "GoodTalk1()" it runs it once, displays the subtitle, but then won't keep my GoodTalk2() running.  Any ideas as to how to fix this?

To simplify it-
GoodTalk1():  Two variations, if variation 2 [good] is active, the ped will say something that I want the cop to respond to by pressing an option in the menu, which is what GoodTalk2() is checking for.

The issue is that it seems to run GoodTalk2() once, (I used notifications to check to see when it ran) then it just abandons it.  So I'm trying to figure out how to keep this process running.  Thanks!

If you check the 2nd spoiler you can see a successful process that's above GoodTalk1() - I tried using the same idea but it just won't work.

Spoiler

        public void GoodTalk1()
        {
            if (state4 == EAudioState.GoodTalk1)
            {
                // Good choice!
                state4 = EAudioState.Neutral;
                int b = RandomNumber.r.Next(1, 5);
                if (b == 1)
                {
                    // Bad variation...
                    perp.Tasks.PlayAnimation("random@shop_tattoo", "_impatient_a", 5f, AnimationFlags.None);
                    Game.DisplaySubtitle("No! I don't know what you're...", 5000);
                    GameFiber.Sleep(5100);
                    BadTalk1();
                }
                else
                {
                    // Good variation...
                    perp.Tasks.PlayAnimation("random@shop_tattoo", "_impatient_a", 5f, AnimationFlags.None);
                    Game.DisplaySubtitle("Yeah I've been near here...", 5000);
                    GameFiber.Sleep(5100);
                    state4 = EAudioState.GoodTalk2;
                }
            }
            if (state4 == EAudioState.GoodTalk2)
            {
                GoodTalk2();
            }
        }

        public void BadTalk1()
        {
            int p = RandomNumber.r.Next(1, 4);

            if (p == 1)
            {
                PerpShoot();
            }
            else
            {
                PerpPunch();
            }
        }

        public void GoodTalk2()
        {
            if (SecondaryMenu.state5 == SecondaryMenu.EState.RestAudio5)
            {
                // Just relax and let's talk for a minute...
                Game.DisplaySubtitle("COP: Just relax...", 5000);
                GameFiber.Sleep(5100);
                state4 = EAudioState.GoodTalk3;
            }
            if (SecondaryMenu.state5 == SecondaryMenu.EState.RestAudio6)
            {
                // We have a person who described you...
                Game.DisplaySubtitle("COP: We have a person...", 5000);
                GameFiber.Sleep(5100);
                state4 = EAudioState.GoodTalk3;
            }
            if (SecondaryMenu.state5 == SecondaryMenu.EState.RestAudio3)
            {
                // You better stop that...
                state4 = EAudioState.BadTalk2;
            }
            if (SecondaryMenu.state5 == SecondaryMenu.EState.RestAudio4)
            {
                // Hey!  Just stay here and talk to me...
                state4 = EAudioState.BadTalk2;
            }
            if (state4 == EAudioState.GoodTalk3)
            {
                GoodTalk3();
            }
            if (state4 == EAudioState.BadTalk2)
            {
                BadTalk2();
            }
        }

 

Spoiler

       	Process()
		{
			base.Process();
			. [other random code starts here]
			.
			. [other random code ends here]

			if (state4 == EAudioState.Intro)
            {
                Conversation();
            }
        }

        public void Conversation()
        {
            if (SecondaryMenu.state5 == SecondaryMenu.EState.RestAudio3)
            {
                state4 = EAudioState.Neutral;
                // You better stop that...
                PerpShoot();
            }
            if (SecondaryMenu.state5 == SecondaryMenu.EState.RestAudio4)
            {
                // Hey! Just stay here...
                Game.DisplaySubtitle("GoodTalk1a", 2000);
                GameFiber.Sleep(2100);
                state4 = EAudioState.GoodTalk1;
            }
            if (SecondaryMenu.state5 == SecondaryMenu.EState.RestAudio5)
            {
                // Just relax and let's talk...
                Game.DisplaySubtitle("GoodTalk1b", 2000);
                GameFiber.Sleep(2100);
                state4 = EAudioState.GoodTalk1;
            }
            if (SecondaryMenu.state5 == SecondaryMenu.EState.RestAudio6)
            {
                // We have a person who described you...
                Game.DisplaySubtitle("GoodTalk1c", 2000);
                GameFiber.Sleep(2100);
                state4 = EAudioState.GoodTalk1;
            }
            if (state4 == EAudioState.Neutral)
            {
                PerpShoot();
            }
            if (state4 == EAudioState.GoodTalk1)
            {
                GoodTalk1();
            }
        }

 

Here's a video of it in action:

 

 

Edited by fiskey111
Added video!

Share this post


Link to post
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

×