Crash when buying custom TTT weapon

Hi there,

I’m trying to make a detective-only TTT weapon based on the shotgun that heals the user based on the amount of damage dealt. But when I try to buy it, the server crashes. It doesn’t just show a lua error, it actually freezes to the point that I have to kill the process with task manager.

I put the code in a pastebin to keep the post from filling the screen.

Does anyone know why this happens or how I could fix this?

Alright, just a couple observable tidbits:

  1. EquipMenuData should only be ran on the client

  2. You should probably put the code that changes the description of the weapon as the definition itself with the values above it, like so:

[lua]SWEP.EquipMenuData = {
if SWEP.ClipPercent < 1 then
addesc = "
-"…tostring(100-100SWEP.ClipPercent)…"% clip size"
end
if SWEP.DamagePercent < 1 then
addesc = "
-"…tostring(100-100
SWEP.DamagePercent)…"% damage dealt"
end
if SWEP.ClipPercent > 1 then
addesc = "
+"…tostring(100-100SWEP.ClipPercent)…"% clip size"
end
if SWEP.DamagePercent > 1 then
addesc = "
+"…tostring(100-100
SWEP.DamagePercent)…"% damage dealt"
end
type = “item_weapon”,
desc = “Heals user on hit.” … addesc
};[/lua]

Or something like that, but it does work they way it is now so if you don’t want to fuck with it don’t

  1. Don’t use an actual weapon as the base. Use weapon_tttbase and copy over any code you need from that weapon (this ended up fixing your problem, so be careful as to what code you borrow from weapon_zm_shotgun)