🛠️Script Configuration
Config Settings & Explanations
Configuration
The NKN-CraftingTable script can be customized through the Config.lua
file. This file allows you to adjust various settings to fit the script to your server's needs.
Basic Configuration
Language Settings
Set the default language for the script. The language codes should match those defined in language.lua
.
Config.Language = 'en' -- Default: 'en' for English, 'de' for German
Framework Selection Define the server framework used. This script is currently tailored for ESX frameworks.
Config.Framework = 'esx' -- Options: 'esx' for ESX Legacy
Debug Mode Enable or disable debug mode, which can be useful for troubleshooting.
Config.Debug = false -- Options: true (enable) or false (disable)
Advanced Settings
Image Path Specifies the path to the image resources used in the user interface. (set your inventory img path)
Config.ImgPath = 'your-inventory-resource/html/img/items/' -- Path to UI images
Database Check Interval Sets the interval for checking the crafting database.
Config.CheckInterval = 2500 -- Time in milliseconds
Render Distance for Markers Determines how far players can be from crafting tables for markers and NPCs to render.
Config.RenderDistance = 30.0 -- Distance in meters
Interaction Distance Defines how close a player needs to be to interact with the crafting tables.
Config.InteractDistance = 2.0 -- Distance in meters
Additional Script Configurations
The NKN-CraftingTable script includes additional configurations to further customize its behavior.
Allow Multiple Crafting
Config.allowMultipleCrafting This setting determines whether players are allowed to engage in multiple crafting processes at the same time, either on the same or different crafting tables.
Config.allowMultipleCrafting = true -- Set to true to allow, false to disallow
When set to true
, players can start multiple crafting sessions simultaneously. If set to false
, they must complete or cancel a crafting process before starting another.
Config.allowOfflineProgress This configuration controls whether crafting progress continues even when the player is offline.
Config.allowOfflineProgress = true -- Set to true to allow, false to require online presence
If true
, crafting processes will continue to progress even if the player logs off the server. Setting this to false
requires players to be online for their crafting duration to decrease.
Command Configuration
Define custom commands for server administrators:
Clear Individual Crafting Database
Config.Commands.clearDatabase = 'clearDatabase' -- Command to clear a specific player's crafting data
Clear All Crafting Databases
Config.Commands.clearDatabaseAll = 'clearDatabaseAll' -- Command to clear crafting data for all players
Admin Roles
Specify server roles that have administrative access to crafting table commands
Config.Admins = {
"superadmin",
"admin",
}
Edit Tables
In Config.lua
, you can define the locations and settings for each crafting table on your server using the Config.Coords
table. Here's how you can set it up:
Each table is defined with a unique name and contains its own settings and crafting recipes.
Config.Coords = {
["Table 1"] = { -- Unique name for the table
coords = vec3(-83.93, -835.70, 39.0), -- Coordinates where the crafting table will be located
allowedJob = {"all"}, -- Jobs allowed to use this table ('all' means accessible to everyone)
craftings = {
["Item 1"] = { -- Unique name for the crafting item
output = 'phone', -- Output item name
label = 'Phone', -- Display name of the item
amount = 1, -- Amount of the item produced
duration = 1, -- Crafting duration in milliseconds
resources = { -- Resources required to craft the item
{item = 'water', label = 'Water', amount = 1},
{item = 'bread', label = 'Bread', amount = 1},
},
},
["Item 2"] = {
output = 'bread',
label = 'Bread',
amount = 1,
duration = 1,
resources = {
{item = 'water', label = 'Gold', amount = 15},
{item = 'bread', label = 'Diamond', amount = 3},
},
},
},
marker = { -- Marker settings for the crafting table
enable = true,
type = 1,
size = { x = 1.0, y = 1.0, z = 1.0 },
color = { r = 255, g = 204, b = 0, a = 100 },
},
blip = { -- Blip settings for the crafting table
enable = true,
sprite = 781,
color = 5,
scale = 1.0,
name = 'CRAFTING TABLE 1',
},
npc = { -- NPC settings for the crafting table
enable = true,
model = 'a_m_y_skater_01',
coords = vec3(-83.93, -835.70, 39.6),
heading = 150.23,
},
},
}
Adding More Tables
To add more tables, replicate the structure within Config.Coords
and adjust the settings as needed. Ensure each table and item has a unique name.
Client and Server Notifications + Triggers
clientnotify Function
Used to display notifications to the client. It triggers the ESX notification event.```lua
function clientNotify(message)
TriggerEvent("esx:showNotification", message)
end
serverNotify Function Used to send notifications from the server to a specific client.
function serverNotify(source, message)
TriggerClientEvent("esx:showNotification", source, message)
end
debug Function Prints debug messages to the console if debug mode is enabled in the configuration. It helps in troubleshooting and development.
function debug(msg)
if Config.Debug then
print(('^3[NKN-CRAFTINGTABLE]^0 %s'):format(msg))
end
end
Config.Triggers Defines the ESX events that the script listens to. These events are crucial for the script's interaction with the ESX framework.
Config.Triggers = {
playerLoaded = 'esx:playerLoaded', -- Triggered when a player is loaded
setJob = 'esx:setJob', -- Triggered when a player's job is set or changed
}
playerLoaded
: This event is triggered when a player successfully loads into the server. It's used to initialize player-specific data or settings.setJob
: This event is triggered when a player's job is set or updated. It can be used to refresh job-related permissions or functionalities.
These utility functions and triggers are essential for the script's operation and integration with the ESX framework. Make sure they are correctly set up and correspond to the events and functionalities of your server's version of ESX.
Last updated