Jump to content

New API Functions in LSPDFR 0.2a


Sam

Recommended Posts

We've added a couple of new API functions in LSPDFR 0.2a.  These were intended to be in the first release of our API, but were unfortunately left out due to time/other constraints:

  • You can now play police scanner audio with the LSPDFR 0.2a API.
  • You can now retrieve full pedestrian Persona data with the API.

 

I've included an example of some code that I used to test the functions earlier:

Audio Example

Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_RESIST_ARREST IN_OR_ON_POSITION", Game.LocalPlayer.Character.Position);

This code will play the following audio files:

  1. A randomly selected variant of "WE_HAVE" from Police Scanner/WE_HAVE
  2. A randomly selected variant of "CRIME_RESIST_ARREST" from Police Scanner/CRIMES
  3. The area (or street) that the local player is currently in (or on), preceded by the appropriate conjunctive ("in" or "on").

Note that "IN_OR_ON_POSITION" is a special keyword recognised by this function.  The other special keywords are:

  • "POSITION" - to play just the street or area.
  • "AREA" - to play just the area (and not the street)

Of course, the position used is the one specified in the second parameter for this function.  A separate function also exists to play paramaterless audio.

 

Persona Data

Persona pedPersona = API.Functions.GetPersonaForPed(Game.LocalPlayer.Character, null);
Game.DisplayNotification(String.Format("My name is {0} and I am a {1}, born on {2}.", pedPersona.FullName, pedPersona.Gender.ToString().ToLower(), pedPersona.BirthDay.ToShortDateString()));

Used in conjunction with Game.DisplayNotifiction as shown above, This example might produce the following output:

My name is Will Peavey and I am a male, born on 16/01/1991

"You tell me exactly what you want, and I will very carefully explain to you why it cannot be."

Link to comment
Share on other sites

  • The topic was pinned

Sam, when playing scanner audio, does the WAV file have to be in the LSPDFR\Police Scanner folder? Or does the API have access to the entire scanner audio library within GTA V?

Stealth22
LSPDFR Tester | Plugin Developer
My Plugins: Code 3 Callouts | Traffic Control | Keep Calm | ALPR+

Please do not PM me for any kind of technical support.
I unfortunately do not have enough free time to answer every PM that I get. For issues with my plugins, please post in the comments section of the file, or it's forum thread. You'll get a much quicker response from me there than if you send me a PM; I do my best to respond to every question in the comments sections. For API/programming questions, please post them in the API Development forum, so all developers can benefit from the answer as well. Thanks!

Link to comment
Share on other sites

Sam, when playing scanner audio, does the WAV file have to be in the LSPDFR\Police Scanner folder? Or does the API have access to the entire scanner audio library within GTA V?

The audio file must be located somewhere in the Police Scanner folder. If you want to use a sound file in GTA V that isn't currently in the folder, use OpenIV to export the sound file you want, and add it to the police scanner folder (renaming it also, since most audio files have random names). Then, when you release the mod, just add the file to your archive and have the user add it to the scanner folder.

Developer of the original Bait Car for LSPDFR!

Download it here

 

 

Link to comment
Share on other sites

  • Management Team

Does the IsPlayerArrested work now? :)

Yeah, it *should* :P

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

Link to comment
Share on other sites

Sam, when playing scanner audio, does the WAV file have to be in the LSPDFR\Police Scanner folder? Or does the API have access to the entire scanner audio library within GTA V?

Has to be in the folder.

"You tell me exactly what you want, and I will very carefully explain to you why it cannot be."

Link to comment
Share on other sites

Im having horrible pop sounds that are heard when my custom clip ends, they are not from my clip, i even put second of silence in the end..

I cant use my audio now.. :(

 

EDIT: yeah it definetly not from my clip.. i tried putting 5 second silence to the end.. and in game after that silence, audio popped/cracked... : /

Edited by Wonka45
Link to comment
Share on other sites

  • 2 months later...
  • 4 weeks later...
Are there any additions or changes being made to the API in LSPDFR 0.3?
 
I'm slowly working on an update to my callout plugin, but I'm not sure if I should be holding out for v0.3 or not.
 
On 13/10/2015, 12:04:50, AnIdioticMonkey said:

I know this thread looks dead, but just wondering if the audio played has to be in a certain order. Because there are files named the same, and wondering how it distinguishes between them.

I realize this reply is late, but in my experience, it just seems to pick whatever file that partially matches the name you provide. For that reason, I had to name my audio files uniquely. For example, when searching for "DIV_1" in my callout plugin, it would find both "DIV_1" and "DIV_10", and it would pick a random one each time the clip was played. I didn't have any numbers above 10 for those files, but if I did, it may have found 11 or 12 as well. I ended up adding a leading zero to the single digit numbers.

Stealth22
LSPDFR Tester | Plugin Developer
My Plugins: Code 3 Callouts | Traffic Control | Keep Calm | ALPR+

Please do not PM me for any kind of technical support.
I unfortunately do not have enough free time to answer every PM that I get. For issues with my plugins, please post in the comments section of the file, or it's forum thread. You'll get a much quicker response from me there than if you send me a PM; I do my best to respond to every question in the comments sections. For API/programming questions, please post them in the API Development forum, so all developers can benefit from the answer as well. Thanks!

Link to comment
Share on other sites

On 10/11/2015, 19:02:40, Stealth22 said:
Are there any additions or changes being made to the API in LSPDFR 0.3?
 
I'm slowly working on an update to my callout plugin, but I'm not sure if I should be holding out for v0.3 or not.
 

I realize this reply is late, but in my experience, it just seems to pick whatever file that partially matches the name you provide. For that reason, I had to name my audio files uniquely. For example, when searching for "DIV_1" in my callout plugin, it would find both "DIV_1" and "DIV_10", and it would pick a random one each time the clip was played. I didn't have any numbers above 10 for those files, but if I did, it may have found 11 or 12 as well. I ended up adding a leading zero to the single digit numbers.

Thanks! Already worked that out from trial and error, but thanks!

Personally holding out for 0.3 myself.

Link to comment
Share on other sites

  • Management Team
On 10.11.2015, 20:02:40, Stealth22 said:
Are there any additions or changes being made to the API in LSPDFR 0.3?
 
I'm slowly working on an update to my callout plugin, but I'm not sure if I should be holding out for v0.3 or not.

Since we've been focused on actual gameplay mostly, I can't give any binding statements regarding the API yet. We have some plans to overhaul the API, including the already announced changes to making some functions and classes private, which will ship with the initial 0.3 release. While there will be some small additions, chances are we will release a separate more API-focused release shortly after rather than including it all in the 0.3 release already. This is mostly a decision due to time constraints on our side, because we do not want to delay a possible 0.3 due to API issues. I don't want to give you the impression we're no longer working on the API though, it's something we are very interesting in and it will definitely be improved soon!

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

Link to comment
Share on other sites

  • The topic was unpinned

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...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...