How to get M9K weapons to spawn in TTT using ttt_random_weapon

I am trying to get M9K guns to spawn using this code in ent_replace.lua


local hl2_weapon_replace = {
   ["weapon_smg1"] = "ttt_random_weapon",
   ["weapon_shotgun"] = "ttt_random_weapon",
   ["weapon_ar2"] = "ttt_random_weapon",
   ["weapon_357"] = "ttt_random_weapon",
   ["weapon_crossbow"] = "ttt_random_weapon",
   ["weapon_rpg"] = "ttt_random_weapon",
   ["weapon_slam"] = "item_ammo_pistol_ttt",
   ["weapon_frag"] = "ttt_random_weapon",
   ["weapon_crowbar"] = "ttt_random_weapon",
   ["weapon_ttt_m16"] = "ttt_random_weapon",
	["weapon_ttt_galil"] = "ttt_random_weapon",
	["weapon_ttt_confgrenade"] = "ttt_random_weapon",
	["weapon_zm_shotgun"] = "ttt_random_weapon",
	["weapon_ttt_pistol"] = "ttt_random_weapon",
	["weapon_ttt_mp5"] = "ttt_random_weapon",
	["weapon_ttt_p228"] = "ttt_random_weapon",
	["weapon_zm_rifle"] = "ttt_random_weapon",
	["weapon_ttt_g3"] = "ttt_random_weapon",
	["weapon_zm_revolver"] = "ttt_random_weapon",
	["weapon_zm_pistol"] = "ttt_random_weapon",
	["weapon_ttt_aug"] = "ttt_random_weapon",
	["weapon_ttt_smg"] = "ttt_random_weapon",
	["weapon_zm_mac10"] = "ttt_random_weapon",
	["weapon_ttt_smokegrenade"] = "ttt_random_weapon",
	["weapon_ttt_pump"] = "ttt_random_weapon",
	["weapon_zm_molotov"] = "ttt_random_weapon",
	["weapon_ttt_glock"] = "ttt_random_weapon",
	["weapon_ttt_famas"] = "ttt_random_weapon",
	["weapon_zm_sledge"] = "ttt_random_weapon",
	["weapon_ttt_sg552"] = "ttt_random_weapon"
};


This code works fine with Sleek weapon base guns, but when I try to use it with M9K weapons, I get the following Lua errors,


[ERROR] gamemodes/terrortown/entities/entities/ttt_random_weapon.lua:18: bad argument #1 to 'Create' (string expected, got no value)
  1. Create - [C]:-1
   2. unknown - gamemodes/terrortown/entities/entities/ttt_random_weapon.lua:18



[ERROR] gamemodes/terrortown/entities/entities/ttt_random_weapon.lua:18: bad argument #1 to 'Create' (string expected, got no value)
  1. Create - [C]:-1
   2. unknown - gamemodes/terrortown/entities/entities/ttt_random_weapon.lua:18
    3. CleanUpMap - [C]:-1
     4. CleanUpMap - addons/tttdamagelogs-master/lua/damagelogs/sh_sync_entity.lua:36
      5. CleanUp - gamemodes/terrortown/gamemode/init.lua:383
       6. unknown - gamemodes/terrortown/gamemode/init.lua:466


Here is the shared.lua from one of the m9K guns


-- Variables that are used on both client and server
SWEP.Gun = ("m9k_acr") -- must be the name of your swep but NO CAPITALS!
if (GetConVar(SWEP.Gun.."_allowed")) != nil then 
	if not (GetConVar(SWEP.Gun.."_allowed"):GetBool()) then SWEP.Base = "bobs_blacklisted" SWEP.PrintName = SWEP.Gun return end
end
SWEP.Category				= "M9K Assault Rifles"
SWEP.Author				= ""
SWEP.Contact				= ""
SWEP.Purpose				= ""
SWEP.Instructions				= ""
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				= "ACR"		-- Weapon name (Shown on HUD)	
SWEP.Slot				= 2				-- Slot in the weapon selection menu
SWEP.SlotPos				= 21			-- 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.SelectiveFire		= true

SWEP.Kind = WEAPON_HEAVY
SWEP.AutoSpawnable = true

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

SWEP.Primary.Sound			= Sound("Masada.Single")		-- Script that calls the primary fire sound
SWEP.Primary.RPM			= 825			-- This is in Rounds Per Minute
SWEP.Primary.ClipSize			= 30		-- Size of a clip
SWEP.Primary.DefaultClip		= 60		-- 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.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		= .025	-- Define from-the-hip accuracy 1 is terrible, .0001 is exact)
SWEP.Primary.IronAccuracy = .015 -- Ironsight accuracy, should be the same for shotguns

-- Enter iron sight info and bone mod info below
SWEP.IronSightsPos = Vector(2.668, 0, 0.675)
SWEP.IronSightsAng = Vector(0, 0, 0)
SWEP.SightsPos = Vector(2.668, 0, 0.675)
SWEP.SightsAng = Vector(0, 0, 0)
SWEP.RunSightsPos = Vector (-3.0328, 0, 1.888)
SWEP.RunSightsAng = Vector (-24.2146, -36.522, 10)

if GetConVar("M9KDefaultClip") == nil then
	print("M9KDefaultClip is missing! You may have hit the lua limit!")
else
	if GetConVar("M9KDefaultClip"):GetInt() != -1 then
		SWEP.Primary.DefaultClip = SWEP.Primary.ClipSize * GetConVar("M9KDefaultClip"):GetInt()
	end
end

if GetConVar("M9KUniqueSlots") != nil then
	if not (GetConVar("M9KUniqueSlots"):GetBool()) then 
		SWEP.SlotPos = 2
	end
end

Here is the shared.lua from one of the sleek weapon base guns


AddCSLuaFile()

if CLIENT then
	SWEP.DrawCrosshair = false
	SWEP.PrintName = "AK-47"
	SWEP.CSMuzzleFlashes = true
	
	SWEP.AimPos = Vector(-6.615, -10.563, 2.417)
	SWEP.AimAng = Vector(2.625, 0, 0)
	
	SWEP.SprintPos = Vector(1.786, 1.442, 2)
	SWEP.SprintAng = Vector(-10.778, 27.573, 0)
	
	SWEP.ViewModelMovementScale = 1.15
	
	SWEP.IconLetter = "b"
	killicon.AddFont("swb_ak47", "SWB_KillIcons", SWEP.IconLetter, Color(255, 80, 0, 150))
	
	SWEP.MuzzleEffect = "swb_rifle_med"
end

SWEP.PlayBackRate = 30
SWEP.PlayBackRateSV = 12
SWEP.SpeedDec = 30
SWEP.BulletDiameter = 7.62
SWEP.CaseLength = 39

SWEP.Kind = WEAPON_HEAVY
SWEP.AutoSpawnable = true
SWEP.AllowDrop = true

SWEP.Slot = 2
SWEP.SlotPos = 0
SWEP.NormalHoldType = "ar2"
SWEP.RunHoldType = "passive"
SWEP.FireModes = {"auto", "semi"}
SWEP.Base = "swb_base"
SWEP.Category = "SWB Weapons"

SWEP.Author			= "Spy"
SWEP.Contact		= ""
SWEP.Purpose		= ""
SWEP.Instructions	= ""

SWEP.ViewModelFOV	= 55
SWEP.ViewModelFlip	= false
SWEP.ViewModel		= "models/weapons/cstrike/c_rif_ak47.mdl"
SWEP.WorldModel		= "models/weapons/w_rif_ak47.mdl"

SWEP.Spawnable			= true
SWEP.AdminSpawnable		= true

SWEP.Primary.ClipSize		= 30
SWEP.Primary.DefaultClip	= 30
SWEP.Primary.Automatic		= true
SWEP.Primary.Ammo			= "Pistol"
SWEP.Primary.ClipMax = 90

SWEP.Kind = WEAPON_HEAVY
SWEP.AutoSpawnable = true
SWEP.AllowDrop = true
SWEP.AmmoEnt = "item_ammo_pistol_ttt"

SWEP.FireDelay = 0.1
SWEP.FireSound = Sound("Weapon_AK47.Single")
SWEP.Recoil = 1.2

SWEP.HipSpread = 0.04
SWEP.AimSpread = 0.005
SWEP.VelocitySensitivity = 1.6
SWEP.MaxSpreadInc = 0.06
SWEP.SpreadPerShot = 0.007
SWEP.SpreadCooldown = 0.13
SWEP.Shots = 1
SWEP.Damage = 30
SWEP.DeployTime = 1

Any help is appreciated.

Use the M9K TTT Addon instead.

Do NOT edit that file.
Just install this on your server:
M9K Assault Rifles: http://steamcommunity.com/sharedfiles/filedetails/?id=253647726
M9K Heavy Weapons: http://steamcommunity.com/sharedfiles/filedetails/?id=254364811
M9K Small Arms: http://steamcommunity.com/sharedfiles/filedetails/?id=257522321
(All of these are for TTT)

Just install them and thats it.
And the next time, do not be a lazy fuck and search. (found this at the first try)

[editline]6th August 2015[/editline]

Sorry for looking like an asshole, but its just that you didnt even search, cause if you searched for them, you would find them instantly as i did.

Thanks for your help geferon but there is no need to go around calling me a lazy fuck. I did search for solutions to my issue but was unable to find any. Thanks again for your help.

[editline]6th August 2015[/editline]

Getting this error on round start and the guns are still not spawning. And that is using the m9k TTT pack.


[ERROR] gamemodes/terrortown/entities/entities/ttt_random_weapon.lua:18: bad argument #1 to 'Create' (string expected, got no value)
  1. Create - [C]:-1
   2. unknown - gamemodes/terrortown/entities/entities/ttt_random_weapon.lua:18
    3. Spawn - [C]:-1
     4. ReplaceSingle - gamemodes/terrortown/gamemode/ent_replace.lua:23
      5. ReplaceWeaponSingle - gamemodes/terrortown/gamemode/ent_replace.lua:113
       6. ReplaceWeapons - gamemodes/terrortown/gamemode/ent_replace.lua:122
        7. ReplaceEntities - gamemodes/terrortown/gamemode/ent_replace.lua:151
         8. unknown - gamemodes/terrortown/gamemode/init.lua:407



The ent_replace.lua, did you change it back to how it was, or is it edited?
Sorry by calling you lazy fuck

[editline]8th August 2015[/editline]

If you’ve edited any TTT’s default file, change it back to default cause the weapons spawn randomly around the map depending on how the mapper has put the weapon entities.
If none of the M9K weapons spawn, then its a map problem, not a lua problem

geferon, I was looking at this because I need to spawn in M9K Weapons, do I just drag the files to my addons and thats it?

Noo, you subscribe to them on the workshop.

Then add them to the workshop dl?