Help with adding SWEP to Detective/Traitor Credit shop in TTT
2 replies, posted
I am getting this error when I try to open up the Detective shop after buying a custom weapon in it.
In the SWEP for the weapon, I put the following to add it to the shop:
[CODE]
table.insert(EquipmentItems[ROLE_DETECTIVE],
{ id = EQUIP_TESLA,
type = "item_active",
material = "vgui/ttt/icon_polter",
name = "Tesla Cannon",
desc = "Left click to fire bolt of electricity that stuns target. \n Right click to recharge weapon."
})
[/CODE]
and also
[CODE]
SWEP.Kind = WEAPON_EQUIP
SWEP.CanBuy = {ROLE_DETECTIVE} -- only traitors can buy
SWEP.WeaponID = EQUIP_CANNON
[/CODE]
The weapon shows up fine in the shop, but after I buy the weapon, the following appears.
[ERROR] gamemodes/terrortown/gamemode/cl_equip.lua:199: attempt to call method 'IsEquipment' (a nil value)
1. unknown - gamemodes/terrortown/gamemode/cl_equip.lua:199
2. unknown - lua/includes/modules/concommand.lua:54
I honestly have no idea what I am doing, and I haven't been able to find a tutorial anywhere about how to add SWEPs to the D/T Credit Shop, so I've just been doing what sounds correct.
Can anyone point me in the right direction?
[editline]26th April 2015[/editline]
I reduced it to only the following;
[CODE]
if CLIENT then
SWEP.PrintName = "Tesla Cannon"
SWEP.Slot = 6
SWEP.DrawAmmo = false
SWEP.ViewModelFOV = 54
SWEP.ViewModelFlip = false
SWEP.EquipMenuData = {
type = "Weapon",
desc = "Shoots electricity that stuns target. \n\nHold right click to charge."
};
SWEP.Icon = "vgui/ttt/icon_polter"
end
SWEP.Kind = WEAPON_EQUIP
SWEP.CanBuy = {ROLE_DETECTIVE} -- only traitors can buy
SWEP.WeaponID = EQUIP_CANNON
[/CODE]
I am still getting the same error message if I try to open up the credit shop with the custom weapon equipped, however. According to the error message, "teslacannon:IsEquipment()" returns nil, even though it is indeed equipment, as far as I can tell. I cannot find the IsEquipment function, so I can't actually tell what it's looking for, so I don't know what to do. Can anyone help?
[lua]
-- Always derive from weapon_tttbase
SWEP.Base = "weapon_tttbase"
[/lua]
also the whole part with table.insert... Drop that.
What an Traitor Weapon only needs, you can see here in this basic, well commented, AK-47
[url]https://github.com/Fuzziks-TTT/ttt-weapon-collection/blob/master/gamemodes/terrortown/entities/weapons/weapon_ttt_ak47.lua[/url]
1. Dont use table.insert( equipmentitems ) for SWEPs, thats meant for stuff like armor or radar.
2. You don't need SWEP.WeaponID
3. SWEP.CanBuy is what adds it to the traitor shop
Sorry, you need to Log In to post a reply to this thread.