PivityGmodStore

Adding/editing catalog items

It requires simple Lua knowledge to add or edit the functionality of items.

Navigate to lua/ch_adv_mayor/shared/config/catalog and open any of the files.

The below example spawns the trash dumpster entity at the mayors aim.

CH_Mayor.Catalog["item_trashcan"] = {
Name = "Trash Dumpster",
Model = "models/props_junk/TrashDumpster01a.mdl",
Description = "Purchase a trash dumpster for your city where citizens can dump various entities/items to earn themselves a reward.",
Price = 250,
CustomCheck = function( ply )
return true
end,
CustomCheckFailMessage = "",
BuyFunction = function( ply )
-- spawn dumpster entity
local tr = ply:GetEyeTrace()
local SpawnPos = tr.HitPos + tr.HitNormal * 30
local SpawnAng = ply:EyeAngles()
SpawnAng.p = 0
SpawnAng.y = SpawnAng.y + 180
local ent = ents.Create( "ch_mayor_trashcan" )
ent:SetPos( SpawnPos )
ent:SetAngles( SpawnAng )
ent:Spawn()
ent:CPPISetOwner( ply )
ent.SpawnedByMayor = true
end,
RemoveFunction = function()
end,
}

The first line defines the table entry and it's unique key. Replace item_trashcan with something unique that represents the item you are creating.

Name is the name of the item as displayed in the UI.

Model is the model used in the display.

Description is shown in the menu as well.

Price determines what it costs the mayor to buy (uses mayor vault money).

CustomCheck is a condition that you can modify to whatever you want. If the code returns true then it will allow the mayor, if the code returns false then it will not.

CustomCheckFailMessage is printed if the custom check returns false.

BuyFunction is what actually happens when the item is bought successfully. You can input any lua code here.

RemoveFunction is what happens when the mayor is demoted/leaves the server. This can also be anything.

Can't find what you're looking for?

Contact support