=============== LIBRARY RULES =============== From library maintainers: - Answer only from the published Murphy's Craft documentation, in the user's language. Cite a relevant clickable Markdown source link under https://docs.murphy-workshop.com/murphy-s-craft/. - This is a public RedM plugin. Do not substitute FiveM, another Murphy plugin, or undocumented framework APIs. Do not mention or speculate about unpublished products. - Never invent commands, exports, event names, configuration keys, default values or compatibility. If the documentation does not establish an answer, say so and link to the closest relevant reference. - Ask for the installed framework and plugin version when they affect behavior. A public release note establishes that release, not a guarantee about files actually installed on the user's server. - Keep answers concise and focused. Give only the requested code. Preserve existing configuration entries and label excerpts. Do not use emojis or long dashes. Remove display line numbers from copied code. - Distinguish client and server context, online server player IDs and persistent character identifiers. Do not interchange commands, events and exports without explicit documentation. - Do not promise data preservation, backups, refunds or offline behavior unless the relevant documentation establishes it. Do not recommend deleting data or blindly replacing a full core file. - Store screenshots show one demonstration setup. Do not infer fixed rewards, version, framework, controls or guarantees from a picture. Do not claim that an in-game test was performed. - Never claim access to purchases, accounts, licenses or server actions. For account or order questions only, link to https://murphy-workshop.com/portal or https://murphy-workshop.com/support. - Published reference: Oui. oxmysql, framework compatible, puis murphy_craft. Ne pas inventer d'installation de base de données automatique ou importer des fichiers non établis. - Published reference: hideResources masque les ingrédients en laissant la recette visible. hideUntilCraftable masque la recette jusqu'à possession de tous les ingrédients requis. ### Start Resource in server.cfg Source: https://docs.murphy-workshop.com/murphy-s-craft/getting-started/installation Add the ensure command to your server.cfg file to load the resource on server startup. ```cfg ensure murphy_craft ``` -------------------------------- ### Basic Kitchen Station Configuration Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/stations An example configuration for a kitchen crafting station, including categories, coordinates, and blip settings. ```lua { name = "Strawberry Kitchen", cat = { "cuisinier", "food" }, coords = vector3(-1773.546, -393.5962, 157.0192), radius = 5.0, blip = { hash = "blip_product_moonshine", displaydistance = 50.0, scale = 0.3 } } ``` -------------------------------- ### Basic Kitchen Setup Configuration Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/crafting-tables-configuration-guide A standard crafting table configuration for a kitchen with a defined blip hash, display distance, and scale. ```lua { name = "Valentine Kitchen", cat = { "cuisinier", "food" }, coords = vector3(-275.42, 805.33, 119.38), radius = 5.0, blip = { hash = "blip_product_moonshine", displaydistance = 50.0, scale = 0.3, }, }, ``` -------------------------------- ### Define Multiple Crafting Resources Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/recipes An example of an array containing multiple resource definitions for a single recipe. ```lua ressources = { { name = "Iron Ore", neededQuantity = 3, item = "iron_ore" }, { name = "Coal", neededQuantity = 2, item = "coal" }, { name = "Water", neededQuantity = 1, item = "water_bucket" }, } ``` -------------------------------- ### Define standard craft recipes with visibility settings Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/hidden-recipes-system Example of integrating various visibility properties within a standard alchemy craft configuration. ```lua Craft["alchemy"] = { name = "Alchemy", recipes = { { name = "Basic Potion", freeaccess = true, ressources = { ... } }, { name = "Advanced Potion", hideResources = true, -- Hides ingredients ressources = { ... } }, { name = "Ultimate Potion", hideUntilCraftable = true, -- Hidden until craftable ressources = { ... } } } } ``` -------------------------------- ### Configure Config.CraftingTables Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/crafting-tables-configuration-guide A complete example of defining various crafting workshops including their categories, coordinates, interaction radius, and map blip settings. ```lua Config.CraftingTables = { -- Kitchen / Cooking { name = "Strawberry Kitchen Setup", cat = { "cuisinier", "food" }, coords = vector3(-1773.546, -393.5962, 157.0192), radius = 5.0, blip = { hash = "blip_product_moonshine", displaydistance = 50.0, scale = 0.3, }, }, -- Medical { name = "Strawberry Doctor Workshop", cat = { "docteur" }, coords = vector3(-1805.461, -431.6964, 157.9324), radius = 5.0, blip = { hash = "blip_mp_pickup", displaydistance = 50.0, scale = 0.3, }, }, -- Weapons { name = "Strawberry Gunsmith Workshop", cat = { "armurier" }, coords = vector3(-1847.763, -427.9155, 159.7529), radius = 5.0, blip = { hash = "blip_weapon_handgun", displaydistance = 50.0, scale = 0.3, }, }, -- Tinkering / Tools { name = "Strawberry Tinkering Workshop", cat = { "bricoleur" }, coords = vector3(-1815.606, -429.1396, 159.1538), radius = 5.0, blip = { hash = "blip_weapon_throwing_knife", displaydistance = 50.0, scale = 0.3, }, }, -- Recycling { name = "Strawberry Recycling Workshop", cat = { "recyclage" }, coords = vector3(-1819.836, -421.7756, 159.092), radius = 5.0, blip = { hash = "blip_shop_blacksmith", displaydistance = 50.0, scale = 0.3, }, }, } ``` -------------------------------- ### Create Mining Category File Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/recipes An example of creating a new category file named mining.lua in the shared/craft/ directory. ```lua Craft["mining"] = { name = "Mining & Smelting", recipes = { -- Add recipes here } } ``` -------------------------------- ### Example - Doctor Category configuration Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/job-locked-crafting A practical example of a category restricted to doctors with a minimum grade of 2. ```lua Craft["medic_advanced"] = { name = "Advanced Medicine", job = "doctor", -- Only doctors can see this category jobgrade = 2, -- Minimum grade 2 required recipes = { { tree_ref = "root", xp = 10, name = "Surgery Kit", freeaccess = true, image = "nui://redemrp_inventory/html/items/kitchirurgie.png", desc = "Advanced medical equipment", duration = 10, amount = 1, item = "surgery_kit", ressources = { { name = "Needle", neededQuantity = 2, item = "needle" }, { name = "Thread", neededQuantity = 5, item = "thread" }, { name = "Bandage", neededQuantity = 3, item = "bandage" }, } }, } } ``` -------------------------------- ### Configure animation.walkTo for workstation scenarios Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/murphy-craft-1-14-0-new-configuration-options Defines an animation block that makes the character walk to a specific coordinate and heading before starting a scenario. The walk is cancelled if the menu closes before arrival. ```lua animation = { type = "scenario", scenario = "WORLD_HUMAN_BLACKSMITH", walkTo = vector4(2949.8, 562.5, 43.7, 90.0), -- x, y, z, heading } ``` -------------------------------- ### Crafting Table Configuration Without Blip Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/crafting-tables-configuration-guide A configuration example where the blip property is explicitly set to nil, resulting in no map marker. ```lua { name = "Hidden Workshop", cat = { "bricoleur", "basic" }, coords = vector3(1234.56, -789.01, 45.67), radius = 3.0, blip = nil, -- No map marker }, ``` -------------------------------- ### Mixed Access Recipe Configuration Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/job-locked-crafting An example of a blacksmith category containing a mix of public recipes and recipes restricted to specific jobs like blacksmiths or sheriffs. ```lua Craft["blacksmith"] = { name = "Blacksmith", -- No job/jobgrade here = category accessible to all recipes = { -- Recipe accessible to everyone { tree_ref = "root", xp = 5, name = "Horseshoe", freeaccess = true, image = "nui://redemrp_inventory/html/items/horseshoe.png", desc = "For shoeing horses", duration = 8, amount = 1, item = "horseshoe", ressources = { { name = "Iron Ingot", neededQuantity = 2, item = "iron_ingot" }, } }, -- Recipe reserved for blacksmiths { tree_ref = "node1", xp = 20, name = "Quality Sword", job = "blacksmith", -- Only blacksmiths can see this recipe jobgrade = 1, -- Minimum grade 1 freeaccess = true, image = "nui://redemrp_inventory/html/items/sword.png", desc = "A superior quality sword", duration = 30, amount = 1, item = "quality_sword", ressources = { { name = "Steel Ingot", neededQuantity = 5, item = "steel_ingot" }, { name = "Leather", neededQuantity = 2, item = "leather" }, } }, -- Recipe reserved for sheriffs { tree_ref = "node2", xp = 15, name = "Handcuffs", job = "sheriff", -- Only sheriffs can see this recipe freeaccess = true, image = "nui://redemrp_inventory/html/items/handcuffs.png", desc = "For arresting outlaws", duration = 15, amount = 1, item = "handcuffs", ressources = { { name = "Iron Ingot", neededQuantity = 3, item = "iron_ingot" }, } }, } } ``` -------------------------------- ### Always-Visible Blip Configuration Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/crafting-tables-configuration-guide A configuration example where displaydistance is set to nil to ensure the blip is always visible on the map. ```lua { name = "Blackwater Forge", cat = { "furnace", "armurier" }, coords = vector3(-802.45, -1241.67, 43.52), radius = 6.0, blip = { hash = "blip_shop_blacksmith", displaydistance = nil, -- Always visible on map scale = 0.4, }, }, ``` -------------------------------- ### Doctor Workshop Configuration with Multiple Categories Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/crafting-tables-configuration-guide A workshop setup featuring multiple categories and a specific blip color modifier. ```lua { name = "Saint Denis Medical Center", cat = { "docteur", "medicine", "bandages" }, coords = vector3(2721.55, -1235.87, 49.94), radius = 8.0, blip = { hash = "blip_mp_pickup", modifier = "BLIP_MODIFIER_MP_COLOR_1", displaydistance = 100.0, scale = 0.4, }, }, ``` -------------------------------- ### Gunsmith Workshop Configuration with Color Modifier Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/crafting-tables-configuration-guide A gunsmith workshop setup utilizing a specific blip hash and color modifier. ```lua { name = "Rhodes Gunsmith", cat = { "armurier" }, coords = vector3(1294.52, -1295.33, 76.91), radius = 5.0, blip = { hash = "blip_weapon_handgun", modifier = "BLIP_MODIFIER_MP_COLOR_4", displaydistance = 75.0, scale = 0.35, }, }, ``` -------------------------------- ### Get Current Language with T.getCurrentLanguage Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/translation-system Returns the active language code, such as 'fr' or 'en'. ```javascript const lang = T.getCurrentLanguage(); // Returns 'fr' or 'en' ``` -------------------------------- ### Run Recommended Diagnostics Source: https://docs.murphy-workshop.com/murphy-s-craft/reference/troubleshooting Use these print statements to verify current configuration values in the server console. ```lua -- Check these configuration values print(Config.DevMode) print(Config.framework) print(Config.EnableSpecialisation) ``` -------------------------------- ### Configure Framework Integration Source: https://docs.murphy-workshop.com/murphy-s-craft/getting-started/configuration Select the server's core framework for compatibility. Supported values are 'REDEMRP2k23', 'vorp', or 'rsg-core'. ```lua Config.framework = "REDEMRP2k23" -- Supported: "REDEMRP2k23", "vorp", "rsg-core" ``` -------------------------------- ### Configure Performance and Security Source: https://docs.murphy-workshop.com/murphy-s-craft/getting-started/configuration Settings for crafting cooldowns, data autosave intervals, and Discord logging. ```lua Config.CraftCooldown = 500 -- Milliseconds between craft attempts Config.SaveInterval = 120 -- Seconds between data autosaves Config.EnableDiscordLogs = true -- Toggle Discord logging ``` -------------------------------- ### OpenCraftStation Client Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Opens a specific crafting station using its configuration index. ```lua exports['murphy_craft']:OpenCraftStation(1) ``` -------------------------------- ### Recipe Configuration Syntax Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/job-locked-crafting The basic structure for defining a recipe with job-specific access requirements. ```lua { tree_ref = "root", name = "Recipe Name", job = "job_name", -- Required job for this recipe jobgrade = 0, -- Minimum grade (optional) freeaccess = true, -- ... other parameters } ``` -------------------------------- ### Configure Recipe Accessibility Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/recipes Demonstrates how to set recipe accessibility using tree_ref and freeaccess properties to control specialization requirements. ```lua -- Always accessible (no specialization needed) { tree_ref = "root", freeaccess = true, -- ... } -- Requires "root" node to be unlocked { tree_ref = "root", freeaccess = false, -- or just omit freeaccess -- ... } -- Requires "node1" to be unlocked in specialization tree { tree_ref = "node1", -- ... } ``` -------------------------------- ### GetAllCraftCategories Client Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Returns a list of all available crafting categories in the system. ```lua local categories = exports['murphy_craft']:GetAllCraftCategories() -- Returns: {"cuisinier", "docteur", "bricoleur", "food", ...} ``` -------------------------------- ### Configure config.lua Source: https://docs.murphy-workshop.com/murphy-s-craft/getting-started/installation Adjust the settings in config.lua to match your server's framework, language, and feature preferences. ```lua Config.framework = "REDEMRP2k23" -- Set your framework Config.Locale = "fr" -- Choose language Config.Debug = false -- Enable/disable debug mode Config.EnableSpecialisation = true -- Enable/disable specialisation ``` -------------------------------- ### Define Alternative Tools with anyOf Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/murphy-craft-1-14-0-new-configuration-options Allows defining multiple tool options for a recipe in shared/craft/*.lua. The player only needs to own one of the items listed in the anyOf group. ```lua tools = { -- classic form: this exact item is required { name = "Hammer", item = "hammer", uses = 10 }, -- new form: bone knife OR regular knife, either one works { anyOf = { { name = "Bone knife", item = "bone_knife", uses = 5 }, { name = "Knife", item = "WEAPON_MELEE_KNIFE" }, }}, } ``` -------------------------------- ### Set Framework Compatibility Source: https://docs.murphy-workshop.com/murphy-s-craft/reference/troubleshooting Configure the supported framework in config.lua. Supported values include REDEMRP2k23, vorp, and rsg-core. ```lua Config.framework = "REDEMRP2k23" -- Supported values: "REDEMRP2k23", "vorp", "rsg-core" ``` -------------------------------- ### GetSpecialisations Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Returns the configuration for all specialisations. ```lua local specialisations = exports['murphy_craft']:GetSpecialisations() ``` -------------------------------- ### GetCraftCategories Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Returns the configuration for all crafting categories. ```lua local categories = exports['murphy_craft']:GetCraftCategories() ``` -------------------------------- ### Event Listener murphy_craft:OnXPSet Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Reacts when XP is directly modified for a specialisation. ```lua AddEventHandler('murphy_craft:OnXPSet', function(specialisationId, amount) print("XP set to " .. amount .. " for " .. specialisationId) end) ``` -------------------------------- ### Configure Basic Categories Source: https://docs.murphy-workshop.com/murphy-s-craft/getting-started/configuration Define categories accessible to all players everywhere. ```lua Config.BasicsCategory = { "basic" } ``` -------------------------------- ### Temporary XP bonus system Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Implement a temporary XP multiplier by hooking into the murphy_craft:AddXP event and managing multipliers via a command. ```lua -- Server local xpMultipliers = {} RegisterCommand('xpboost', function(source, args) local targetId = tonumber(args[1]) local multiplier = tonumber(args[2]) or 2 local duration = tonumber(args[3]) or 3600 -- 1 hour by default xpMultipliers[targetId] = multiplier SetTimeout(duration * 1000, function() xpMultipliers[targetId] = nil end) end, true) -- Hook on XP event to apply multiplier AddEventHandler('murphy_craft:AddXP', function(source, speId, amount) if xpMultipliers[source] then local bonus = amount * (xpMultipliers[source] - 1) TriggerEvent('murphy_craft:AddXP', source, speId, bonus) end end) ``` -------------------------------- ### Configure Global Basic Categories Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/crafting-tables-configuration-guide Categories listed in Config.BasicsCategory are accessible to players regardless of their location. ```lua Config.BasicsCategory = { "basic" } -- "basic" recipes available anywhere ``` -------------------------------- ### Define a recipe with multiple output items Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/recipes A recipe structure that outputs multiple different items by providing a table for the item parameter. ```lua { tree_ref = "root", name = "Salvage Kit", freeaccess = true, image = "nui://path/image.png", desc = "Salvage materials from items", duration = 5, amount = 1, item = { ["iron_scrap"] = 3, ["wood_scrap"] = 2, ["cloth"] = 1 }, ressources = { { name = "Broken Tool", neededQuantity = 1, item = "broken_tool" }, } } ``` -------------------------------- ### Configure Config.AllowClientXPRequests Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/murphy-craft-1-14-0-new-configuration-options Sets the default state for client-side XP requests in shared/config.lua. It is recommended to keep this false and use the provided server-side trigger instead. ```lua Config.AllowClientXPRequests = false ``` ```lua TriggerEvent('murphy_craft:AddXP', source, 'docteur', 50) ``` -------------------------------- ### OpenCraftStation(stationIndex) Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Opens a specific crafting station based on its configuration index. ```APIDOC ## OpenCraftStation(stationIndex) ### Description Opens a crafting station by its config index. ### Parameters - **stationIndex** (number) - Required - The index of the station to open. ``` -------------------------------- ### OpenCraftMenu Client Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Opens the crafting menu, optionally filtered by specific categories. ```lua -- Open with all categories exports['murphy_craft']:OpenCraftMenu() -- Open with specific categories exports['murphy_craft']:OpenCraftMenu({'cuisinier', 'food'}) ``` -------------------------------- ### File Structure Overview Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/translation-system The directory structure for the translation system components. ```text ui/ ├── translations.js # Translation system and data ├── index.html # HTML with data-translate attributes ├── script.js # JavaScript with translation integration └── ... ``` -------------------------------- ### Event Listener murphy_craft:OnAllSpecialisationsReset Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Reacts when all specialisations are reset. ```lua AddEventHandler('murphy_craft:OnAllSpecialisationsReset', function() print("All specialisations have been reset") end) ``` -------------------------------- ### Configure Debug Mode Source: https://docs.murphy-workshop.com/murphy-s-craft/getting-started/configuration Settings to toggle development features and console logging. ```lua Config.DevMode = false Config.Debug = false ``` -------------------------------- ### Define Basic Categories in shared/config.lua Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/recipes Specify categories that are accessible at any crafting location. ```lua Config.BasicsCategory = { "basic" } -- These categories work anywhere ``` -------------------------------- ### GetSpecialisationState Client Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Retrieves the complete state of all player specialisations, including XP and points. ```lua local state = exports['murphy_craft']:GetSpecialisationState() --[[ Returns: { ["docteur"] = { SelectedSpecialisation = true, AvailablePoints = 3, TotalPoints = 5, xp = 150 }, ... } ]] ``` -------------------------------- ### GetSpecialisationXP Client Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Returns the total XP earned for a specific specialisation. ```lua local xp = exports['murphy_craft']:GetSpecialisationXP('docteur') -- Returns: 150 ``` -------------------------------- ### Define a basic crafting recipe Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/recipes A standard recipe structure defining a single output item and its required materials. ```lua { tree_ref = "root", -- Specialization tree reference xp = 5, -- XP gained when crafting name = "Item Name", -- Display name freeaccess = true, -- Accessible without unlocking image = "nui://path/to/image.png", -- Item image desc = "Item description", -- Description shown in UI duration = 10, -- Crafting time in seconds amount = 1, -- Amount produced item = "item_name", -- Output item name ressources = { -- Required materials { name = "Material Name", neededQuantity = 2, item = "material_item" }, } } ``` -------------------------------- ### murphy_craft:AddXP Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Adds XP to a player's specialisation and automatically recalculates their level. ```APIDOC ## murphy_craft:AddXP ### Description Adds XP to a player's specialisation and automatically recalculates their level. ### Usage TriggerEvent('murphy_craft:AddXP', source, specialisationId, amount) ``` -------------------------------- ### Trigger murphy_craft:SetXP Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Sets a specific specialisation's XP for a player. ```lua TriggerEvent('murphy_craft:SetXP', source, 'bricoleur', 100) ``` -------------------------------- ### Define Craft Category File Path Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/recipes The directory where all craft category Lua files must be placed to be automatically loaded by the resource. ```text murphy_craft/shared/craft/ ``` -------------------------------- ### Update server configuration for locale Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/translation-system Add support for the new language code in the server configuration file. ```lua Config.Locale = "es" -- Add support for new language code ``` -------------------------------- ### Define a recipe with tools Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/tools-system Add a tools field to a recipe definition to require specific items that remain in the player's inventory after crafting. ```lua { name = "Fish Fillet", item = "filetpoisson", amount = 2, duration = 5, ressources = { { name = "Fish", neededQuantity = 1, item = "a_c_fishbluegil_01_ms" } }, tools = { { name = "Knife", item = "WEAPON_MELEE_KNIFE" } } } ``` -------------------------------- ### Configure Crafting Props in shared/config.lua Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/crafting-props-system Define crafting stations by specifying the display name, prop model or hash, available categories, and interaction radii. ```lua Config.CraftingProps = { { name = "Campfire", -- Display name shown in the tip prop = "p_campfire02x", -- Prop model name or hash cat = { "cuisinier", "food" }, -- Categories available at this prop searchRadius = 15.0, -- Radius around player to search for this prop (default: 10.0) interactionRadius = 2.0, -- Distance from prop to allow interaction (default: 2.0) }, { name = "Butcher Table", prop = `p_table29x`, -- Can use hash directly cat = { "food" }, searchRadius = 10.0, interactionRadius = 1.5, }, { name = "Forge", prop = "p_anvil01x", cat = { "armurier", "bricoleur" }, searchRadius = 12.0, interactionRadius = 3.0, }, } ``` -------------------------------- ### Configure Global Specialisation Settings Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/specialisations Set global parameters for the specialisation system, including enabling the feature, setting the maximum number of allowed specialisations, and defining the default required grade. ```lua Config.EnableSpecialisation = true -- Enable/disable specialization system Config.AuthorizedSpecialisationAmount = 1 -- Maximum number of specializations Config.JobGradeOnSpecialisation = 3 -- Default required grade ``` -------------------------------- ### Event Listener murphy_craft:OnLevelUp Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Reacts when a player levels up in a specialisation. ```lua AddEventHandler('murphy_craft:OnLevelUp', function(specialisationId, newLevel, pointsGained, totalPoints) print("Level up! " .. specialisationId .. " level " .. newLevel) print("+" .. pointsGained .. " points (total: " .. totalPoints .. ")") end) ``` -------------------------------- ### Event Listener murphy_craft:OnSpecialisationReset Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Reacts when a specific specialisation is reset. ```lua AddEventHandler('murphy_craft:OnSpecialisationReset', function(specialisationId) print("Specialisation " .. specialisationId .. " reset") end) ``` -------------------------------- ### OpenCraftMenu(categories?) Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Opens the crafting menu. Optionally accepts a list of categories to filter the menu. ```APIDOC ## OpenCraftMenu(categories?) ### Description Opens the crafting menu. If categories are provided, only those categories will be displayed. ### Parameters - **categories** (table) - Optional - A list of category identifiers to display. ``` -------------------------------- ### Configure Specialisation System Source: https://docs.murphy-workshop.com/murphy-s-craft/getting-started/configuration Settings to enable the specialisation system, set the maximum number of specialisations per player, and define the job grade for specialised players. ```lua Config.EnableSpecialisation = true Config.AuthorizedSpecialisationAmount = 1 Config.JobGradeOnSpecialisation = 3 ``` -------------------------------- ### Define a Minimal Recipe Template Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/recipes Use this Lua table structure to define a new crafting recipe, including its resource requirements and output details. ```lua { tree_ref = "root", name = "Recipe Name", freeaccess = true, image = "nui://inventory/html/items/item.png", desc = "Description", duration = 10, amount = 1, item = "output_item", ressources = { { name = "Material", neededQuantity = 1, item = "material_item" }, } } ``` -------------------------------- ### Configure Menu Keybind Source: https://docs.murphy-workshop.com/murphy-s-craft/getting-started/configuration Customize the key used to open the crafting menu. The default is 0x71 (F2 key). ```lua Config.MenuKeybind = 0x71 -- F2 key by default ``` -------------------------------- ### GetCraftCategories() Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Retrieves crafting categories configuration. ```APIDOC ## GetCraftCategories() ### Description Returns the configuration table for all crafting categories. ``` -------------------------------- ### Event Listener murphy_craft:OnRecipeUnlocked Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Reacts when a recipe is unlocked. ```lua AddEventHandler('murphy_craft:OnRecipeUnlocked', function(specialisationId, recipeId) print("Recipe unlocked: " .. recipeId .. " in " .. specialisationId) end) ``` -------------------------------- ### Configure Multiple Crafting Locations Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/crafting-tables-configuration-guide Define multiple crafting tables with the same or different categories at specific coordinates. ```lua -- Strawberry location { name = "Strawberry Kitchen", cat = { "cuisinier" }, coords = vector3(-1773.546, -393.5962, 157.0192), ... }, -- Valentine location { name = "Valentine Kitchen", cat = { "cuisinier" }, coords = vector3(-275.42, 805.33, 119.38), ... } ``` -------------------------------- ### Event Listener murphy_craft:OnXPGained Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Reacts when a player gains XP. ```lua AddEventHandler('murphy_craft:OnXPGained', function(specialisationId, amount, newTotal, pointsGained) print("+" .. amount .. " XP in " .. specialisationId) print("Total: " .. newTotal .. " XP") if pointsGained > 0 then print("+" .. pointsGained .. " points!") end end) ``` -------------------------------- ### Trigger murphy_craft:AddXP Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Adds XP to a player's specialisation and automatically recalculates their level. ```lua TriggerEvent('murphy_craft:AddXP', source, 'docteur', 50) ``` -------------------------------- ### SetPlayerSpecialisationXP(source, specialisationId, amount) Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Sets the XP for a player's specialisation. ```APIDOC ## SetPlayerSpecialisationXP(source, specialisationId, amount) ### Description Sets a player's XP for a specific specialisation to a fixed amount. ### Parameters - **source** (number) - The player source ID. - **specialisationId** (string) - The ID of the specialisation. - **amount** (number) - The XP value to set. ``` -------------------------------- ### SetPlayerSpecialisationXP Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Sets the XP for a player's specialisation to a specific amount. ```lua local success = exports['murphy_craft']:SetPlayerSpecialisationXP(source, 'docteur', 100) ``` -------------------------------- ### GetSpecialisations() Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Retrieves specialisation configuration. ```APIDOC ## GetSpecialisations() ### Description Returns the full configuration table for all specialisations. ``` -------------------------------- ### Register dynamic station recipes with RegisterStationRecipes Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/murphy-craft-1-14-0-new-configuration-options Server-side export used to register recipes at runtime for resources that do not ship with static station files. This prevents 'unknown station recipe' errors. ```lua -- server-side, raw config shape (same as shared/station/*.lua) exports['murphy_craft']:RegisterStationRecipes("tannery", { { name = "Leather", duration = 30, ingredients = { { name = "Pelt", item = "pelt", amount = 2 } }, output = { { name = "Leather", item = "leather", amount = 1 } }, }, }) ``` -------------------------------- ### Export GetPlayerAllSpecialisations Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Returns all specialisations for a player along with their progression data. ```lua local all = exports['murphy_craft']:GetPlayerAllSpecialisations(source) --[[ Returns: { ["docteur"] = { name = "Doctor", id = "docteur", progress = { ... }, unlockedRecipes = {"root", "node1"} }, ... } ]] ``` -------------------------------- ### Configure tool durability in recipes Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/tool-durability-system Add a 'uses' field to the tools table within your recipe configuration to define how many times a tool can be used before consumption. ```lua recipes = { { name = "Iron Sword", item = "iron_sword", amount = 1, category = "blacksmith", ressources = { { name = "Iron Ingot", item = "iron_ingot", neededQuantity = 3 }, }, tools = { { name = "Hammer", item = "hammer", uses = 10 }, -- consumed after 10 crafts { name = "Anvil", item = "anvil" }, -- never consumed }, }, } ``` -------------------------------- ### Configure Language Source: https://docs.murphy-workshop.com/murphy-s-craft/getting-started/configuration Set the default language for translations. Supported values are 'fr' or 'en'. ```lua Config.Locale = "fr" -- "fr" or "en" supported ``` -------------------------------- ### Export GetXPForLevel Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Returns the total XP required to reach a specific level for a specialisation. ```lua local xpRequired = exports['murphy_craft']:GetXPForLevel('docteur', 5) -- Returns: 100 ``` -------------------------------- ### GetCategoryRecipes Client Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Retrieves all recipes associated with a specific crafting category. ```lua local recipes = exports['murphy_craft']:GetCategoryRecipes('food') ``` -------------------------------- ### Resource Folder Structure Source: https://docs.murphy-workshop.com/murphy-s-craft/getting-started/installation The required directory structure for the murphy_craft resource within your server's resources folder. ```text resources/ └── murphy_craft/ ├── client/ ├── server/ ├── shared/ ├── ui/ ├── config.lua └── fxmanifest.lua ``` -------------------------------- ### Define Crafting Categories Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/crafting-tables-configuration-guide Categories defined in the craft files must match the keys referenced in the configuration. ```lua -- In shared/craft/cuisinier.lua Craft["cuisinier"] = { name = "Cooking", recipes = { ... } } -- In Config.CraftingTables cat = { "cuisinier" } -- Must match "cuisinier" key ``` -------------------------------- ### UnlockPlayerRecipe(source, category, recipeId) Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Unlocks a recipe for a player. ```APIDOC ## UnlockPlayerRecipe(source, category, recipeId) ### Description Unlocks a specific recipe for a player. ### Parameters - **source** (number) - The player source ID. - **category** (string) - The recipe category. - **recipeId** (string) - The ID of the recipe. ``` -------------------------------- ### GetLocalSpecialisationProgress Client Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Returns the local progression details for a specific specialisation. ```lua local progress = exports['murphy_craft']:GetLocalSpecialisationProgress('docteur') --[[ Returns: { xp = 150, level = 3, totalPoints = 5, availablePoints = 3 } ]] ``` -------------------------------- ### Event Listener murphy_craft:OnRecipeLocked Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Reacts when a recipe is locked. ```lua AddEventHandler('murphy_craft:OnRecipeLocked', function(specialisationId, recipeId) print("Recipe locked: " .. recipeId) end) ``` -------------------------------- ### Add Crafting Table in shared/config.lua Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/recipes Define a new crafting table location with specific categories and blip settings. ```lua Config.CraftingTables = { { name = "Blacksmith Workshop", -- Blip name cat = { "mining", "blacksmith" }, -- Available categories coords = vector3(100.0, 200.0, 30.0), -- Location radius = 5.0, -- Interaction radius blip = { hash = "blip_shop_blacksmith", displaydistance = 50.0, scale = 0.3, }, }, } ``` -------------------------------- ### GetNearbyCraftingCategories Client Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Returns a list of crafting categories accessible in the player's current vicinity. ```lua local categories = exports['murphy_craft']:GetNearbyCraftingCategories() -- Returns: {"cuisinier", "food", "basic"} ``` -------------------------------- ### GetPlayerAllSpecialisations Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Returns all specialisations for a player with their progression and unlocked recipes. ```APIDOC ## GetPlayerAllSpecialisations(source) ### Description Returns all specialisations for a player with their progression and unlocked recipes. ``` -------------------------------- ### GetNearbyCraftingStation Client Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Checks if the player is near a crafting station and returns the station data via a callback. ```lua exports['murphy_craft']:GetNearbyCraftingStation(function(station) if station then print("Near station: " .. station.name) else print("No station nearby") end end) ``` -------------------------------- ### UnlockPlayerRecipe Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Unlocks a specific recipe for a player. ```lua local success = exports['murphy_craft']:UnlockPlayerRecipe(source, 'docteur', 'node1') ``` -------------------------------- ### Configure hideResources property Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/hidden-recipes-system Use hideResources to keep a recipe visible while masking ingredient names and quantities. ```lua { name = "Mysterious Potion", hideResources = true, ressources = { { name = "Rare Herb", neededQuantity = 3 }, { name = "Pure Water", neededQuantity = 1 } } } ``` -------------------------------- ### GetSpecialisationState() Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Retrieves the complete state of all player specialisations. ```APIDOC ## GetSpecialisationState() ### Description Returns the complete state of player specialisations, including selected status, points, and XP. ``` -------------------------------- ### GetSpecialisationXP(specialisationId) Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Returns the player's current XP for a specific specialisation. ```APIDOC ## GetSpecialisationXP(specialisationId) ### Description Returns the player's XP for a specialisation. ### Parameters - **specialisationId** (string) - Required - The ID of the specialisation. ``` -------------------------------- ### AddPlayerSpecialisationXP(source, specialisationId, amount) Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Adds XP to a player's specialisation. ```APIDOC ## AddPlayerSpecialisationXP(source, specialisationId, amount) ### Description Adds a specified amount of XP to a player's specialisation. ### Parameters - **source** (number) - The player source ID. - **specialisationId** (string) - The ID of the specialisation. - **amount** (number) - The amount of XP to add. ``` -------------------------------- ### GetNearbyCraftingStation(callback) Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Checks if the player is near a crafting station and returns the station data via a callback. ```APIDOC ## GetNearbyCraftingStation(callback) ### Description Checks if the player is near a station. ### Parameters - **callback** (function) - Required - Function to execute with the station data. ``` -------------------------------- ### AddPlayerSpecialisationXP Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Adds a specified amount of XP to a player's specialisation. ```lua local success = exports['murphy_craft']:AddPlayerSpecialisationXP(source, 'docteur', 50) ``` -------------------------------- ### ForceSaveCraftData() Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Forces a save of all crafting data. ```APIDOC ## ForceSaveCraftData() ### Description Triggers an immediate save of all crafting data to the database. ``` -------------------------------- ### Display progression in a menu Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Retrieve local specialization progress using GetLocalSpecialisationProgress to display level, XP, and available points in a UI menu. ```lua -- Client local function showProgressMenu() local progress = exports['murphy_craft']:GetLocalSpecialisationProgress('docteur') local text = string.format( "Doctor - Level %d\nXP: %d/%d\nAvailable points: %d", progress.level, progress.xp, progress.totalXPForNextLevel or "MAX", progress.availablePoints ) -- Display in your menu system end ``` -------------------------------- ### Define a Minimal Category Template Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/recipes Use this Lua structure to group recipes under a specific category ID. ```lua Craft["category_id"] = { name = "Category Name", recipes = { -- Add recipes here } } ``` -------------------------------- ### GetPlayerSpecialisationXP Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Returns the XP value for a player in a specific specialisation. ```lua local xp = exports['murphy_craft']:GetPlayerSpecialisationXP(source, 'docteur') ``` -------------------------------- ### Define Basic Craft Category Structure Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/recipes The template for creating a new craft category using the Craft table. ```lua Craft["category_id"] = { name = "Category Display Name", recipes = { -- Recipes go here } } ``` -------------------------------- ### LockPlayerRecipe(source, category, recipeId) Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Locks a recipe for a player. ```APIDOC ## LockPlayerRecipe(source, category, recipeId) ### Description Locks a specific recipe for a player. ### Parameters - **source** (number) - The player source ID. - **category** (string) - The recipe category. - **recipeId** (string) - The ID of the recipe. ``` -------------------------------- ### Combine hideUntilCraftable and hideResources Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/hidden-recipes-system Apply both properties to create a progressive effect where a recipe is hidden until craftable, and remains mysterious even after discovery. ```lua { name = "Sage's Elixir", hideUntilCraftable = true, -- Invisible until all materials obtained hideResources = true, -- Once visible, resources remain hidden ressources = { { name = "Secret Ingredient", neededQuantity = 2 } } } ``` -------------------------------- ### GetAllActiveStations Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Returns all currently active crafting stations. ```lua local stations = exports['murphy_craft']:GetAllActiveStations() ``` -------------------------------- ### GetUnlockedRecipes Client Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Returns a list of all recipes currently unlocked by the player. ```lua local recipes = exports['murphy_craft']:GetUnlockedRecipes() --[[ Returns: { ["docteur"] = { ["root"] = true, ["node1"] = true, ["node2"] = true }, ... } ]] ``` -------------------------------- ### LockPlayerRecipe Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Locks a specific recipe for a player. ```lua local success = exports['murphy_craft']:LockPlayerRecipe(source, 'docteur', 'node1') ``` -------------------------------- ### GetSpecialisationPoints Client Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Returns the number of available points for a specific specialisation. ```lua local points = exports['murphy_craft']:GetSpecialisationPoints('docteur') -- Returns: 3 ``` -------------------------------- ### Event Listener murphy_craft:OnPointsAdded Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Reacts when points are added to a specialisation. ```lua AddEventHandler('murphy_craft:OnPointsAdded', function(specialisationId, amount, newAvailable) print("+" .. amount .. " points for " .. specialisationId) print("Available points: " .. newAvailable) end) ``` -------------------------------- ### ForceSaveCraftData Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Forces the system to save all crafting data. ```lua exports['murphy_craft']:ForceSaveCraftData() ``` -------------------------------- ### Configure hideUntilCraftable property Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/hidden-recipes-system Use hideUntilCraftable to keep a recipe hidden from the list until the player possesses all required materials. ```lua { name = "Legendary Recipe", hideUntilCraftable = true, ressources = { { name = "Dragon Bone", neededQuantity = 1 }, { name = "Star Dust", neededQuantity = 5 } } } ``` -------------------------------- ### Export GetPlayerSpecialisationProgress Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Returns complete progression information for a player's specialisation. ```lua local progress = exports['murphy_craft']:GetPlayerSpecialisationProgress(source, 'docteur') --[[ Returns: { xp = 150, level = 3, xpForNextLevel = 50, -- XP remaining for next level totalXPForNextLevel = 200, -- Total XP required for next level totalPoints = 5, availablePoints = 3, isMaxLevel = false } ]] ``` -------------------------------- ### GetAllActiveStations() Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Retrieves all currently active crafting stations. ```APIDOC ## GetAllActiveStations() ### Description Returns a list of all active stations in the system. ``` -------------------------------- ### GetPlayerCraftData Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Retrieves all crafting data for a specific player source. ```lua local data = exports['murphy_craft']:GetPlayerCraftData(source) --[[ Returns: { spestate = { ... }, unlocked_recipes = { ... } } ]] ``` -------------------------------- ### Define a Crafting Resource Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/recipes Defines the required fields for an entry in the resources array, including the UI name, quantity, and inventory item identifier. ```lua { name = "Display Name", -- Name shown in UI neededQuantity = 5, -- Amount required item = "item_name" -- Item identifier in inventory } ``` -------------------------------- ### GetNearbyCraftingCategories() Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Returns a list of crafting categories accessible at the player's current location. ```APIDOC ## GetNearbyCraftingCategories() ### Description Returns accessible categories nearby. ``` -------------------------------- ### Configure Butcher Table Prop Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/crafting-props-system Defines a butcher table prop for food processing with a 10m search radius and 1.5m interaction distance. ```lua { name = "Butcher Table", prop = "p_table29x", cat = { "food" }, searchRadius = 10.0, interactionRadius = 1.5, } ``` -------------------------------- ### HasRecipeUnlocked Client Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Checks if a specific recipe within a category is unlocked. ```lua local unlocked = exports['murphy_craft']:HasRecipeUnlocked('docteur', 'node1') -- Returns: true/false ``` -------------------------------- ### GetNearbyCraftingProps and GetNearbyCraftingCategories exports Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/crafting-props-system Use these export functions to retrieve a list of nearby interactive props or all available crafting categories including tables and props. ```lua -- Get nearby props player can interact with local props = exports['murphy_craft']:GetNearbyCraftingProps() -- Returns: array of prop configs player is near -- Get all nearby categories (includes tables, props, and basics) local categories = exports['murphy_craft']:GetNearbyCraftingCategories() -- Returns: array of category names ``` -------------------------------- ### Check level before an action Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Verify a player's specialization level using GetPlayerSpecialisationLevel before allowing them to perform an advanced action. ```lua -- Server RegisterNetEvent('myScript:doAdvancedAction', function() local source = source local level = exports['murphy_craft']:GetPlayerSpecialisationLevel(source, 'bricoleur') if level >= 5 then -- Allow advanced action TriggerClientEvent('myScript:actionAllowed', source) else TriggerClientEvent('myScript:actionDenied', source, 5 - level) end end) ``` -------------------------------- ### Give XP when player harvests Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Use this server-side event to grant experience points to players based on the type of resource harvested. ```lua -- In a harvesting script (server) RegisterNetEvent('harvest:onHarvest', function(resourceType) local source = source if resourceType == 'herbs' then TriggerEvent('murphy_craft:AddXP', source, 'docteur', 5) elseif resourceType == 'ore' then TriggerEvent('murphy_craft:AddXP', source, 'bricoleur', 10) end end) ``` -------------------------------- ### Configure Server-Side Locale in shared/config.lua Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/translation-system Set the default language for the interface. Options include 'fr' and 'en'. ```lua Config.Locale = "fr" -- Options: "fr", "en" ``` -------------------------------- ### Define a Crafting Table in Config.CraftingTables Source: https://docs.murphy-workshop.com/murphy-s-craft/crafting/crafting-tables-configuration-guide The basic structure for a crafting table entry, including location coordinates, access radius, and optional map blip settings. ```lua Config.CraftingTables = { { name = "My Crafting Table", cat = { "category1", "category2" }, coords = vector3(x, y, z), radius = 5.0, blip = { hash = "blip_hash_name", modifier = "BLIP_MODIFIER_NAME", -- Optional displaydistance = 50.0, scale = 0.3, }, }, } ``` -------------------------------- ### Enable Debug Mode in config.lua Source: https://docs.murphy-workshop.com/murphy-s-craft/reference/troubleshooting Modify config.lua to enable detailed development logging and diagnostic information. ```lua Config.DevMode = true -- Enables detailed development logging Config.Debug = true -- Prints additional diagnostic information ``` -------------------------------- ### AddPlayerSpecialisationPoints Export Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/exports Adds specialisation points to a player. ```lua local success = exports['murphy_craft']:AddPlayerSpecialisationPoints(source, 'bricoleur', 2) ``` -------------------------------- ### Change Language with T.setLanguage Source: https://docs.murphy-workshop.com/murphy-s-craft/advanced/translation-system Switch the current interface language dynamically. ```javascript T.setLanguage('en'); // Switch to English ```