Code Monkey home page Code Monkey logo

envi-receipts's Introduction

Envi-Receipts

Envi-Receipts is a free open-source resource for ESX (using ox inventory) or QB-Core (using qb-inventory) This script utilizes item metadata and a simple UI to create an immersive shopping experience!

Features:

  1. Integration with ESX/QB-Core: The system is compatible with popular frameworks, ensuring seamless functionality with your existing setup.
  2. Customizable item display: You can easily add metadata to display item information in our realistic user interface.
  3. Ox_lib Support: The Receipt System requires and supports ox_lib v3 for a clean user experience.
  4. Simple and Advanced Usage: The system provides both simple and advanced methods for using the Receipt System, catering to users with different needs and skill levels.
  5. Server-side exports: Several server-side exports are available for integrating the Receipt System with other resources or utilizing more advanced functionality.
  6. User-friendly Menus: The Receipt System offers an intuitive in-game menu for adding, reviewing, and managing items and receipts.
  7. Flexible receipt printing: Users can print receipts with customizable details, such as payment status and the number of copies.
  8. Add items to receipt: The Receipt System allows users to easily add items to the bill by entering their details in the provided menu.
  9. Clear receipt: Users can clear the bill to remove all items and start fresh.
  10. Show receipt: The Receipt System provides a feature to review the items added to the receipt and their prices.
  11. Print receipt: The system allows users to give a receipt to a player with the bill's contents.
  12. Multiple item management: You can add as many items as needed via simple or advanced methods, and choose to print the bill via the item, providing a lot of flexibility and possibilities.
  13. Realistic UI: View the receipts and all it's info including tax, sub-total, itemised list and more!
  14. Tax System: Will allow you to set your own tax percentage in the config file.
  15. AP-Government Compatibility: Easy linked with AP Script's Government system to automatically calculate current item tax!
  16. Custom Prop from BzZz: Payment terminal prop from the amazingly talented BzZz! - https://bzzz.tebex.io

Preview: https://youtu.be/srlHgmRgGWY

Table of Contents

  1. Installation
    1. Add Items into qb-core
    2. Add Metadata to Display in App.js
    3. Ensure You Have ox_lib v3 Installed
  2. Usage
    1. Simple Method
    2. Advanced Usage

Installation

1.1. Add Items into your qb-core or ox_inventory! ('receipt' and 'payment_terminal')

Before using the Receipt System, ensure that you have added the necessary items into the appropriate resource. This will enable the system to recognize and process the items needed.

1.2. Add Metadata to Display in App.js (QB-INVENTORY ONLY)

To display the item information, insert the following code into your app.js file:

} else if (itemData.name == "receipt") {
  var items = "";
  var i = 1;
  while (itemData.info["item" + i]) {
    items += "<p><strong>Item " + i + ": </strong><span>" + itemData.info["item" + i] + " - $" + itemData.info["price" + i] + "</span></p>";
    i++;
  }
  $(".item-info-title").html("<p>" + itemData.label + "</p>");
  $(".item-info-description").html(
    "<p><strong>Date: </strong><span>" + itemData.info.date + "</span></p>" +
    "<p><strong>Time: </strong><span>" + itemData.info.time + "</span></p>" +
    items +
    "<p><strong>Total: </strong><span>$" + itemData.info.total + "</span></p>" +
    "<p><strong>Tax Amount: </strong><span>$" + itemData.info.tax_amount + "</span></p>" +
    "<p><strong>Total After Tax: </strong><span>$" + itemData.info.total_after_tax + "</span></p>" +
    "<p><strong>Status: </strong><span>" + itemData.info.description.split(' - ')[1] + "</span></p>"
  )
}

1.3. Ensure You Have ox_lib Installed

Make sure you have ox_lib installed on your server. This library is required for the Receipt System to work correctly.

2. Usage

2.1. Simple Method

The simple method of using the Receipt System involves the following steps:

  1. Trigger menu via item: To open the Receipt System menu, interact with the in-game item.
  2. Add items manually: Once the menu is open, you can add items to the receipt by entering their details in the provided menu.
  3. Show Basket: You can review the items added to the receipt and their prices by checking the basket. If you need to remove any items, simply click the "Clear Basket" button.
  4. Print Receipt: After finalizing the items and their prices, click the "Print Receipt" button. You will be prompted to select whether the bill is paid in full or not and the number of receipt copies you want to print.

2.2. Advanced Usage

To integrate the Receipt System into other resources or utilize server exports for more advanced functionality.

addToBill This server-side export allows you to add an item to a player's bill:

-- addToBill(player, itemName, itemPrice)
exports['envi-receipts']:addToBill(source, itemName, itemPrice)

clearBill This server-side export allows you to clear a player's bill:

-- clearBill(player)
exports['envi-receipts']:clearBill(source)

showBasket This server-side export allows you to get a player's bill as a table of items and their prices:

-- showBasket(player)
local basket = exports['envi-receipts']:showBasket(source)

giveBill This server-side export allows you to give a receipt to a player with the bill's contents:

-- giveBill(player, howMany, paid)
exports['envi-receipts']:giveBill(source, 1, true)

When you want to give a receipt for a single item, you can follow this sequence:

Clear the bill. Add the item to the bill. Give the bill to the player. Clear the bill again.

Here's an example of how to do this after a QBCore.Function.AddItem in another script:

RegisterServerEvent('burger:example', function(source)
 local Player = QB.Functions.GetPlayer(source)
 Player.Functions.AddItem("burger", 1)
 exports['envi-receipts']:clearBill(source)      -- clears any old data
 exports['envi-receipts']:addToBill(source, "Burger", 50)   -- adds it to the total bill
 exports['envi-receipts']:giveBill(source, 1, true)  -- prints the items currently added and rewards receipt item
 exports['envi-receipts']:clearBill(source)      -- clear the bill again for good measure
end)

You can also add as many items as you like/ choose when to print the bill via the item. Lots of possibilities!

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.