The table is generated in garrysmod\gamemodes\terrortown\gamemode\gamemode\equip_items_shd.lua
-- This table is used by the client to show items in the equipment menu, and by
-- the server to check if a certain role is allowed to buy a certain item.
-- If you have custom items you want to add, consider using a separate lua
-- script that uses table.insert to add an entry to this table. This method
-- means you won't have to add your code back in after every TTT update. Just
-- make sure the script is also run on the client.
--
-- For example:
-- table.insert(EquipmentItems[ROLE_DETECTIVE], { id = EQUIP_ARMOR, ... })
--
-- Note that for existing items you can just do:
-- table.insert(EquipmentItems[ROLE_DETECTIVE], GetEquipmentItem(ROLE_TRAITOR, EQUIP_ARMOR))
-- Special equipment bitflags. Every unique piece of equipment needs its own
-- id. The number should increase by a factor of two for every item (ie. ids
-- should be powers of two). So if you were to add five more pieces of
-- equipment, they should have the following ids: 8, 16, 32, 64, 128...
EQUIP_NONE = 0
EQUIP_ARMOR = 1
EQUIP_RADAR = 2
EQUIP_DISGUISE = 4
-- Icon doesn't have to be in this dir, but all default ones are in here
local mat_dir = "VGUI/ttt/"
-- Stick to around 35 characters per description line, and add a "\n" where you
-- want a new line to start.
EquipmentItems = {
[ROLE_DETECTIVE] = {
-- body armor
{ id = EQUIP_ARMOR,
loadout = true, -- default equipment for detectives
type = "item_passive",
material = mat_dir .. "icon_armor",
name = "item_armor",
desc = "item_armor_desc"
},
-- radar
{ id = EQUIP_RADAR,
type = "item_active",
material = mat_dir .. "icon_radar",
name = "item_radar",
desc = "item_radar_desc"
}
-- The default TTT equipment uses the language system to allow
-- translation. Below is an example of how the type, name and desc fields
-- would look with explicit non-localized text (which is probably what you
-- want when modding).
-- { id = EQUIP_ARMOR,
-- loadout = true, -- default equipment for detectives
-- type = "Passive effect item",
-- material = mat_dir .. "icon_armor",
-- name = "Body Armor",
-- desc = "Reduces bullet damage by 30% when\nyou get hit."
-- },
};
[ROLE_TRAITOR] = {
-- body armor
{ id = EQUIP_ARMOR,
type = "item_passive",
material = mat_dir .. "icon_armor",
name = "item_armor",
desc = "item_armor_desc"
},
-- radar
{ id = EQUIP_RADAR,
type = "item_active",
material = mat_dir .. "icon_radar",
name = "item_radar",
desc = "item_radar_desc"
},
-- disguiser
{ id = EQUIP_DISGUISE,
type = "item_active",
material = mat_dir .. "icon_disguise",
name = "item_disg",
desc = "item_disg_desc"
}
};
};
-- Search if an item is in the equipment table of a given role, and return it if
-- it exists, else return nil.
function GetEquipmentItem(role, id)
local tbl = EquipmentItems[role]
if not tbl then return end
for k, v in pairs(tbl) do
if v and v.id == id then
return v
end
end
end
I'm creating the command in garrysmod\addons\ULX\lua\modules\sh\ttt_fun.lua
--[Helper Functions]---------------------------------------------------------------------------
function GetEquipment()
local item_table
for role,_ in pairs(EquipmentItems) do
for _, item in pairs(EquipmentItems[])
EquipmentItems
end
local items = MergeTable(EquipmentItems[ROLE_TRAITOR], EquipmentItems[ROLE_DETECTIVE])
if type(items_table) == "table" then
for _, item in pairs(items_table) do
if item.id then
table.insert(ulx.get_equipment, item.id)
end
end
end
return tbl
end
--[End]----------------------------------------------------------------------------------------
--[Ulx Completes]------------------------------------------------------------------------------
ulx.get_equipment = {}
function GetEquipment()
table.Empty( ulx.get_equipment )
local items = MergeTable(EquipmentItems[ROLE_TRAITOR], EquipmentItems[ROLE_DETECTIVE])
if type(items_table) == "table" then
for _, item in pairs(items_table) do
if item.id then
table.insert(ulx.get_equipment, item.id)
end
end
end
end
hook.Add( ULib.HOOK_UCLCHANGED, "ULXGetEquipment", GetEquipment )
GetEquipment()
--[End]----------------------------------------------------------------------------------------
--[Toggle spectator]---------------------------------------------------------------------------
--[[ulx.spec][Forces <target(s)> to and from spectator.]
@param {[PlayerObject]} calling_ply [The player who used the command.]
@param {[PlayerObject]} target_plys [The player(s) who will have the effects of the command applied to them.]
--]]
function ulx.GiveEquipment( calling_ply, target_plys, equipment )
if not GetConVarString("gamemode") == "terrortown" then ULib.tsayError( calling_ply, gamemode_error, true ) else
for i=1, #target_plys do
target_plys[ i ]:GiveEquipmentItem(equipment)
end
ulx.fancyLogAdmin( calling_ply, "#A gave #T " .. equipment, target_plys)
end
end
local armor = ulx.command( CATEGORY_NAME, "ulx Give Equipment", ulx.GiveEquipment )
GiveEquipment:addParam{ type=ULib.cmds.PlayersArg }
GiveEquipment:addParam{ type=ULib.cmds.StringArg, completes=ulx.get_equipment, hint="Equipment", error="Invalid equpiment:\"%s\" specified", ULib.cmds.restrictToCompletes }
GiveEquipment:defaultAccess( ULib.ACCESS_SUPERADMIN )
GiveEquipment:help( "Give <target(s)> specified equpiment." )
--[End]----------------------------------------------------------------------------------------
I can sort out the rest, i know how the completes work from the examples included in other ulx commands, it's mainly just referencing the table. Also thanks for dedicating so much time to my cause, i'm not sure if i would do the same although i would hope that i would. The code is quite broken and mismatched, i normally fix the code as i go along but i can't work out what's wrong if i can't get the table.