Jump to content

Psssst. We thought it'd be fun to share the winter-defying warmth of our meltingly cute snowman, so we stuck him on a t-shirt!

Want one? You can order this limited edition shirt now at Spreadshirt (US), or Redbubble

master1114

Getting started!

Recommended Posts

Hey there!

I am a 19 yo computer science student. I have been playing LCPDFR and LSPDFR for quite some time and I have never thought about doing something own when it comes to modding/scripting for games. But times can change I guess :wink: In february @alexguirre told me that everybody can be a dev. I will be an software developper in about 4 years (at least thats the plan) and I decided to take a look into scripting and Hopefully give this great community something more! I am learning Java at university, I hope that will make it a bit easier scince Java and C# are pretty similar.

First of all I think its the time to say thank you to all the developers who spend their time into this and make this whole thing possible. And then special thanks to @Albo1125 for taking his time to create this API-basics tutorial!

It would be great if someone could have an open eye for this thread and possibly help me when I have some questions!

For now on, I would like to know how I can spawn something on a specific location and facing a spec. direction (for example like the cars in a "Traffic Stop Backup Requiered" callout (AssortedCallouts). Tanks!

Share this post


Link to post
Share on other sites

Quick question:

When I try to spawn a callout on a predefined postion, how do I mangage to let this callout only be displayed when the player is within a certain range?

If I would do that in my actual callout class, it would be "blocking" a callout spawn because at this point LSPDFR already wanted my callout to appear but I have to cancel it.

Share this post


Link to post
Share on other sites

For the spawn point in a certain range you can try this:  spawnPoint =
                World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(300f));

Share this post


Link to post
Share on other sites

Yeah but that gives me a rendom spawnpoint right? But I have set my own coordinates. So for example i have a callout that only spawns in Sandy Shores, so I dont want the game to display it when the player is e.g. in LS

Edited by master1114

Share this post


Link to post
Share on other sites
20 hours ago, master1114 said:

Yeah but that gives me a rendom spawnpoint right? But I have set my own coordinates. So for example i have a callout that only spawns in Sandy Shores, so I dont want the game to display it when the player is e.g. in LS

If the callout happens in a specific location (coordinates):
if (Game.LocalPlayer.Character.DistanceTo(callout location) > maximum distance away they can be from the callout location)

{

End();
}

Or if it's just the general area of LS and Sandy Shores:

if (NativeFunction.CallByName<uint>("GET_HASH_OF_MAP_AREA_AT_COORDS", Game.LocalPlayer.Character.Position.X, Game.LocalPlayer.Character.Position.Y, Game.LocalPlayer.Character.Position.Z) == Game.GetHashKey("city"))
{

End();

}

 

That is how I would do it. 

Edited by ScottehBoyy

Share this post


Link to post
Share on other sites

Yup, thats logical, but lets assume:

Player forces a callout. My callout appears, but distance check fails. Callout gets cancelled. Player does not get a callout displayed.

Or does LSPDFR has something implemented that prevents this from happening?

Share this post


Link to post
Share on other sites
6 hours ago, master1114 said:

Yup, thats logical, but lets assume:

Player forces a callout. My callout appears, but distance check fails. Callout gets cancelled. Player does not get a callout displayed.

Or does LSPDFR has something implemented that prevents this from happening?

There's an OnBeforeCalloutDisplayed function that you can override, and your distance logic would go in that function. If the player is too far, return false, and that's it. LSPDFR handles the rest.

PNWParksFan and ScottyTooHotty like this

Share this post


Link to post
Share on other sites

Thanks for the help so far!

I have two new problems so if someone wants to share some more time for me it would be great :wink:

1) The callout appears everywhere, even tho I i did what @ScottehBoyy proposed. (OnBeforeCalloutDisplayed Method)

Spoiler

if (Game.LocalPlayer.Character.DistanceTo(spawnPoint)<4000f)
            {
                return false;
            }
            

2) When I accept the callout, this appears: What did I do to cause this?

Spoiler

[15.09.2016 21:10:51.814] LSPD First Response: ==============================
[15.09.2016 21:10:51.815] LSPD First Response: UNHANDLED EXCEPTION DURING GAME FIBER TICK
[15.09.2016 21:10:51.815] LSPD First Response: ------------------------------
[15.09.2016 21:10:51.815] LSPD First Response: Origin: Game fiber "CalloutManager".
[15.09.2016 21:10:51.816] LSPD First Response: ------------------------------
[15.09.2016 21:10:51.816] LSPD First Response: Exception type: System.IndexOutOfRangeException
[15.09.2016 21:10:51.817] LSPD First Response: Exception message: Der Index war außerhalb des Arraybereichs.
[15.09.2016 21:10:51.844] LSPD First Response: ------------------------------
[15.09.2016 21:10:51.844] LSPD First Response: Inner exceptions:
[15.09.2016 21:10:51.844] LSPD First Response: ------------------------------
[15.09.2016 21:10:51.844] LSPD First Response: Stack trace:
[15.09.2016 21:10:51.845] LSPD First Response: bei AlphaCallouts.Callouts.FreewayPet.OnCalloutAccepted()
[15.09.2016 21:10:51.845] bei ?????????????????????????????????????????.?????????????????????????????????????????() in E:\GTA V\LSPD First Response\LSPD First Response\Mod\Callouts\CalloutManager.cs:Zeile 338.
[15.09.2016 21:10:51.845] bei ?????????????????????????????????????????.?????????????????????????????????????????() in E:\GTA V\LSPD First Response\LSPD First Response\Mod\Callouts\CalloutManager.cs:Zeile 173.
[15.09.2016 21:10:51.846] bei Rage.GameFiber.Main()

 

Share this post


Link to post
Share on other sites
20 hours ago, master1114 said:

Thanks for the help so far!

I have two new problems so if someone wants to share some more time for me it would be great :wink:

1) The callout appears everywhere, even tho I i did what @ScottehBoyy proposed. (OnBeforeCalloutDisplayed Method)

  Reveal hidden contents

if (Game.LocalPlayer.Character.DistanceTo(spawnPoint)<4000f)
            {
                return false;
            }
            

2) When I accept the callout, this appears: What did I do to cause this?

  Reveal hidden contents

[15.09.2016 21:10:51.814] LSPD First Response: ==============================
[15.09.2016 21:10:51.815] LSPD First Response: UNHANDLED EXCEPTION DURING GAME FIBER TICK
[15.09.2016 21:10:51.815] LSPD First Response: ------------------------------
[15.09.2016 21:10:51.815] LSPD First Response: Origin: Game fiber "CalloutManager".
[15.09.2016 21:10:51.816] LSPD First Response: ------------------------------
[15.09.2016 21:10:51.816] LSPD First Response: Exception type: System.IndexOutOfRangeException
[15.09.2016 21:10:51.817] LSPD First Response: Exception message: Der Index war außerhalb des Arraybereichs.
[15.09.2016 21:10:51.844] LSPD First Response: ------------------------------
[15.09.2016 21:10:51.844] LSPD First Response: Inner exceptions:
[15.09.2016 21:10:51.844] LSPD First Response: ------------------------------
[15.09.2016 21:10:51.844] LSPD First Response: Stack trace:
[15.09.2016 21:10:51.845] LSPD First Response: bei AlphaCallouts.Callouts.FreewayPet.OnCalloutAccepted()
[15.09.2016 21:10:51.845] bei ?????????????????????????????????????????.?????????????????????????????????????????() in E:\GTA V\LSPD First Response\LSPD First Response\Mod\Callouts\CalloutManager.cs:Zeile 338.
[15.09.2016 21:10:51.845] bei ?????????????????????????????????????????.?????????????????????????????????????????() in E:\GTA V\LSPD First Response\LSPD First Response\Mod\Callouts\CalloutManager.cs:Zeile 173.
[15.09.2016 21:10:51.846] bei Rage.GameFiber.Main()

 

Well you're telling it to return false if they're within the desired radius. Change your '<' sign to '>'.

Share this post


Link to post
Share on other sites

Alright, I have solved the problems above (well, they were actually pretty simple and stupid) and I am now on the point of having my callout actually going through the process routine. That brings us to 2 new questions:

1) Game.DisplaySubtitle(string) shows a subtitle text. But when you display multiple ones after each other, it only shows the last one. How to I make the game wait for the sutitle before to get removed?

2) Vehicle.Deform(Vector3 offset, float radius, float amount) should damage my vehicle. I already played around with some values. Radius dispositioned the vehicle somewhere else and the other 2 had no visible influence.

Share this post


Link to post
Share on other sites
On 9/16/2016 at 8:56 PM, master1114 said:

Alright, I have solved the problems above (well, they were actually pretty simple and stupid) and I am now on the point of having my callout actually going through the process routine. That brings us to 2 new questions:

1) Game.DisplaySubtitle(string) shows a subtitle text. But when you display multiple ones after each other, it only shows the last one. How to I make the game wait for the sutitle before to get removed?

2) Vehicle.Deform(Vector3 offset, float radius, float amount) should damage my vehicle. I already played around with some values. Radius dispositioned the vehicle somewhere else and the other 2 had no visible influence.

I don't have a clue about 2 as I've never played with it at all but for 1 you need to put "GameFiber.Sleep(insert desired amount of time);". Your desired amount of time should be however long you wish the subtitle to stay on screen. It's also worth noting that the numbers you put in there are in milliseconds so if you put in "4000" then that's 4 seconds.

Edit: This is to go after your subtitle code. So it'd be:
Subtitle
Code
Subtitle
Code etc..

Edited by ScottehBoyy
master1114 likes this

Share this post


Link to post
Share on other sites

Thanks for the help so far :wink:

I am close to finishing my first callout. Only thing thats creating problems is the mentioned Vehicle.Deform method, wich i cant get to work. The car remains in perfect condition after using it with many different values on the parameters.

Share this post


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

Thanks for the help so far :wink:

I am close to finishing my first callout. Only thing thats creating problems is the mentioned Vehicle.Deform method, wich i cant get to work. The car remains in perfect condition after using it with many different values on the parameters.

Which values are you passing to Vehicle.Deform()? This is the meaning of the paramaters:

  • Vector3 offset: is the position where to deform the vehicle at from the center of the vehicle.
  • float radius: the radius from the offset where the deformation will be applied.
  • float amount: how much deformation apply.

For example, this vehicle.Deform(new Vector3(0f, 1f, 0.225f), 50.0f, 500f); works fine to deform the front of a NINEF.

Share this post


Link to post
Share on other sites

Thanks I got it to work :)

        public override bool OnCalloutAccepted()
        {

            //SPAWN 2 CARS AND 2 PEDS

            try
            {
                KeysConverter kc = new KeysConverter();
                mainKey = (Keys)kc.ConvertFromString(AlphaCallouts.Main.getKeyBinding());
                mainKeyString = AlphaCallouts.Main.getKeyBinding();
            }
            catch
            {
                mainKey = Keys.T;
                Game.DisplayNotification("Error reading AlphaCallouts.ini. Setting default");
            }

            route = guard.AttachBlip();
            route.Color = System.Drawing.Color.DarkBlue;
            route.EnableRoute(System.Drawing.Color.DarkBlue);
            route.IsFriendly = true;

            GameFiber.Wait(5000);
            Functions.PlayScannerAudio("PLAYING_911_CALL 911_CALL_01 911_CALL_02 911_CALL_03 911_CALL_04");
            GameFiber.Wait(12000);

            return base.OnCalloutAccepted();
        }

When I accept my callout with this OnCalloutAccepted-Method, I get the following exception:

Spoiler

[22.09.2016 18:45:19.297] LSPD First Response: UNHANDLED EXCEPTION DURING GAME FIBER TICK
[22.09.2016 18:45:19.297] LSPD First Response: ------------------------------
[22.09.2016 18:45:19.297] LSPD First Response: Origin: Game fiber "CalloutManager".
[22.09.2016 18:45:19.298] LSPD First Response: ------------------------------
[22.09.2016 18:45:19.298] LSPD First Response: Exception type: Rage.Exceptions.InvalidHandleableException
[22.09.2016 18:45:19.299] LSPD First Response: Exception message: Operation is not valid because the specified  Rage.Blip is invalid.
[22.09.2016 18:45:19.299] LSPD First Response: ------------------------------
[22.09.2016 18:45:19.299] LSPD First Response: Inner exceptions:
[22.09.2016 18:45:19.300] LSPD First Response: ------------------------------
[22.09.2016 18:45:19.300] LSPD First Response: Stack trace:
[22.09.2016 18:45:19.301] LSPD First Response: bei Rage.Blip.Delete()
[22.09.2016 18:45:19.301] bei LSPD_First_Response.Mod.Callouts.Callout.OnCalloutAccepted() in E:\GTA V\LSPD First Response\LSPD First Response\Mod\Callouts\Callout.cs:Zeile 154.
[22.09.2016 18:45:19.302] bei AlphaCallouts.Callouts.PoisonAttack.OnCalloutAccepted()
[22.09.2016 18:45:19.302] bei ?????????????????????????????????????????.?????????????????????????????????????????() in E:\GTA V\LSPD First Response\LSPD First Response\Mod\Callouts\CalloutManager.cs:Zeile 338.
[22.09.2016 18:45:19.302] bei ?????????????????????????????????????????.?????????????????????????????????????????() in E:\GTA V\LSPD First Response\LSPD First Response\Mod\Callouts\CalloutManager.cs:Zeile 173.
[22.09.2016 18:45:19.303] bei Rage.GameFiber.Main()

 

I set a route to a Blip attached to my ped, and thats working fine, but 3-4 seconds after accepting the callout, it crashes, while I dont even try to delete any blips in this method?

Share this post


Link to post
Share on other sites

It looks like it doesnt crash without the Wait-methods. But now obvsly. the Scanner Audio doesnt get played because its in conflict to the Audio from the callout spawning.

 

Unrelated question: I always thought the EnterVehicle-Tasks would make the Ped walk to that Vehicle aswell, but it looks like they need to be close to it already. Is that right?

Share this post


Link to post
Share on other sites

Put PlayScannerAudio() in a new GameFiber:

GameFiber.StartNew(delegate
{
	GameFiber.Wait(5000);
	PlayScannerAudio(params);
});

Yes, a ped has to be within distance of x units to a vehicle to perform EnterVehicle() properly where x is something like 10f.

Edited by LtFlash
master1114 likes this

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


×