AV Scripts
StoreDiscord
  • Documentation
  • Guides
    • Dealerships
      • Installation
      • Admin Panel
        • All Vehicles
        • Dealerships
        • Auctions
      • Dealership Panel
        • Overview
        • Auctions
        • Employees
        • Orders
        • Payments
        • Showroom
        • Warehouse
        • Pre Owned
        • Settings
      • Buy/Sell Vehicles
      • Catalogue
      • Exports
      • FAQ
    • House Robbery
      • Installation
      • Add Shells
      • Dispatch
      • Exports
      • Weather
      • Minigames
      • Notifications
      • New Houses
      • Object Types
      • Sell Items
    • Illegal Runs
      • Installation
      • Customization
      • Ox Inventory
      • QB Inventory
    • Multicharacter
      • Installation
      • Character Slots
      • Clothes
      • Scenes
        • Previews
      • Exports
      • Weather
    • Paleto Heist
      • Buy here
    • Refund System
      • Installation
        • Inventories
    • Tuning Script
      • Installation
      • Events and Controls
      • Exports
      • Price Multiplier
    • Vehicleshop
      • Installation
      • Admin Panel
      • Addon Vehicles
      • Functions
        • Fuel
        • Keys
        • VIP
        • Weather
      • Garages
      • HUD
      • Society
    • Weather Script
      • Installation
      • Breath Condensation
      • Fog
      • Real Time Sync
      • Exports
    • VIP Script
      • Installation
      • Exports
      • Categories
      • Admin
      • Tebex
      • Free Tokens
  • LAPTOP PACK V3
    • Laptop v3
      • Installation
        • Inventory
        • Cosmo
        • Permissions
        • QBCore
        • Custom Framework/Inventory
        • Phone
        • Translate
      • Browser
      • Terminal
      • Documents
      • APPs Config
      • Exports
    • Boosting
      • Create Profile
      • APP
      • Contracts
      • Dispatch
      • Lockpick Export
      • VIN Export
    • Business
      • Installation
        • Inventories
          • Origen Inventory
            • ESX
            • QBCore
          • OX Inventory
          • QB/PS/LJ Inventory
          • Quasar Inventory
            • ESX
            • QBCore
          • Codem Inventory
          • Tgiann Inventory
        • ESX
      • Admin Panel
        • Create Zones
        • Edit Zones
      • Config
        • Animations
        • Blips
        • Buttons
        • Crafting
        • Effects
        • Events
          • Items
          • Zones
        • Logs
          • Custom Logs
        • Permissions
      • Exports
      • Banking Scripts
      • Multijobs
    • Cameras
      • Installation
        • Vehicle Cameras
      • Place Camera
      • Job Cameras
    • Drugs
      • Installation
      • Admin Panel
      • APP
      • Tables
      • Labs
        • PC
        • Raids
      • Alert Cops
      • Shells
      • Exports
    • Gangs
      • Installation
      • Admin Panel
        • Gangs
        • Whitelist
      • Properties
      • Register Gang
      • APP
        • Members
        • Settings
        • Missions
        • Blackmarket
        • Properties
      • Graffitis
      • Missions
      • Gang NPC
      • Shells
      • Exports
      • Labs
    • Groups
      • Events
      • Exports
    • Music
      • Installation
      • Music Labels
      • APP
        • Search Music
        • Playlists
        • Headphones
      • CDs
    • Racing
      • Installation
        • Permissions
        • Discord Logs
        • Addon Vehicles
      • Admin Panel
      • Categories
      • Events
      • Exports
      • Personal Settings
      • The Underground
    • Custom APPs
    • Discord Support
Powered by GitBook
On this page
  • Register your Category
  • Create your custom function
  • Final Result
  1. Guides
  2. VIP Script

Categories

Last updated 3 days ago

This is a step by step guide on how to create and configure new categories and packages correctly. Make sure to read and understand everything before you start modifying or adding any kind of code to the script.

If you feel that something is missing or unclear, please leave your feedback in my Discord's Support Channel.

Register your Category

  • Go to config/_config.lua > Config.Categories and add your new category (name and label).

  • Create your category.json file in categories folder and make sure is named exactly like the name you set in the previous step (for this example is weapons):

  • Start adding your products to the .json file, your package needs to contain the following fields (some are optional):

    • value: string same as key index, needs to be an unique identifier as string.

    • label: string package name, how the player will see it in the shop panel.

    • moneySymbol (optional): string currency symbol to display alongside the price.

    • account: string money account used to buy a package, the script currency is "tokens" but you can use your own as long as you edit the removeMoney function in server/editable/_framework.lua.

    • account_label: string used for the UI.

    • price: number the product price, needs to be a number.

    • stock: number product current stock, needs to be a number higher than 0 or the Buy button will be blocked.

    • vip: boolean only players with an active VIP membership will be allowed to buy from this category.

    • preview (optional): boolean allows the player to click the product image and zoom it.

    • website (optional): string the Buy Product button will redirect the player to a website, use a valid website URL like your Tebex store, etc.

    • image (optional): string Set a custom image for your package, don't use Discord or Imgur as hosting, use services like Fivemerr, Fivemanage, etc.

Your .json should look something like this:

{
    "weapon_assaultrifle": { // this is a key index, should be unique
        "value": "weapon_assaultrifle", // value should be same as key index
        "label": "Assault Rifle",
        "account": "tokens",
        "account_label": "Tokens",
        "price": 50,
        "stock": 999,
        "vip": true,
        "image": "https://www.gtabase.com/images/jch-optimize/ng/images_gta-5_weapons_assault-rifles_assault-rifle-mk2.webp"
    }
}

You can add custom fields if needed. In business.json, you can see that I added the job name and grade the player will receive after purchasing the package, this fields are used in my processBusiness() function.

Create your custom function

  • Now we need to create our custom function, this function will be triggered when a player clicks the Buy Button and the money is debited from his account.

  • Go to av_vip/server/editable and create a new lua file, for this example I'll name it _weapons.lua

  • Inside this new file create a custom function, this function will receive 3 parameters: source, category and product name. I'll simply name it processWeapon(source,category,product), should look something like this:

  • Now go to server/editable/buy.lua and add your function in the buyFunctions table, like this:

['weapons'] = function(...) -- 'weapons' is the category name
    return processWeapons(...) -- processWeapons(...) is the name of your function
end,

Don't remove the dots or your function will NOT receive any of the parameters (source, category, product).

  • Now go back to your function and add your own logic, what do you want the code to trigger when a player buy your product?, for this example we are using weapons, in my server weapons are items so I need to add the weapon to the player inventory, something like this works for this example:

function processWeapons(source,category,product)
    dbug("processWeapons(source,category,product)", source, category, product)
    -- We need to access the product info by using Categories table > category name > product name
    local itemInfo = Categories[category] and Categories[category][product]
    if itemInfo then -- this contain the whole product info from the .json file
        -- print(json.encode(itemInfo, {indent = true}))
        local metadata = {
            ammo = 100
        }
        -- addItem needs the playerId, item name, amount and metadata (optional)
        addItem(source, product, 1, metadata)
    end
end

Final Result

  • After a script restart, our new category will look like this:

  • After buying my rifle, I get it with the amount of ammo I set in the metadata field:

durability, ammo type and serial fields are defined by ox_inventory not my script