MailDelivery v1.0.2 - Standalone mail delivery job for Paleto Bay, Grapeseed and Sandy Shores (Extra: ESX Addon)

It works great for me, but it would be nice if I could put it in my language: Portugues
as it’s DLL I do not know it would be possible to change messages

No, that’s not possible at the moment, but I’m open to adding convars for that.

However, that might turn into a large amount of convars. Perhaps a config file would be better. You can also change it yourself and recompile :slight_smile:

I’ll think about it.

Hi I have deployed your script on my vrp server. What is happening is weird on my personal server test all gose well nut on the release server people aren’t able to give back the van. For example they are sitted in the van inside the blip but they receive the error like they are in a non Maildelivery.Rental van .

 private async Task OnRentalTick()
        {
            try
            {
                var playerPos = Game.PlayerPed.Position;

                if (playerPos.DistanceToSquared2D(RentalPosition) < 16)
                {
                    var playerPed = Game.PlayerPed;
                    if (playerPed.IsSittingInVehicle())
                    {
                        if (!DecorExistOn(playerPed.CurrentVehicle.Handle, "MailDelivery.Rental"))
                        {
                            Screen.DisplayHelpTextThisFrame("Esci dal veicolo per noleggiare il camion");
                            return;
                        }

                        Screen.DisplayHelpTextThisFrame("Premi ~INPUT_CONTEXT~ per restituire il camion");
                        if (Game.IsControlJustReleased(0, Control.Context))
                        {
                            playerPed.CurrentVehicle.Delete();
                            Screen.ShowNotification("Il camion è stato restituito.");
                        }

                        return;
                    }

                    Screen.DisplayHelpTextThisFrame($"Premi ~INPUT_CONTEXT~ per noleggiare un camioncino per le consegne al prezzo: ${_rentalAmount}");

                    if (Game.IsControlJustReleased(0, Control.Context))
                    {
                        var _parkId = GetParkingPosition(VehicleSpawnPositions);

                        if (_parkId < 0 || _parkId >= VehicleSpawnPositions.Count)
                        {
                            Screen.ShowNotification("Non ci sono parcheggi disponibli.");
                            return;
                        }

                        var parkPos = VehicleSpawnPositions[_parkId];

                        _jobVehicle = await World.CreateVehicle(new Model(_vanModel), new Vector3(parkPos.X, parkPos.Y, parkPos.Z), parkPos.W);

                        SetEntityAsMissionEntity(_jobVehicle.Handle, true, true);

                        if (!DecorExistOn(_jobVehicle.Handle, "MailDelivery.Rental"))
                        {
                            DecorRegister("MailDelivery.Rental", 2);
                            DecorSetBool(_jobVehicle.Handle, "MailDelivery.Rental", true);
                        }

                        TriggerServerEvent("MailDelivery:VanRented", _rentalAmount);

                        Screen.DisplayHelpTextThisFrame("Il tuo camion è stato parcheggiato al parcheggio.");

                        await Delay(4000);
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine($"{e.Message} : Exception thrown on MailDelivery:OnRentalTick()");
            }

            await Task.FromResult(0);
        }

Hey! Great script.
Currently, you download a truck, you pay 2,000$.

I would like to do it in the form of a deposit, if you give back a lorry, you get a return of 2,000 $
Can you guide me, how to do it.

1 Like

Are you perhaps using OneSync? I wouldn’t know why the vans lose their Decor metadata. Perhaps we could add a server sided script that keeps track of the rented vehicles and their handles (over network, obviously). I’ll look into it some time this week, if I don’t forget :smiley:

That would require a new ConVar and some code. I could add this in the upcoming week if I don’t forget :slight_smile:. Thank you for the feedback and idea.

2 Likes

I’ll remind you about it
:upside_down_face: :smirk:

Nope I am not on OneSync . Well I am also looking on it so we can come up with a solution together @d0p3t

I will be very grateful how you will do it and I have a question whether it can be done so that this script would be a job at the work center and not as a separate one? (it’s about esx)

This resource is standalone. I won’t be making this ESX compatible. If someone wants to create a plugin for including it in your “job center” and requires some extra events or ConVars then I’m more than happy to include those.

Very nice Script but i dont cant figure out how to use the ConVars i dont get it i was Trying to do them several spots in the esx-maildelivery but nothing changed.

i need to change the
SetConvar (“mail_max_payment”, “320”)
SetConvar (“mail_rental_amount”, “1000”)

if the player gets up to 1000 its a lot to much for my economy.

the script itselfs works flawlessly i like very much.

Thx in advance

Have a look here. https://docs.fivem.net/scripting-reference/convars/

TLDR: in your server.cfg include

setr mail_max_payment 320
setr mail_rental_amount 1000

To those that asked about getting the rental money back upon return of the vehicle; I will be looking to expand on that this weekend.

ok it seems in my case it needs setr. but now its working like a charm. Thx for this script

Thx for the fast reply.

I have a question whether you have already added money refund options for borrowing or not

Great script! Easy to understand and edit even as a novice who mainly uses Lua.

For those who want a refund upon van return… copy the rental event:

TriggerServerEvent(“MailDelivery:VanRented”, _rentalAmount);

Change it to become a return event:

TriggerServerEvent(“MailDelivery:VanReturned”, _rentalAmount);

And add it to the section that is triggered by returning the vehicle:

if (Game.IsControlJustReleased(0, Control.Context))
{
playerPed.CurrentVehicle.Delete();
Screen.ShowNotification(“Mail Delivery Van has been returned.”);
TriggerServerEvent(“MailDelivery:VanReturned”, _rentalAmount);
}

You will also need to edit the server file the same way that is outlined in the initial post to actual trigger the money to be returned to a bank account. This is framework specific and I don’t use ESX, though.

Now if someone knows a way to make it so when a player does not return the van they are charged a certain (additional) amount, I would love that. Not sure how you would go about setting the time frame a person has to return the van…

Can you please modify a little for me… i want that ped can start job without any truck and when he start the job, the truck should be provided automatically… can this happen?

Can anyone help me? I downloaded the source codes and the downlink link.
I just created the resource MailDelivery and added it into server.cfg.

It’s load perfectly into my server without issues (Standalone). But I do not see any blips on the map to start the job?

Well, u have it in now. Sound like you should actually start the trigger to start the job, and by doing that it will draw the map blips for you.

if only you can change the routes in a config file

The places are manually places where there are actual mailboxes. If you’ve found more, you can add that. Our source code is open source and you can Pull Request changes.

Every single new route is almost different.

ill see what i can do aha. i ain’t the best. want to change it to like a Grocery delivery for 24/7 shop so you deliver boxes to houses