I am looking for a way to make custom Equipment (stuff that doesn't appear as a weapon in the player's inventory, such as the radar) for TTT, and to show it on the shop menu.
I have looked at some of the internal structures, and I have found the following;
[b]shared.lua[/b]
[code]-- Weapons and items that come with TTT. Weapons that are not in this list will
-- get a little marker on their icon if they're buyable, showing they are custom
-- and unique to the server.
DefaultEquipment = {
-- traitor-buyable by default
[ROLE_TRAITOR] = {
"weapon_ttt_c4",
"weapon_ttt_flaregun",
"weapon_ttt_knife",
"weapon_ttt_phammer",
"weapon_ttt_push",
"weapon_ttt_radio",
"weapon_ttt_sipistol",
"weapon_ttt_teleport",
"weapon_ttt_decoy",
EQUIP_ARMOR,
EQUIP_RADAR,
EQUIP_DISGUISE
},
-- detective-buyable by default
[ROLE_DETECTIVE] = {
"weapon_ttt_binoculars",
"weapon_ttt_defuser",
"weapon_ttt_health_station",
"weapon_ttt_stungun",
"weapon_ttt_cse",
"weapon_ttt_teleport",
EQUIP_ARMOR,
EQUIP_RADAR
},
-- non-buyable
[ROLE_NONE] = {
"weapon_ttt_confgrenade",
"weapon_ttt_m16",
"weapon_ttt_smokegrenade",
"weapon_ttt_unarmed",
"weapon_ttt_wtester",
"weapon_tttbase",
"weapon_tttbasegrenade",
"weapon_zm_carry",
"weapon_zm_improvised",
"weapon_zm_mac10",
"weapon_zm_molotov",
"weapon_zm_pistol",
"weapon_zm_revolver",
"weapon_zm_rifle",
"weapon_zm_shotgun",
"weapon_zm_sledge",
"weapon_ttt_glock"
}
};[/code]
[b]equip_items_shd.lua[/b]
[code]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"
}
};
};[/code]
I'd like to be able to add equipment as an addon, without modifying the core TTT files. I'm not sure how to go about doing this, so any pointers would be great.
Since EquipmentItems is global you can just use table.insert
[CODE]
local tbl = {
id = EQUIP_INVISIBILITY,
type = "item_active",
material = "VGUI/ttt/invisibility",
name = "invisibility",
desc = "item_invis_desc"
}
if enabled_traitor then
table.insert(EquipmentItems[ROLE_TRAITOR], tbl)
end
if enabled_detective then
table.insert(EquipmentItems[ROLE_DETECTIVE], tbl)
end[/CODE]
P.S. He obviously would be happy to get any example :P
snip
Ninja'd.
[QUOTE=Total Crash;43630551][CODE]
local tbl = {
id = EQUIP_INVISIBILITY,
type = "item_active",
material = "VGUI/ttt/invisibility",
name = "invisibility",
desc = "item_invis_desc"
}
if enabled_traitor then
table.insert(EquipmentItems[ROLE_TRAITOR], tbl)
end
if enabled_detective then
table.insert(EquipmentItems[ROLE_DETECTIVE], tbl)
end[/CODE]
P.S. He obviously would be happy to get any example :P[/QUOTE]
I tried this earlier using my own code, but nothing new was added to the menu. I'll try your code now.
[editline]22nd January 2014[/editline]
Turns out it works, but I have to reload the addon after the gamemode has started. Any ideas on making my addon load after TTT? Also, more importantly, how do I get code to run on the users that are currently using the item? Would I use a Think hook, and just check whether the player has the equipment, and if so, run some code on them?
[CODE] hook.Add("Initialize", "InitializeCustomTTTItems", function() -- delay until gamemode is loaded [/CODE]
There you go, this will make it autostart once the gamemode loads.
Sorry, you need to Log In to post a reply to this thread.