Coder Social home page Coder Social logo

maildelivery's Introduction

MailDelivery Job (v1.0.2)

Standalone mail delivery job for Paleto Bay, Grapeseed and Sandy Shores

Version Build Status Discord

Build Status Hello


I decided to release this script after a beloved server that I played on shut down. At the time I created this, I was working together with the developers to add some unique functionalities to the server. This was one of them.


What is MailDelivery?

In short, MailDelivery is a standalone mail delivery job that lets players deliver mail all around Blaine County.

A mail delivery man always has his own unique route, designated to one of the three towns: Paleto Bay, Grapeseed, or Sandy Shores, delivering his mail to mailboxes or other interesting places.

Standalone means that it does not have built-in ESX or vRP support. It does however have events that you can listen for.

Written fully in C#.


Features

  • Always receive a unique route in one of three towns with 10-12 delivery spots (out of max. 33)
  • Marked delivery spots on the map
  • Delivery spots are mailboxes, porches and other interesting spots
  • Animation when delivering mail
  • Ability to use your own custom van model if you don't like the PostOP Boxville
  • Rental spot in case the mail man doesn't have his own PostOP Boxville yet!
  • Rental vans are spawned in one of the free parking spots.
  • Configurable min/max pay per delivery and other settings using ConVars
  • Adaptable to your own system by using server events for payment and rental costs
  • Customize all blip sprites and colors using ConVars

Installation & Configuration

Installation

Installation is simple, download the resource through the link above, add start maildelivery to your server.cfg and you're ready to go. However, if you would like to configure settings or bind this to your existing economy system, see Configuration.

Configuration

This resource triggers two events for you to conveniently integrate this job into your own system as well as various ConVars to modify settings (like minimum and maximum payments).

There are two server events that you can use to add delivery payments and rental costs to your existing economy system (for example ESX).

Name: "MailDelivery:DeliveryMade" Parameters: payment(integer) Description: Fired when a delivery has been made. Contains the payment amount between the min and max payment. Example:

AddEventHandler("MailDelivery:DeliveryMade", function(payment)
    -- add payment to players bank account
end)

Name: "MailDelivery:VanRented" Parameters: rentalAmount(integer) Description: When renting a van, this event gets triggered with the set rental amount. Example:

AddEventHandler("MailDelivery:VanRented", function(rentalAmount)
    -- deduct rentalAmount from players bank account
end)

You can configure various aspects of the job using ConVars. Below is the list of all available ConVars and their default values if not set.

Name: "mail_min_payment" (Default: 150) Description: The minimum payment of a delivery.

Name: "mail_max_payment" (Default: 1000) Description: The maximum payment of a delivery.

Name: "mail_rental_amount" (Default: 2000) Description: The rental cost when renting a mail delivery van via the rental spot.

Name: "mail_rental_blip_sprite" (Default: 67) Description: Sets the blip sprite of the rental location. By default a truck sprite.

Name: "mail_rental_blip_color" (Default: 0) Description: Sets the blip color of the rental location. By default white.

Name: "mail_job_cooldown" (Default: 60000) Description: Sets the cooldown time between going on/off duty. A security measure to prevent people from getting the optimal route.

Name: "mail_job_blip_sprite" (Default: 67) Description: Sets the blip sprite of the on-duty location. By default a truck sprite.

Name: "mail_job_blip_color" (Default: 0) Description: Sets the blip color of the on-duty location. By default white.

Name: "mail_van_model" (Default: "BOXVILLE4") Description: Sets the van model required to start the delivery job. Also the model for the rental spot.

Name: "mail_delivery_blip_sprite" (Default: 164) Description: Sets the blip sprites of the delivery locations. By default a flag.

Name: "mail_delivery_blip_color" (Default: 66) Description: Sets the blip color of the delivery locations. By default yellow.

Name: "mail_debug" (Default: false) Description: A debug flag for developers (Only set this convar when developing!)


Changelog

v1.0.2

  • New default delivery points blip
  • Added blip customization convars
  • CI: Added Azure DevOps for faster builds. Releases process still on TravisCI

v1.0.1

  • Ability to use your own custom van model
  • Moved ConVars to client side due to new FiveM feature

v1.0.0

  • Initial release

Known Issues

None as of right now 🤞

If you come across anything bugs/issues, please create an Issue.


Support

If you require assistance, you can ask your question on the FiveM forum topic. Please don't create topics elsewhere or ask me on the FiveM Discord about this resource. Lets keep all questions and comments in one topic, so we are all aware of what's going on.


Credits

Last, but not least, some credits to people that have helped me get into FiveM coding and helped other wise.

Thanks @Mooshe and his stream for the preliminary logic of parking spots and toggling duty (months ago). Thanks to @Vespura for letting me use the same license :)


Final Words

I hope you enjoy the release. I want this resource to not only be one that community members can use, but also learn from. I feel there is a lack of C# resources as well as source code that developers can learn from.

If you have any requests, concerns, etc. please let me know.

You can modify or edit the code as you like, but you cannot re-release it. Please see the LICENSE.md

maildelivery's People

Contributors

d0p3t avatar

Stargazers

 avatar DuckySuck avatar  avatar Mr.Crowley avatar jamie avatar Lama avatar Mathis (Avnyr) avatar Nicolas Favre avatar xTxVxTx avatar  avatar Ant avatar Leonid avatar Muddy Kipper avatar TJ avatar jawad qassab avatar  avatar  avatar Neddings avatar  avatar Jacek Maciejak avatar Mitch avatar M. Hale avatar Austin Grandpre avatar

Watchers

James Cloos avatar  avatar  avatar

maildelivery's Issues

Ideas

Add a option to input a different car for the job, so we can use custom mail vans.

And maybe change from using convars to a ini file insted, just to keep our server.cfg clean :D

Van not be able to be returned

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);
    }`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.