Making a swep run a command.

I’m trying to edit a swep to run a certain command that an addon uses, spread_extinguish is the command, where would I add this to the swep to make it function?

[lua]
function SWEP:Deploy()
game.ConsoleCommand, “spread_extinguish”)
end
[/lua]

That should work

I’m trying to make this fire extinguisher work with a fire addon I have, it needs to run the command fire_spread_extinguish now that I have added the deploy function the gun does not spawn, I’m not a lua coder I was trying to add this function with no knowledge if anyone could point me in the right direction.


 if ( SERVER ) then

	AddCSLuaFile( "shared.lua" )
	
	SWEP.HoldType			= "shotgun"
	
end

if ( CLIENT ) then

	SWEP.PrintName			= "Fire Extinguisher"			
	SWEP.Author				= "Feihc"

	SWEP.Slot				= 1
	SWEP.SlotPos			= 8
	SWEP.ViewModelFOV		= 70
	SWEP.IconLetter			= "x"

end
-----------------------Main functions----------------------------
 
-- function SWEP:Reload() --To do when reloading
-- end 
 
function SWEP:Think() -- Called every frame

end

function SWEP:Deploy()  
game.ConsoleCommand, "spread_extinguish")  
end   

function SWEP:Initialize()
util.PrecacheSound("ambient/wind/wind_hit2.wav")
end

function smoke(ent, speed, rate, size1, size2, length)
if SERVER then
local smoke = ents.Create("env_steam")
if ent:IsPlayer() then
	smoke:SetPos(ent:GetShootPos())
	smoke:SetKeyValue("Angles", tostring(ent:EyeAngles()))
else
	smoke:SetPos(ent:GetPos())
	smoke:SetKeyValue("Angles", tostring(Angle(0,0,0)))
end

smoke:SetKeyValue("InitialState", "1")
smoke:SetKeyValue("Speed", speed)
smoke:SetKeyValue("Rate", rate)
smoke:SetKeyValue("StartSize", size1)
smoke:SetKeyValue("EndSize", size2)
smoke:SetKeyValue("JetLength", length)
smoke:SetKeyValue("SpreadSpeed", "2")
smoke:SetKeyValue("SpawnFlags", "1")
smoke:Spawn()
smoke:Activate()
smoke:Fire("TurnOn", "", 0)
smoke:Fire("TurnOff","", .25)
smoke:Fire("kill", "", 1)
end
end
 
function SWEP:PrimaryAttack()
if SERVER then
smoke(self.Owner, "500", "50", "5", "20", "500")
	
local trace = {}
trace.startpos = self.Owner:GetShootPos()
trace.endpos = self.Owner:GetShootPos() + (self.Owner:GetAimVector() * 800)
trace.filter = self.Owner
local tr = util.TraceLine(trace)

if tr.Hit then
	local exting = ents.FindInSphere(tr.HitPos, 80)
	for key, ent in pairs(exting) do
		local flames = ents.FindByClass( "entityflame" );
			for _, flame in pairs(flames) do
				if flame:IsValid() then
					if flame:GetParent() == ent then
						--flame:Fire("TurnOff", "", 0)
						--flame:Fire("kill", "", 0)
						flame:Remove()	
					end
				end 
			end
		if ent:IsValid() then
			if ent:IsNPC() or ent:IsPlayer() then
				local b = ents.Create( "point_hurt" )
				b:SetKeyValue("targetname", "fier" ) --Yes, I spelled it like that on purpose.
				b:SetKeyValue("DamageRadius", "20" )
				b:SetKeyValue("Damage", "5" )
				b:SetKeyValue("DamageDelay", "1" )
				b:SetKeyValue("DamageType", "16" )
				b:SetPos( ent:GetPos())
				b:Spawn()
				b:Fire("turnon", "", 0)
				b:Fire("kill", "", 5)
			end
		end
	end
	local Pos1 = tr.HitPos + tr.HitNormal
	local Pos2 = tr.HitPos - tr.HitNormal
	--util.Decal( "hl1glassbreak", Pos1, Pos2 )
end
end

self.Weapon:EmitSound("ambient/wind/wind_hit2.wav")
self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
self.Weapon:SetNextPrimaryFire(CurTime() + .2)

end
 
function SWEP:SecondaryAttack()

end
-------------------------------------------------------------------

------------General Swep Info---------------
SWEP.Author   = "Feihc"
SWEP.Contact        = ""
SWEP.Purpose        = ""
SWEP.Instructions   = "Put out ze fire!"
SWEP.Spawnable      = true
SWEP.AdminSpawnable  = true
-----------------------------------------------

------------Models---------------------------
SWEP.ViewModel      = "models/weapons/v_fire_extinguisher.mdl"
SWEP.WorldModel   = "models/weapons/w_fire_extinguisher.mdl"
-----------------------------------------------

-------------Primary Fire Attributes----------------------------------------
SWEP.Primary.Delay			= 0.9 	--In seconds
SWEP.Primary.Recoil			= 0		--Gun Kick
SWEP.Primary.Damage			= 15	--Damage per Bullet
SWEP.Primary.NumShots		= 1		--Number of shots per one fire
SWEP.Primary.Cone			= 0 	--Bullet Spread
SWEP.Primary.ClipSize		= 10	--Use "-1 if there are no clips"
SWEP.Primary.DefaultClip	= 10	--Number of shots in next clip
SWEP.Primary.Automatic   	= true	--Pistol fire (false) or SMG fire (true)
SWEP.Primary.Ammo         	= "pistol"	--Ammo Type
-------------End Primary Fire Attributes------------------------------------
 
-------------Secondary Fire Attributes-------------------------------------
SWEP.Secondary.Delay		= 0.9
SWEP.Secondary.Recoil		= 0
SWEP.Secondary.Damage		= 0
SWEP.Secondary.NumShots		= 1
SWEP.Secondary.Cone			= 0
SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic   	= true
SWEP.Secondary.Ammo         = "none"
-------------End Secondary Fire Attributes--------------------------------

Wait, what? What kind of santax is that…

:eng101:

Go do your grammar Nazi-ism on the post that other guy made.

Can anyone help :o?

It’s because his syntax fails. It’s

[lua]
function SWEP:Deploy()
if(SERVER) then
game.ConsoleCommand(“fire_spread_extinguish”)
end
end[/lua]