Skip to content
View in the app

A better way to browse. Learn more.

LCPDFR.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Event for when exiting a police station

Featured Replies

Is there any kind of event or someway for my plugin (in development) can know when a player exits a police station? The idea that I am trying to go for is when the player has selected a police agency to work under (example: San Andreas Highway Patrol), my mod will register callouts that are specific to what a State Trooper would normally respond to. Currently, using the Functions.OnOnDutyStateChanged event fires as SOON AS the player clicks the "Go On Duty" menu option, and therefor the police agency is not yet selected. Any help is greatly appreciated!

  • Management Team

There is no such event currently. You could however use the new function in LSPDFR 0.4.6 IsPlayerInStationMenu and whenever it evaluates to true wait until it is false again, then compare their last agency (if any) to the new one. That should probably cover most cases of the player switching an agency and you can adjust your callouts accordingly.

Please do not PM me unless really necessary (knowing you helps). If you think you need my attention in a topic, tag me.

  • Author

Ok, I can get on board with that, thanks! Question though, would it be better to use a more backwards compatible version since 0.4.6 is so new? Such as Functions.IsPlayerAvailableForCalls()? Not sure of the internals of that function, but does it return true even if the player is in menus?

 

  • Management Team

I don't think there is much of a benefit to using an older version. IsPlayerAvailableForCalls returns true when the player has made themselves available for callouts, it does not take into account menus etc.

Please do not PM me unless really necessary (knowing you helps). If you think you need my attention in a topic, tag me.

Because there is no way to unregister callouts, I think it would be much more straightforward and robust to register all the callouts, and then in the OnBeforeDisplayed method check the current agency and return false if it's not in the list of relevant agencies for that callouts. 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

  • Author
3 hours ago, PNWParksFan said:

Because there is no way to unregister callouts, I think it would be much more straightforward and robust to register all the callouts, and then in the OnBeforeDisplayed method check the current agency and return false if it's not in the list of relevant agencies for that callouts. 

 

If a Callout returns false on the OnBeforeDisplayed method, does LSPDFR automatically select a new callout immediately or does it go into a timeout again?

  • Management Team
35 minutes ago, Brexin212 said:

 

If a Callout returns false on the OnBeforeDisplayed method, does LSPDFR automatically select a new callout immediately or does it go into a timeout again?

 

It resets the timeout so you are effectively skipping a callout. You could however abuse the API and in the next tick after your callout got shut down due to an invalid agency, check whether a callout is running (just to be sure) and if not, start a new callout (that is valid for the current agency). That way the timer shot would not be wasted. If there is no callout valid for your current agency, then it would do nothing since you do not know the names of third party callouts and there is no way via the API to trigger a random callout. The timer shot would go to waste then, but unless you only have two callouts for very specific agencies I don't see it as that much of a problem. 

Please do not PM me unless really necessary (knowing you helps). If you think you need my attention in a topic, tag me.

  • Author

I have an idea, mind giving some input @LMS? What if I used a callout wrapper of sorts for my callout pack for selecting callouts? I assume that if I have 20 callouts, I could just register my callout wrapper 20 times correct? (this way its called as often as a callout from my mod is called compared to other callout packs)

 

Example:

 

[CalloutInfo("CalloutWrapper", CalloutProbability.Medium)]
public class CalloutWrapper
{
	private Callout SelectedCallout { get; set; }
  
	public CalloutWrapper()
	{
		// Loads a random callout from my callout selection based on CURRENT AGENCY
		string name = Functions.GetCurrentAgencyScriptName();
		SelectedCallout = GetRandomCalloutByAgency(name);
	}
  
	public override bool OnBeforeCalloutDisplayed()
	{
		return SelectedCallout.OnBeforeCalloutDisplayed();
	}
  
	// etc etc
}

 

Edited by Brexin212

You could also register each callout with a callout probability of None, and then register your wrapper once with a probability of very high. The wrapper could then call Functions.StartCallout (or whatever that's called) to start the "real" callout, effectively cancelling the wrapper callout from running. This has a few advantages; you avoid possible issues from the actual underlying callout not really being running, it lets mods like Callout Manager still work, and it's a bit cleaner I think. 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

  • Author
2 hours ago, PNWParksFan said:

You could also register each callout with a callout probability of None, and then register your wrapper once with a probability of very high. The wrapper could then call Functions.StartCallout (or whatever that's called) to start the "real" callout, effectively cancelling the wrapper callout from running. This has a few advantages; you avoid possible issues from the actual underlying callout not really being running, it lets mods like Callout Manager still work, and it's a bit cleaner I think. 

 

I like this idea, very clean!

Edited by Brexin212

56 minutes ago, Brexin212 said:

This is what I ended up doing, thoughts? With a CalloutProbability set to VeryHigh, this should ensure my callout manager spawning very often, even if there is 20 or so other callouts loaded?

 

https://github.com/wilson212/AgencyCalloutsPlus/blob/master/AgencyCalloutsPlus/API/AgencyCalloutManager.cs

 

Have you tested this in game yet? I don't think this will work: 

Functions.StartCallout(calloutType.FullName);

 

I believe StartCallout takes the registered callout name, not the name of the class. What you want to do is use Reflection to get the CalloutInfo attribute of the callout, which will have the registered callout name. 

 

I'm not exactly sure what you're doing to get the list of callouts to register. Looks like you have some sort of XML config file you're using. It may be more straightforward to define your own custom attribute class to specify the agency types for each callout, and then get those by reflection too. That way you don't run the risk of anything getting out of sync between your code and your config file. 

 

 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

  • Author
2 hours ago, PNWParksFan said:

 

Have you tested this in game yet? I don't think this will work: 

Functions.StartCallout(calloutType.FullName);

 

I believe StartCallout takes the registered callout name, not the name of the class. What you want to do is use Reflection to get the CalloutInfo attribute of the callout, which will have the registered callout name. 

@PNWParksFan if that is the case, then what if 2 callout packs add the same name to the CalloutManager?

Just now, Brexin212 said:

@PNWParksFan if that is the case, then what if 2 callout packs add the same name to the CalloutManager?

 

Then I believe it will spawn one of them at random. @LMS can you confirm if that's correct? 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

  • Management Team
10 hours ago, PNWParksFan said:

 

Then I believe it will spawn one of them at random. @LMS can you confirm if that's correct? 

 

It will always start the first callout registered with the name.

Please do not PM me unless really necessary (knowing you helps). If you think you need my attention in a topic, tag me.

  • Author
2 hours ago, LMS said:

 

It will always start the first callout registered with the name.

 

@LMS Does this refer to the name of the class, or the CalloutInfo.Name property?

Edited by Brexin212

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.