Code Monkey home page Code Monkey logo

cdn-fuel's Introduction

Codine Development Fuel Script Banner

cdn-fuel

A functionality fuel system based off of ps-fuel that uses PolyZones that target fueling pumps and vehicles to allow you to refuel your vehicle, as well as interact-sound to play accurate refueling sounds.

Major Credits

Major shoutout to the Project Sloth team. We based this script off of their wonderful ps-fuel script. We wanted to change it up a little bit, but ended up doing a lot more than originally planned, so we though we'd release this on it's own rather than PR things. (https://github.com/Project-Sloth/ps-fuel)

Dependencies:



Codine Development Fuel Script Install Banner

Begin your installation

Here, we shall provide a step-by-step guide on installing cdn-fuel to your server and making it work with other scripts you may already have installed.

Step 1:

First, we will start by renaming the resource "cdn-fuel-main" to just "cdn-fuel".

Next, we will drag the "cdn-fuel" resource into your desired folder in your servers resources directory.

Step 1

Step 2:

Next, we're going to drag the sounds from the cdn-fuel/assets/sounds folder in cdn-fuel, into your interact-sounds folder located at resources/[standalone]/interact-sound/client/html/sounds

Step 2

Step 3:

Next, we're going to open our entire resources folder in whichever IDE you use, (we will be using Visual Studio Code for this example) and replace all of your current exports titled "LegacyFuel", "ps-fuel" or "lj-fuel", with "cdn-fuel". Then you want to ensure cdn-fuel in your server's config file.

step 3


If you do not want the Jerry Can or Syphoning Kit items, you are now finished with installation.


*Otherwise, navigate to Step 4 & Step 5 below, and finish installation.*

Step 4:

We will now be installing the Jerry Can & Syphoning Kit items into your server. You don't have to install either, but they are recommended additions. You can install them & disable them in the config, until you want to use them later on!

If you plan to not use them, you can skip this Step and Step 5!

The first step of installing our items is to navigate to your qb-core/shared/items.lua.

Once there, we will paste the following items at the bottom of our items table.

	["syphoningkit"]				 = {["name"] = "syphoningkit", 					["label"] = "Syphoning Kit", 			["weight"] = 5000, 		["type"] = "item", 		["image"] = "syphoningkit.png", 		["unique"] = true, 		["useable"] = true, 	["shouldClose"] = true,   ["combinable"] = nil,   ["description"] = "A kit made to siphon gasoline from vehicles."},
	["jerrycan"]				 	 = {["name"] = "jerrycan", 						["label"] = "Jerry Can", 				["weight"] = 15000, 	["type"] = "item", 		["image"] = "jerrycan.png", 			["unique"] = true, 		["useable"] = true, 	["shouldClose"] = true,   ["combinable"] = nil,   ["description"] = "A Jerry Can made to hold gasoline."},

For people using inventories with built-in decay, you must add those onto the item, as it doesn't come with it!

You can follow this GIF to better understand how to install the items:
Step4GIF
Now, we need to format item data in our inventory. Firstly, find the app.js located at inventoryname/html/js/app.js.

Now we will CTRL+F the following line:

} else if (itemData.name == "harness") {

Once you have found this line, copy the following one line above it:

        } else if (itemData.name == "syphoningkit") { // Syphoning Kit (CDN-Fuel or CDN-Syphoning!)
            $(".item-info-title").html("<p>" + itemData.label + "</p>");
            $(".item-info-description").html(
                "<p>" + "A kit used to syphon gasoline from vehicles! <br><br>" + itemData.info.gasamount + " Liters Inside.</p>" +
                "</span></p><p style=\"padding-top: .8vh;font-size:11px\"><b>Weight: </b>" + ((itemData.weight * itemData.amount) / 1000).toFixed(1) + " | <b>Amount: </b> " + itemData.amount
            );
        } else if (itemData.name == "jerrycan") { // Jerry Can (CDN-Fuel!)
            $(".item-info-title").html("<p>" + itemData.label + "</p>");
            $(".item-info-description").html(
                "<p>" + "A Jerry Can, designed to hold fuel! <br><br>" + itemData.info.gasamount + " Liters Inside.</p>" +
                "</span></p><p style=\"padding-top: .8vh;font-size:11px\"><b>Weight: </b>" + ((itemData.weight * itemData.amount) / 1000).toFixed(1) + " | <b>Amount: </b> " + itemData.amount
            );

Again, if you have decay, you must add in the options yourself!

Here is a GIF to better understand how to install the "jerrycan" and "syphoningkit" in the app.js
Step4JSGIF

Next, we'll add the item's images into our Inventory resource. This is a simple process.

Navigate to the cdn-fuel resource and follow this path: cdn-fuel/assets/images

Once there, select both images and either drag or CTRL + X and CTRL + V them into your inventory's image folder, usually the path is: inventoryname/html/images/

You can follow this GIF to get a better understanding:
Step4ImagesGIF

Step 5:

This step is only necessary for you to be able to do the /giveitem command or to put items in the qb-shops.

Navigate to inventoryname/server/server.lua, and CTRL + F the following line:

				elseif itemData["name"] == "harness" then
					info.uses = 20

Now we will add the following above the line below:
				elseif itemData["name"] == "syphoningkit" then
					info.gasamount = 0
				elseif itemData["name"] == "jerrycan" then
					info.gasamount = 0

Alternatively, watch this GIF to better understand the process:
Step 5 GIF


QB-Shop Setup

Here are some preconfigured shop items if you wish to put them in the shop. (The Jerry Can is buyable via the Gas Pump!)

        [10] = {
            name = "syphoningkit",
            price = 5000,
            amount = 5,
            info = { gasamount = 0 },
            type = "item",
            slot = 10,
        }, -- CDN-Fuel / CDN-Syphoning
        [11] = {
            name = "jerrycan",
            price = 750,
            amount = 5,
            info = { gasamount = 0 },
            type = "item",
            slot = 11,
        }, -- CDN-Fuel

You will most likely have to change the slot it is in for it to work properly!

QB-Target Issue Fix

There is a possible issue with qb-target if you are using the Config.GlobalVehicleOptions or Config.TargetBones options.

If you are NOT having this issue occur, do not follow the instructions below, as it could mess up other things.


Here is a simple fix for that issue:


Firstly, this option will have to be added to your Config.TargetBones under the bones you are having trouble with:

            {
				type = "client",
				event = "cdn-fuel:client:RefuelMenu",
				icon = "fas fa-gas-pump",
				label = "Insert Nozzle",
				canInteract = function() return Allowrefuel end
            },

Here is an example of how to add this option (ignore the different event names):

Step5part33 QB-Target
This is specifically for the "boot" bone, but, add it on which bone you are having trouble with.



Next, we'll add this simple Function & Export into our QB-Target in the Functions() area:

local function AllowRefuel(state) 
    if state then
        Allowrefuel = true
    else
        Allowrefuel = false
    end
end exports('AllowRefuel', AllowRefuel)

Example Image:

Step5 Part 421421412

Now, set the Config.FuelTargetExport in cdn-fuel/shared/config.lua to true.


Step5 Part 1421942151251

You are now officially done installing!


Enjoy using cdn-fuel, if you have an issues, create an issue on the repository, and we will fix it ASAP!



Codine Development Fuel Script Features Banner

Some features to mention within cdn-fuel:

  • Show all gas station blips via Config Options.
  • Vehicle blowing up chance percent via Config Options.
  • Pump Explosion Chance when running away with Nozzle via Config Options.
  • Global tax and fuel prices via Config Options.
  • Target eye for all base fuel actions, not including Jerry Can & Syphoning.
  • Menu estimating cost for vehicle being refueled. (Tax Included)
  • Fuel Nozzle prop and realistic fueling animation.
  • Added sounds when taking and replacing fuel nozzle, as well as refueling.
  • Select amount of fuel you want to put in your vehicle.
  • On cancel, the amount you put in will be filled.
  • Option to pay cash or with your bank.
  • Toggleable Jerry Cans via Config Options.
  • CDN-Syphoning built-in via Config Options.


Codine Development Fuel Script Showcase Banner

Demonstration of the script

Here's a couple of videos showcasing the script in action!



Codine Development Fuel Script Future Plans Banner

Future Plans

Future Plans are located on the Wiki Section of this repository, labeled CDN-Fuel Roadmap.



Codine Development Links Banner

Codine Links

Credits:

Massive shoutout once again to the team at Project Sloth!

They create super sick scripts that have changed the game when it comes to fivem server development. This script is based off of their ps-fuel script.

cdn-fuel's People

Contributors

dnelyk avatar cdnkasu avatar xviperag avatar

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.