CRAFTING

FiveM Crafting Script Configuration Guide

This guide provides detailed instructions on how to configure a crafting script for your FiveM server. The following sections will cover everything from setting up locations and markers to configuring crafting items and their recipes.

1. General Configuration

The general configuration section includes the framework settings, marker names, and Discord token for integration.

Config = {}

Config.Framework = "NewESX" -- QBCore or ESX or OLDQBCore -- NewESX

Config.MarkerName = "[E] CRAFT"

Config.FormattedToken = "discord-token"  -- https://discord.com/developers/applications

Config.CraftXP = '100' -- How many XP does each Craft give? 100 XP = +1 level

2. Discord Integration Functions

Functions for making HTTP requests to the Discord API to retrieve user avatars and other data.

function DiscordRequest(method, endpoint, jsondata, callback)
    PerformHttpRequest("https://discord.com/api/"..endpoint, function(errorCode, resultData, resultHeaders)
        if errorCode == 200 then
            local data = json.decode(resultData)
            callback(data, nil)
        else
            callback(nil, errorCode)
        end
    end, method, #jsondata > 0 and json.encode(jsondata) or "", {["Content-Type"] = "application/json", ["Authorization"] = "Bot " .. Config.FormattedToken})
end

function GetDiscordAvatar(userID, callback)
    DiscordRequest("GET", "users/"..userID, {}, function(data, error)
        if not error and data and data.avatar then
            local avatarURL = string.format("https://cdn.discordapp.com/avatars/%s/%s.png", userID, data.avatar)
            callback(avatarURL)
        else
            callback(nil)
        end
    end)
end

3. HTTP GET Function

A function to perform HTTP GET requests.

4. Crafting Locations

Define the locations for your crafting stations, including coordinates, NPC details, and markers.

5. Inventory Management Functions

Functions to add and remove items from the player's inventory.

6. Crafting Categories and Items

Define the crafting categories and items, including the required materials, crafting time, and levels.

Last updated