Prioritizing some files over workshop

I got this to work, however it only works if the server itself is started up and I modify say the code of a weapon. Once I restart the server, it goes back to how the gun originally was. How do I go about bypassing it?
I was told before to use weapons.Register but I have little to no knowledge of Lua and have no idea how that works.

In an Initialize hook, declare a local table SWEP, copy and paste your weapon code, then run weapons.Register("class_name, SWEP)

I don’t mean to be annoying and I apologize if I am but I don’t really have an idea on how to do that.

For the hook, I know I have to include this:


hook.Add( "Initialize", "randomname", function )

I don’t know what to include as the function.

The local table SWEP, is that the ammo, dmg etc except ran locally?

I noticed a small mistake in the other suggestion you gave me on another thread.

You said to try this:


local SWEP = {}

-- SWEP code

weapons.Register("class_name", SWEP)

Isn’t it the table, “SWEP” then the class name afterwards on the weapons.Register?

assuming that’s right, shouldn’t this work? I’ve tested it and the default settings still overide it. Unless i’m doing something wrong, which wouldn’t surprise me. Also, to 2x check, “class_name” is the name of the weapon correct?


local SWEP = {}

//GeneralSettings\\
SWEP.Base				= "weapon_tttbase"
SWEP.Spawnable = true
SWEP.AutoSpawnable = true
SWEP.HoldType = "pistol"
SWEP.AdminSpawnable = true
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Kind = WEAPON_PISTOL


//Serverside\\
if SERVER then
   AddCSLuaFile( "shared.lua" )
   resource.AddFile("materials/VGUI/ttt/icon_a300.vmt")
end

//Clientside\\
if CLIENT then

   SWEP.PrintName    = "A-3000"
   SWEP.Slot         = 1
   
   SWEP.ViewModelFOV  = 70
   SWEP.ViewModelFlip = true

   SWEP.Icon = "VGUI/ttt/icon_a3000"
end

//Damage\\
SWEP.Primary.Delay       = 0.1
SWEP.Primary.Recoil      = 1.5
SWEP.Primary.Automatic   = true
SWEP.Primary.NumShots = 1
SWEP.Primary.Damage      = 50 -- was 32 testing
SWEP.Primary.Cone        = 0.01
SWEP.Primary.Ammo        = "Alyxgun"
SWEP.Primary.ClipSize    = 12
SWEP.Primary.ClipMax     = 36
SWEP.Primary.DefaultClip = 12
SWEP.AmmoEnt = "item_ammo_revolver_ttt"


//Verschiedenes\\
SWEP.InLoadoutFor = nil
SWEP.AllowDrop = true
SWEP.IsSilent = false
SWEP.NoSights = false
SWEP.UseHands = true
SWEP.HeadshotMultiplier = 4

//Sounds/Models\\
SWEP.ViewModel	= "models/weapons/gamefreak/v_pist_glock66.mdl"
SWEP.WorldModel	= "models/weapons/gamefreak/w_pist_glock66.mdl"
SWEP.Weight = 5
SWEP.Primary.Sound = Sound( "weapons/gamefreak/glock/glock18-1.wav" )
SWEP.IronSightsPos = Vector(2.634, -0.805, 0.75)
SWEP.IronSightsAng = Vector(0, 0, 0)


function SWEP:Reload()
	if (self.Weapon:Clip1() < 12) then
		
		self.Weapon:DefaultReload( ACT_VM_RELOAD );
		
		self:SetIronsights( false )
	end
end

weapons.Register(SWEP,"weapon_ttt_a3000")

Yes, you are correct in the ordering. Do that code in an Initialize or InitPostEntity

Thanks for the reply, this is my end results. Does everything seem correct? (Mostly the function, I’m not sure I did that correctly.)


function init()

local SWEP = {}

//GeneralSettings\\
SWEP.Base				= "weapon_tttbase"
SWEP.Spawnable = true
SWEP.AutoSpawnable = true
SWEP.HoldType = "pistol"
SWEP.AdminSpawnable = true
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Kind = WEAPON_PISTOL


//Serverside\\
if SERVER then
   AddCSLuaFile( "shared.lua" )
   resource.AddFile("materials/VGUI/ttt/icon_a300.vmt")
end

//Clientside\\
if CLIENT then

   SWEP.PrintName    = "A-3000"
   SWEP.Slot         = 1
   
   SWEP.ViewModelFOV  = 70
   SWEP.ViewModelFlip = true

   SWEP.Icon = "VGUI/ttt/icon_a3000"
end

//Damage\\
SWEP.Primary.Delay       = 0.1
SWEP.Primary.Recoil      = 1.5
SWEP.Primary.Automatic   = true
SWEP.Primary.NumShots = 1
SWEP.Primary.Damage      = 50 -- was 32 testing
SWEP.Primary.Cone        = 0.01
SWEP.Primary.Ammo        = "Alyxgun"
SWEP.Primary.ClipSize    = 12
SWEP.Primary.ClipMax     = 36
SWEP.Primary.DefaultClip = 12
SWEP.AmmoEnt = "item_ammo_revolver_ttt"


//Verschiedenes\\
SWEP.InLoadoutFor = nil
SWEP.AllowDrop = true
SWEP.IsSilent = false
SWEP.NoSights = false
SWEP.UseHands = true
SWEP.HeadshotMultiplier = 4

//Sounds/Models\\
SWEP.ViewModel	= "models/weapons/gamefreak/v_pist_glock66.mdl"
SWEP.WorldModel	= "models/weapons/gamefreak/w_pist_glock66.mdl"
SWEP.Weight = 5
SWEP.Primary.Sound = Sound( "weapons/gamefreak/glock/glock18-1.wav" )
SWEP.IronSightsPos = Vector(2.634, -0.805, 0.75)
SWEP.IronSightsAng = Vector(0, 0, 0)


function SWEP:Reload()
	if (self.Weapon:Clip1() < 12) then
		
		self.Weapon:DefaultReload( ACT_VM_RELOAD );
		
		self:SetIronsights( false )
	end
end

end

hook.Add("Initialize","overideWorkshop", init )

weapons.Register(SWEP,"weapon_ttt_a3000")

Yes, but make init a local function.

Alright thank you very much for your help! I really appreciate it. I’m sorry again if I was somewhat annoying lol.

Ah man. It ended up not working, tried both of the hooks. I’ll give up on it for now.

Edit: Without the use of the provided code, I can make it work but I don’t understand how.

It came in a folder called weapon_ttt_a3000, inside was a shared.lua

I took the shared.lua, renamed it to the folder name and placed it under /garrysmod/gamemodes/terrortown/entities/weapons

and my modifications somehow work.

Was about to say missing base but since you put it back in /terrortown/ it can’t be that :dead: