Workshop addons and weapons.Register

If anyone saw, I posted about workshop addons the other day. I extracted the .gma from the workshop and attempted to edit that to change the behavior of the addon. Long story short that didn’t work, workshop files have priority. I was told I had to use different file names and weapons.Register to override the workshop version. Problem is, I have no idea on how to do so… I have an addon called the TTT Briefcase, I added more options to it but was unsuccessful in trying to actually update it on my server. I spent a few hours looking up information and trying different solutions with no success. Any help would be appreciated!

Pretty sure weapons are loaded before autorun, so you can do this in a file there:


local SWEP = {}

-- SWEP code

weapons.Register("class_name", SWEP)

If I’m incorrect (don’t have means of testing atm), you can use a PostGamemodeLoaded or InitPostEntity hook, although doing the latter will trigger all of that entity type to be recreated with your new class.

I added what you wrote on lines 46 and the last line. It doesn’t work probably because I’m bad lol



AddCSLuaFile( "shared.lua" )



if SERVER then
	//resource.AddSingleFile( "materials/VGUI/ttt/sp_briefcase2.vtf" )
	//resource.AddSingleFile( "materials/VGUI/ttt/sp_briefcase2.vmt" )
	resource.AddWorkshop( "215080259" )
end





-- Copy a line to add a new weapon to the list.
-- Simple and easy. Please do not ask for help.
-- ex: weapon_ttt_ak47 = "AK47",

arse_Primary = {
//	weapon_ttt_ak47 = "AK47",
	weapon_ttt_m16 = "M16",
	weapon_ttt_ar15 = "Ar15",
	weapon_ttt_scarh = "Scar-H",
	weapon_zm_rifle = "Rifle",
	weapon_zm_shotgun = "Shotgun",
	weapon_zm_mac10 = "MAC10",
	weapon_zm_sledge = "H.U.G.E.",
}

arse_Secondary = {
	weapon_ttt_glock = "Glock",
	weapon_zm_pistol = "Pistol",
	weapon_zm_revolver = "Deagle",
	weapon_ttt_a3000 = "A-3000",
}

arse_Grenade = {
	weapon_ttt_confgrenade = "Dicombobulator",
	weapon_ttt_smokegrenade = "Smoke",
	weapon_zm_molotov = "Incendiary",
}



local SWEP = {}


SWEP.HoldType = "normal"


SWEP.Base = "weapon_tttbase"

SWEP.ViewModel          = "models/weapons/v_crowbar.mdl"
SWEP.WorldModel         = "models/weapons/w_suitcase_passenger.mdl"

SWEP.DrawCrosshair      = false
SWEP.Primary.ClipSize       = -1
SWEP.Primary.DefaultClip    = -1
SWEP.Primary.Automatic      = false
SWEP.Primary.Ammo       = "none"
SWEP.Primary.Delay = 1

SWEP.Kind = WEAPON_EQUIP2
SWEP.CanBuy = { ROLE_TRAITOR, ROLE_DETECTIVE }

SWEP.LimitedStock = true
SWEP.AllowDrop = true
SWEP.NoSights = true

SWEP.DeploySpeed = 10


if CLIENT then

	SWEP.PrintName = "Briefcase"
	SWEP.Slot = 7

	SWEP.ViewModelFOV = 10

	SWEP.EquipMenuData = {
		type = "item_weapon",
		desc = "A single use briefcase full of weapons and ammo.

Allows you to equip your choice of any default
primary, secondary, and/or grenade weapon."
	};

	SWEP.Icon = "VGUI/ttt/sp_briefcase2"
	
	function CreateArsenalMenu()
		
		arse_Close()
		
		local w,h = 210,150
		
		arse_prim = nil
		arse_seco = nil
		arse_nade = nil
		
		arse = vgui.Create( "DFrame" )
		arse:SetPos( ScrW() - w/2, ScrH() - h/2 )
		arse:SetSize( w, h )
		arse:SetTitle( "Weapon Deployment" )
		arse:Center()
		arse:MakePopup()
		
		arse:SetKeyboardInputEnabled()
		
		arse:SetAlpha( 0 )
		arse:AlphaTo( 255, 0.3 )
		
		local lab = vgui.Create( "DLabel", arse )
		lab:SetText( "Primary:" )
		lab:SetPos( 10, 33 )
		lab:SizeToContents()
		
		local arse1 = vgui.Create( "DComboBox", arse )
		arse1:SetPos( 56, 30 )
		arse1:SetSize( 144, 20 )
		arse1:SetText( "None" )
		arse1.OnSelect = function( self, i, title, data ) arse_prim = data end
		for k,v in pairs( arse_Primary ) do arse1:AddChoice( v, k ) end
		
		local lab = vgui.Create( "DLabel", arse )
		lab:SetText( "Secondary:" )
		lab:SetPos( 10, 63 )
		lab:SizeToContents()
		
		arse2 = vgui.Create( "DComboBox", arse )
		arse2:SetPos( 70, 60 )
		arse2:SetSize( 130, 20 )
		arse2:SetText( "None" )
		arse2.OnSelect = function( self, i, title, data ) arse_seco = data end
		for k,v in pairs( arse_Secondary ) do arse2:AddChoice( v, k ) end
		
		local lab = vgui.Create( "DLabel", arse )
		lab:SetText( "Grenade:" )
		lab:SetPos( 10, 93 )
		lab:SizeToContents()
		
		local arse3 = vgui.Create( "DComboBox", arse )
		arse3:SetPos( 61, 90 )
		arse3:SetSize( 139, 20 )
		arse3:SetText( "None" )
		arse3.OnSelect = function( self, i, title, data ) arse_nade = data end
		for k,v in pairs( arse_Grenade ) do arse3:AddChoice( v, k ) end
	
		local but = vgui.Create( "DButton", arse )
		but:SetPos( 100, 120 )
		but:SetSize( 100, 20 )
		but:SetText( "Give Loadout" )
		but.DoClick = function( self )
			
			arse_Close()
			
			if !arse_prim and !arse_seco and !arse_nade then return end
			
			RunConsoleCommand( "arse_loadout", arse_prim or "", arse_seco or "", arse_nade or "" )
			
		end
		
	end
	
	function arse_Close()
		
	//	MsgN( "CLOSING ARSENAL MENU" )
		
		if arse and arse.Remove then arse:Remove() end
		
		arse = nil
	
	end
	
	hook.Add( "TTTEndRound", "arse_EndClose", arse_Close )
	hook.Add( "TTTPrepareRound", "arse_PrepClose", arse_Close )
	
	hook.Add( "Think", "arse_DeadClose", function()
		if !arse then return end
		if LocalPlayer():GetObserverMode() != OBS_MODE_NONE or
		!LocalPlayer():HasWeapon( "weapon_ttt_briefcase" ) then arse_Close() end
	end )
	
elseif SERVER then
	
	local function RemoveKind( ply, kind )
	
		for k,v in pairs( ply:GetWeapons() ) do
			
			if v.Kind == kind then
				ply:StripWeapon( v:GetClass() )
				SafeRemoveEntity( v ) // insurance
			end
			
		end
	
	end
	
	concommand.Add( "arse_loadout", function( ply, cmd, args )
	
		if !IsValid( ply ) or ply:GetObserverMode() != OBS_MODE_NONE then return end
		
		if !ply:HasWeapon( "weapon_ttt_briefcase" ) then return end
		
		local prim = tostring( args[1] )
		local seco = tostring( args[2] )
		local nade = tostring( args[3] )
		
		if prim and arse_Primary[ prim ] then
			RemoveKind( ply, WEAPON_HEAVY )
			ply:Give( prim )
		end
		
		if seco and arse_Secondary[ seco ] then
			RemoveKind( ply, WEAPON_PISTOL )
			ply:Give( seco )
		end
		
		if nade and arse_Grenade[ nade ] then
			RemoveKind( ply, WEAPON_NADE )
			ply:Give( nade )
		end
		
		ply:StripWeapon( "weapon_ttt_briefcase" )
		
		for k,v in pairs( ply:GetWeapons() ) do
			
			local kind = v.Kind
			local ammo = string.lower( v.Primary.Ammo )
			
			local white = {
				"pistol",
				"smg1",
				"alyxgun",
				"357",
				"buckshot"
			}
			
			if ( kind == WEAPON_HEAVY or kind == WEAPON_PISTOL )
			and table.HasValue( white, ammo ) then
				ply:SetAmmo( v.Primary.ClipMax, ammo )
			end
			
		end
		
	end )

end


function SWEP:OpenArsenalMenu()

	self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
	self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
	
	if SERVER and !game.SinglePlayer() then return end
	
	CreateArsenalMenu()

end


function SWEP:PrimaryAttack() self:OpenArsenalMenu() end
function SWEP:SecondaryAttack() self:OpenArsenalMenu() end
function SWEP:Reload() end


function SWEP:OnRemove()

	if CLIENT and IsValid(self.Owner) and self.Owner == LocalPlayer() and self.Owner:Alive() then
		
		RunConsoleCommand("lastinv")
		
	end

end


function SWEP:Deploy()

	if SERVER and IsValid(self.Owner) then
	
		self.Owner:DrawViewModel(false)
		
	end
	
	return true
	
end


//function SWEP:DrawWorldModel() if !IsValid( self:GetOwner() ) then self:DrawModel() end end

weapons.Register("weapon_ttt_briefcase", SWEP)



Edit* Yeah, I can’t make this work for the life of me. I’m going to keep trying tomorrow.