PivityGmodStore

Crafting

File location:

lua/ch_mining/shared/config/ch_mining_config_crafting.lua

Example code:

CH_Mining.Crafting["item_ak47"] = {
Name = "AK-47",
Model = "models/weapons/w_rif_ak47.mdl",
Description = "Craft a fully automatic AK-47 assult rifle.",
MineralsCost = {
["Stone"] = 2,
["Iron"] = 2,
["Diamond"] = 2,
["Rare"] = 2,
},
RequiredLevel = 1,
XPCost = 500,
XPEarn = 40,
MoneyCost = 5000,
CustomCheck = function( ply )
return not ply:HasWeapon( "weapon_ak472" )
end,
CustomCheckFailMessage = "Cannot craft because AK-47 is already equipped!",
BuyFunction = function( ply )
ply:Give( "weapon_ak472" )
end,
}

Explanation:

This is where you put the unique name of the item. It MUST be unique, but it can be anything.

CH_Mining.Crafting["item_ak47"]

Name of the item as shown in the UI.

Name = "AK-47"

Model used for the display.

Model = "models/weapons/w_rif_ak47.mdl"

Description of the item as shown on the UI.

Description = "Craft a fully automatic AK-47 assult rifle."

These are the minerals it cost to craft the item. You can add as many minerals as you wish (out of the 9 available).

MineralsCost = {
["Rare"] = 15,
["Stone"] = 22,
["Iron"] = 82,
["Amethyst"] = 52,
["Bloodstone"] = 21,
["Emerald"] = 12,
["Gold"] = 5,
["Diamond"] = 7,
["Ruby"] = 9,
},

This decides what level the player must be in order to be able to craft this.

RequiredLevel = 1,

Should it cost XP to craft an item? You can set this to 0 or remove the line entirely.

XPCost = 500,

If the player should earn XP from crafting the item? You can set to 0 or remove it entirely if not.

XPEarn = 40,

If you want you can also charge the player money for crafting. If not, just set it to 0 or remove entirely.

MoneyCost = 5000,

You can perform a custom check if you want. The CustomCheck includes the code and should return either true or false depending on if the player can craft the item or not.

The CustomCheckFailMessage will be present to the player if the CustomCheck condition fails.

If you don't know what you are doing here, just put return true

CustomCheck = function( ply )
return not ply:HasWeapon( "weapon_ak472" )
end,
CustomCheckFailMessage = "Cannot craft because AK-47 is already equipped!",

This is the buy function that is ran when the player has successfully crafted the item. This can be any custom lua that you wish.

BuyFunction = function( ply )
ply:Give( "weapon_ak472" )
end,

Can't find what you're looking for?

Contact support