TTT Custom Weapons problem

I’m having a problem on my server where I have custom weapons installed, mainly m9k. I had gone though the files and converted them to ttt, I have added them to maps, everything seems to be working fine other than picking up multiple weapons, and I’m not quite sure where the problem is.
NOTE- I’m still a beginner coder, which means I’ll probably need some explanation.

Problem: I have a couple Custom M9k weapons loaded on my ttt server, and I can randomly pick up different weapons in unintentional ways, such as if I pick up a colt which is in the 2 slot it does not allow me to pick up any primarys, while I can generally pick up 2 primarys in the 3 slot. I’m confused on how/where this occurred, any guidance would be greatly appreciated. This is NOT an error, its more of an unintentional bug that is happening and I’m not quite sure what I can do to fix it.

Code I added/Replaced for each Custom Weapon-

I changed ammo and pistols to slot 1 and all primarys to slot 2
I also changed the base to weapon_tttbase


SWEP.Kind = WEAPON_HEAVY
SWEP.AutoSpawnable = true
SWEP.AmmoEnt = "item_ammo_pistol_ttt"
SWEP.InLoadoutFor = nil
SWEP.AllowDrop = true
SWEP.IsSilent = false
SWEP.NoSights = false

Example-


-- Variables that are used on both client and server
SWEP.Gun = ("m9k_g36") -- must be the name of your swep but NO CAPITALS!
if (GetConVar(SWEP.Gun.."_allowed")) == nil then 
	if (GetConVar("DebugM9K"):GetBool()) then	print("Blacklist Convar for "..SWEP.Gun.." is missing! You may have hit the lua limit, or incorrectly modified the autorun file!")	end
elseif not (GetConVar(SWEP.Gun.."_allowed"):GetBool()) then SWEP.Base = "weapon_tttbase" SWEP.PrintName = SWEP.Gun return end
SWEP.Category				= "M9K Assault Rifles"
SWEP.MuzzleAttachment			= "1" 	-- Should be "1" for CSS models or "muzzle" for hl2 models
SWEP.ShellEjectAttachment			= "2" 	-- Should be "2" for CSS models or "1" for hl2 models
SWEP.PrintName				= "G36"		-- Weapon name (Shown on HUD)	
SWEP.Slot				= 2				-- Slot in the weapon selection menu
SWEP.SlotPos				= 24			-- Position in the slot
SWEP.DrawAmmo				= true		-- Should draw the default HL2 ammo counter
SWEP.DrawWeaponInfoBox			= false		-- Should draw the weapon info box
SWEP.BounceWeaponIcon   		= 	false	-- Should the weapon icon bounce?
SWEP.DrawCrosshair			= true		-- set false if you want no crosshair
SWEP.Weight				= 30			-- rank relative ot other weapons. bigger is better
SWEP.AutoSwitchTo			= true		-- Auto switch to if we pick it up
SWEP.AutoSwitchFrom			= true		-- Auto switch from if you pick up a better weapon
SWEP.HoldType 				= "ar2"		-- how others view you carrying the weapon
-- normal melee melee2 fist knife smg ar2 pistol rpg physgun grenade shotgun crossbow slam passive 
-- you're mostly going to use ar2, smg, shotgun or pistol. rpg and crossbow make for good sniper rifles

SWEP.ViewModelFOV			= 70
SWEP.ViewModelFlip			= true
SWEP.ViewModel				= "models/weapons/v_rif_g362.mdl"	-- Weapon view model
SWEP.WorldModel				= "models/weapons/w_hk_g36c.mdl"	-- Weapon world model
SWEP.ShowWorldModel			= true
SWEP.Base				= "weapon_tttbase"
SWEP.Spawnable				= true
SWEP.AdminSpawnable			= true
SWEP.FiresUnderwater = true

SWEP.Primary.Sound			= Sound("G36.single")		-- Script that calls the primary fire sound
SWEP.Primary.RPM			= 750			-- This is in Rounds Per Minute
SWEP.Primary.ClipSize			= 20		-- Size of a clip
SWEP.Primary.DefaultClip		= 20		-- Bullets you start with
SWEP.Primary.KickUp				= 0.3		-- Maximum up recoil (rise)
SWEP.Primary.KickDown			= 0.3		-- Maximum down recoil (skeet)
SWEP.Primary.KickHorizontal		= 0.3		-- Maximum up recoil (stock)
SWEP.Primary.Automatic			= true		-- Automatic = true; Semi Auto = false
SWEP.Primary.Ammo			= "pistol"			-- pistol, 357, smg1, ar2, buckshot, slam, SniperPenetratedRound, AirboatGun
-- Pistol, buckshot, and slam always ricochet. Use AirboatGun for a light metal peircing shotgun pellets

SWEP.SelectiveFire		= true

SWEP.Secondary.IronFOV			= 55		-- How much you 'zoom' in. Less is more! 	

SWEP.data 				= {}				--The starting firemode
SWEP.data.ironsights			= 1

SWEP.Primary.NumShots	= 1		-- How many bullets to shoot per trigger pull
SWEP.Primary.Damage		= 30	-- Base damage per bullet
SWEP.Primary.Spread		= .02	-- Define from-the-hip accuracy 1 is terrible, .0001 is exact)
SWEP.Primary.IronAccuracy = .01 -- Ironsight accuracy, should be the same for shotguns

-- Enter iron sight info and bone mod info below
SWEP.IronSightsPos = Vector(2.865, -0.857, 1.06)
SWEP.IronSightsAng = Vector(0, 0, 0)
SWEP.SightsPos = Vector(2.865, -0.857, 1.06)
SWEP.SightsAng = Vector(0, 0, 0)
SWEP.RunSightsPos = Vector(-6, -2.571, -0.04)
SWEP.RunSightsAng = Vector(-11, -43, 0)

if GetConVar("M9KDefaultClip") == nil then
	print("M9KDefaultClip is missing! You may have hit the lua limit!")
else
	if GetConVar("M9KDefaultClip"):GetFloat() >= 0 then
	SWEP.Primary.DefaultClip = SWEP.Primary.DefaultClip * GetConVar("M9KDefaultClip"):GetFloat()
	PainMulti = GetConVar("M9KDefaultClip"):GetFloat()
	else return end
end

SWEP.Kind = WEAPON_HEAVY
SWEP.AutoSpawnable = true
SWEP.AmmoEnt = "item_ammo_pistol_ttt"
SWEP.InLoadoutFor = nil
SWEP.AllowDrop = true
SWEP.IsSilent = false
SWEP.NoSights = false

Not sure what the issue is, but here’s the code in a more readable format (use


 tags in the future!)


– Variables that are used on both client and server
SWEP.Gun = (“m9k_g36”) – must be the name of your swep but NO CAPITALS!

if (GetConVar(SWEP.Gun…"_allowed")) == nil then
if (GetConVar(“DebugM9K”):GetBool()) then
print(“Blacklist Convar for “…SWEP.Gun…” is missing! You may have hit the lua limit, or incorrectly modified the autorun file!”)
end
elseif not (GetConVar(SWEP.Gun…"_allowed"):GetBool()) then
SWEP.Base = “weapon_tttbase”
SWEP.PrintName = SWEP.Gun
return
end

SWEP.Category = “M9K Assault Rifles”
SWEP.MuzzleAttachment = “1” – Should be “1” for CSS models or “muzzle” for hl2 models
SWEP.ShellEjectAttachment = “2” – Should be “2” for CSS models or “1” for hl2 models
SWEP.PrintName = “G36” – Weapon name (Shown on HUD)
SWEP.Slot = 2 – Slot in the weapon selection menu
SWEP.SlotPos = 24 – Position in the slot
SWEP.DrawAmmo = true – Should draw the default HL2 ammo counter
SWEP.DrawWeaponInfoBox = false – Should draw the weapon info box
SWEP.BounceWeaponIcon = false – Should the weapon icon bounce?
SWEP.DrawCrosshair = true – set false if you want no crosshair
SWEP.Weight = 30 – rank relative ot other weapons. bigger is better
SWEP.AutoSwitchTo = true – Auto switch to if we pick it up
SWEP.AutoSwitchFrom = true – Auto switch from if you pick up a better weapon
SWEP.HoldType = “ar2” – how others view you carrying the weapon
– normal melee melee2 fist knife smg ar2 pistol rpg physgun grenade shotgun crossbow slam passive
– you’re mostly going to use ar2, smg, shotgun or pistol. rpg and crossbow make for good sniper rifles

SWEP.ViewModelFOV = 70
SWEP.ViewModelFlip = true
SWEP.ViewModel = “models/weapons/v_rif_g362.mdl” – Weapon view model
SWEP.WorldModel = “models/weapons/w_hk_g36c.mdl” – Weapon world model
SWEP.ShowWorldModel = true
SWEP.Base = “weapon_tttbase”
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.FiresUnderwater = true

SWEP.Primary.Sound = Sound(“G36.single”) – Script that calls the primary fire sound
SWEP.Primary.RPM = 750 – This is in Rounds Per Minute
SWEP.Primary.ClipSize = 20 – Size of a clip
SWEP.Primary.DefaultClip = 20 – Bullets you start with
SWEP.Primary.KickUp = 0.3 – Maximum up recoil (rise)
SWEP.Primary.KickDown = 0.3 – Maximum down recoil (skeet)
SWEP.Primary.KickHorizontal = 0.3 – Maximum up recoil (stock)
SWEP.Primary.Automatic = true – Automatic = true; Semi Auto = false
SWEP.Primary.Ammo = “pistol” – pistol, 357, smg1, ar2, buckshot, slam, SniperPenetratedRound, AirboatGun
– Pistol, buckshot, and slam always ricochet. Use AirboatGun for a light metal peircing shotgun pellets

SWEP.SelectiveFire = true

SWEP.Secondary.IronFOV = 55 – How much you ‘zoom’ in. Less is more!

SWEP.data = {} --The starting firemode
SWEP.data.ironsights = 1

SWEP.Primary.NumShots = 1 – How many bullets to shoot per trigger pull
SWEP.Primary.Damage = 30 – Base damage per bullet
SWEP.Primary.Spread = .02 – Define from-the-hip accuracy 1 is terrible, .0001 is exact)
SWEP.Primary.IronAccuracy = .01 – Ironsight accuracy, should be the same for shotguns

– Enter iron sight info and bone mod info below
SWEP.IronSightsPos = Vector(2.865, -0.857, 1.06)
SWEP.IronSightsAng = Vector(0, 0, 0)
SWEP.SightsPos = Vector(2.865, -0.857, 1.06)
SWEP.SightsAng = Vector(0, 0, 0)
SWEP.RunSightsPos = Vector(-6, -2.571, -0.04)
SWEP.RunSightsAng = Vector(-11, -43, 0)

if GetConVar(“M9KDefaultClip”) == nil then
print(“M9KDefaultClip is missing! You may have hit the lua limit!”)
else
if GetConVar(“M9KDefaultClip”):GetFloat() >= 0 then
SWEP.Primary.DefaultClip = SWEP.Primary.DefaultClip * GetConVar(“M9KDefaultClip”):GetFloat()
PainMulti = GetConVar(“M9KDefaultClip”):GetFloat()
else
return
end
end

SWEP.Kind = WEAPON_HEAVY
SWEP.AutoSpawnable = true
SWEP.AmmoEnt = “item_ammo_pistol_ttt”
SWEP.InLoadoutFor = nil
SWEP.AllowDrop = true
SWEP.IsSilent = false
SWEP.NoSights = false




[editline]7th July 2014[/editline]

I think I see the problem actually. Looks like you're setting the Kind as WEAPON_HEAVY for SLOT 2, when it should be WEAPON_PISTOL.

Add this in there
SWEP.Slot = 2

The slots in ttt are goofy so you add 1 to whatever slot number you set it. So setting SWEP.Slot = 2 would make the gun show up in slot 3.

Making it SWEP.Slot = 7 will make the gun show up in slot 8 and so on.

That’s already in the script at the top


SWEP.Slot	 = 2	 -- Slot in the weapon selection menu

Yes I already had the G36(primary assault rifle) at slot 2 which made it show up in slot 3.

What I figured out was doing this-


SWEP.Category = "Secondary" 

and then I also did that for primary made it so I can’t pick up multiple but the same problem consists where the pistols are in slot 2 in game primarys in slot 3 ingame aswell as having weapon_pistol and weapon_heavy properly done, the problem now is that pistols even though they’re in slot 2(ingame) and setup as a pistol they still seem to count as a primary

SWEP.Category = “Secondary” does nothing in ttt.

Make a file called weapon_ttt_g36.lua and put it into garrysmod/gamemodes/terrortown/entities/weapons/
Then put this code in there and it should spawn at the random spawn points on maps.
[lua]AddCSLuaFile()

SWEP.HoldType = “ar2”

if CLIENT then
SWEP.PrintName = “G36”
SWEP.Slot = 2

SWEP.Icon = “vgui/ttt/g36” --MAKE AN ICON FOR THE GUN
end

SWEP.Base = “weapon_tttbase”
SWEP.Spawnable = true

SWEP.Kind = WEAPON_HEAVY

SWEP.Primary.Delay = 0.13
SWEP.Primary.Recoil = 1.1
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = “smg1”
SWEP.Primary.Damage = 30
SWEP.Primary.Cone = 0.025
SWEP.Primary.ClipSize = 20
SWEP.Primary.ClipMax = 60
SWEP.Primary.DefaultClip = 20
SWEP.AutoSpawnable = true
SWEP.AmmoEnt = “item_ammo_smg1_ttt”

SWEP.UseHands = true
SWEP.ViewModelFlip = true
SWEP.ViewModelFOV = 70
SWEP.ViewModel = “models/weapons/v_rif_g362.mdl”
SWEP.WorldModel = “models/weapons/w_hk_g36c.mdl”

SWEP.Primary.Sound = Sound(“G36.single”)

SWEP.IronSightsPos = Vector(2.865, -0.857, 1.06)
SWEP.IronSightsAng = Vector(0, 0, 0)[/lua]
Typed from my phone so excuse an fk ups

Of course configure the stuff like damage and recoil as much as you want and don’t forget to make an icon for the gun.

Seems like it’s working, thanks for the help, so it seems all I have to do is make a TTT version of the code. Case closed, once again thanks for the help.