FiveM Train Robbery

You decide how much to pay.

FiveM Train Robbery Script [QBCore]

Package Description

Train Robbery for QBCore Framework

This simple train robbery script allows for players to purchase coordinates to a train carrying gold. Upon arrival the player will have armed guards (optional) come to stop them, and the police are sent a notification as well. Once ALL the gold is taken, the selling point will unlock and allow for players to meet with the buyer to exchange the gold for cash.

Demo Video

https://youtu.be/-qXCKZcTdKU

Support: (OneSync Enabled Required)

https://discord.gg/B9ZxYUtZzv

Features:

  • Synced animations between players
  • Configurable:
    • Starting location
    • Train spawning locations
    • Time between heists (cooldown)
    • Starting price
    • Minimum police needed to start
    • Guards:
      • Player model
      • Weapon
      • Accuracy
      • Max Health
      • Armor
    • Police Alert Function
    • Notification language options
    • Price per gold
  • Open QB Functions to allow for custom code such as custom:
    • AddItem
    • RemoveItem
    • AddMoney
    • TakeMoney
    • GetItemByName
    • Notify

Default configuration file available at the end of this document.

Planned for future release - ETA unknown

  • Option to have the train start moving and need to be jumped on to stop

Note:

This script must be the ONLY train related script on your server or it will mess with the other trains

Uses Escrow Encryption

Insert these 2 items into qb-core/shared/items.lua

```

    -- train robbery

    ["stolen_gold"]                 = {["name"] = "stolen_gold",                    ["label"] = "Gold",                     ["weight"] = 1000,      ["type"] = "item",      ["image"] = "stolen_gold.png",          ["unique"] = false,     ["useable"] = false,    ["shouldClose"] = true,    ["combinable"] = nil,   ["description"] = "Gold stolen from a train"},

    ["grinder"]                     = {["name"] = "grinder",                        ["label"] = "Angle Grinder",            ["weight"] = 1000,      ["type"] = "item",      ["image"] = "grinder.png",              ["unique"] = false,     ["useable"] = false,    ["shouldClose"] = true,    ["combinable"] = nil,   ["description"] = "Tool used to cut things"},

```

## Upload images from the images folder to qb-inventory/html/images/ folder (or respective inventory file location)

Default Config:

```

    Config = {}

    -- Prints information to the F8 and server console

    -- Only needed if testing or working around bugs

    Config.Debug = false 

    -- Cooldown between spawning the train.

    -- Also is the amount of time you have to complete the robbery

    -- before the train is despawned and reset

    Config.RefreshTime = 60 * 45 -- seconds * minutes

    -- How much does it cost to start the train robbery

    Config.CostToStart = 5000

    -- Where to place the NPC that you buy the train's starting location from

    -- All players that want to participate in the heist must be NEAR this npc

    -- when the first purchase is made, but only 1 player needs to purchase it

    Config.StartingPoint = {

        model = "a_m_m_salton_04",

        location = vector4(595.9, -455.73, 24.74, 311.22)

    }

    -- For your information:

    -- Selling point NEEDS TO BE at (-585.89, 5303.75, 70.21)

    -- This is set in a place that cannot be changed due to the cutscene needing this location

    -- Locations that the train can start at. These MUST be on the railroad track that loops around Mt. Chiliad.

    -- Go to any of these locations to see which track it is, if you put a coordinate here that isn't on that 

    -- track, then the train will not function properly.

    Config.TrainSpawnLocations = {

        vector3(2611.03, 1369.5, 35.99),

        vector3(2485.97, 2752.83, 38.22),

        vector3(2613.29, 5497.38, 62.05),

        vector3(662.73, 6437.66, 32.14),

        vector3(555.1, 3184.18, 42.65),

        vector3(2433.31, 3858.55, 39.0),

        vector3(2864.76, 3456.06, 46.75),

        vector3(1926.97, 2309.27, 60.67),

        vector3(2611.53, 30.09, 93.77),

    }

    -- All players that took gold must successfully make it to the sell point

    -- If 1 of your members dies/gets arrested and cannot make it, none of you can sell

    Config.AllPlayersPresentRequired = true 

    Config.Payout = 10000 -- amount per stolen gold items in inventory

    -- Use any police notification function you want. This will get triggered from the client that is robbing

    -- the train. Any function here should be set up like the following on a server.lua script

    -- RegisterNetEvent('police:server:policeAlert', function(text) ... end)

    -- Reference the default qb-policejob function in qb-policejob/server.lua

    -- If you do not want police alerts, leave this as 'none'

    Config.AlertPoliceFunction = 'police:server:policeAlert'

    Config.Guards = { -- If you do not want NPC Guards to spawn, make this list empty

        [1] = {

            model = `s_m_y_blackops_01`,

            weapon = `WEAPON_PISTOL`,

            accuracy = 30,

            maxHealth = 500, -- default 200

            armor = 100

        },

        [2] = {

            model = `s_m_y_blackops_01`,

            weapon = `WEAPON_PISTOL`,

            accuracy = 40,

            maxHealth = 500,

            armor = 100

        },

        [3] = {

            model = `s_m_y_blackops_01`,

            weapon = `WEAPON_PISTOL`,

            accuracy = 40,

            maxHealth = 500,

            armor = 100

        },

        [4] = {

            model = `s_m_y_blackops_01`,

            weapon = `WEAPON_PISTOL`,

            accuracy = 50,

            maxHealth = 500,

            armor = 100

        },

        [5] = {

            model = `s_m_y_blackops_01`,

            weapon = `WEAPON_PISTOL`,

            accuracy = 50,

            maxHealth = 500,

            armor = 100

        },

        [6] = {

            model = `s_m_y_blackops_01`,

            weapon = `WEAPON_PISTOL`,

            accuracy = 50,

            maxHealth = 500,

            armor = 100

        }, -- You can add more if you want to make it harder to survive

    }

    Config.Language = {

        ['begin'] = "~g~[E]~b~ To begin heist ~w~[$" .. Config.CostToStart .. "]",

        ['not_available'] = "The train isn't out yet, be patient",

        ['not_enough_cash'] = "You do not have enough cash",

        ['train_active'] = "A train has been located, stop it and get whats inside!",

        ['stop_train'] = "Press [E] to pull the brake",

        ['train_moving'] = "Train must be stopped first!",

        ['open_crate'] = "[E] Open Crate",

        ['grab_gold'] = "[E] Grab Gold",

        ['missing_grinder'] = "You do not have an Angle Grinder",

        ['gold_taken'] = "You got all the gold, get it to the drop off point",

        ['waiting_players'] = "Waiting for all players to arrive",

        ['sell_blip'] = "Gold Sales",

        ['train_blip'] = "Train",

    }

```