Categories
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: same as key index, needs to be an unique identifier as string.
label: package name, how the player will see it in the shop panel.
moneySymbol (optional): currency symbol to display alongside the price.
account: 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: used for the UI.
price: the product price, needs to be a number.
stock: product current stock, needs to be a number higher than 0 or the Buy button will be blocked.
preview (optional): allows the player to click the product image and zoom it.
website (optional): the Buy Product button will redirect the player to a website, use a valid website URL like your Tebex store, etc.
image (optional): 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:
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:

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:
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:

Last updated