I made this resource a while ago, some dutch servers were using it so I thought I might as well release it to the public. This resource allows you to craft certain items by playing a game (https://codepen.io/marctannous/pen/qONmob) and also has a crafting points system (which you can edit).
It also has a threshold system with the point system where you have to be a certain points (all of this you can edit in the config) you can also set it to 0 to totally remove it with items.
Some clarification on the config:
You can edit the config very easy to make it create items that you want to, you can remove the items I left in there because it was made for someone else first
["item_name"] = { // This is the name of the item you want to craft (not the label)
label = "Item Label", // The label of the item you want to craft
needs = { // Here you can put certain items you need before you can start crafting, you can add as many as you want to.
["item_to_use_name"] = {label = "Item Use Label", count = 1}, // the key of the table is the item name (not label)
["item_to_use_name2"] = {label = "Item Use Label", count = 2},
},
threshold = 0, // Here you can set a certain threshold where a player has to have a certain amount of points to craft this item, you can leave it 0 when you don't want to use the point system.
},
Support
I don’t really wanna deal with support privately anymore, I will respond on the FiveM forums sometimes but not on discord anymore.
Citizen.CreateThread(function()
while true do
Citizen.Wait(7)
if ESX ~= nil and Crafting.Locations ~= nil then
local pos = GetEntityCoords(GetPlayerPed(-1), true)
for i=1, #Crafting.Locations, 1 do
if GetDistanceBetweenCoords(pos.x, pos.y, pos.z, Crafting.Locations[i].x, Crafting.Locations[i].y, Crafting.Locations[i].z, true) < 2.5 then
DrawText3D(Crafting.Locations[i].x, Crafting.Locations[i].y, Crafting.Locations[i].z, "[~g~E~w~] to craft item")
if IsControlJustReleased(0, Keys["E"]) then
OpenCraftMenu()
end
end
end
end
end
end)
DrawText3D = function(x, y, z, text)
local onScreen,x,y = World3dToScreen2d(x, y, z)
local factor = #text / 370
if onScreen then
SetTextScale(0.35, 0.35)
SetTextFont(4)
SetTextProportional(1)
SetTextColour(255, 255, 255, 215)
SetTextEntry("STRING")
SetTextCentre(1)
AddTextComponentString(text)
DrawText(x,y)
DrawRect(x,y + 0.0125, 0.015 + factor, 0.03, 41, 11, 41, 120)
end
end
There seems to be a error somewhere, when i try to craft something, it wont let me and some extended errors is appear. Seems to be something in line 65 in server.lua
Once I get home, I can send a screenshot, I mean it is working, i get the menu and stuff but when I’m about to craft it give errors in line 65 in server.lua
if xPlayer.getInventoryItem(itemname).count < v.count then
cb(false)
end
To change the position you click you can edit the window.addEventListener('click' function()). You certainly can remove that you lose items in server/main.lua you can change line 30 to if rand <= 100 then or remove the if statement as a whole