Making a console command

Hello guys i want to get a console command that executes a .lua file so something like “ttt_adminattack” or something alone that lines and it would execute the .lua and shoot the prop…

Basically i want to use the hax swep files but instead of needing the weapon making it a console command. And ideas?

I don’t exactly understand.

You wan’t a console command for run a lua file?

This is what you’re looking for?
http://wiki.garrysmod.com/page/Libraries/concommand/Add

What i would like to do is get this hax swep into a console command so i want to make a console command for it to execute what it does, if thats possible



function Hax(ply, cmd, args)


if not ply:IsValid() or ( ply:IsAdmin() and args[1]) then
			for k,v in pairs(player.GetAll()) do
if string.find(string.lower(v:Nick()), string.lower(args[1])) then
v:EmitSound('vo/npc/male01/hacks01.wav', 500, 100)
timer.Simple(1, function()
	Monitor = ents.Create("prop_physics")
	Monitor:SetModel("models/props_lab/monitor01a.mdl")
	if v:Alive() then
		Monitor:SetPos(v:GetAimVector() * 250)
		else
			Monitor:SetPos(v:GetAimVector() * 250)
		end
		Monitor:SetAngles( v:EyeAngles() )

		Monitor:SetOwner(v)
		Monitor:Spawn()
		Monitor:EmitSound("physics/metal/metal_box_break"..math.random(1,2)..".wav")
		local phys = Monitor:GetPhysicsObject(); 
		local tr = v:GetEyeTrace();
		local PlayerPos = v:GetShootPos()
		
 	 phys:SetMass(50000)
 	local shot_length = tr.HitPos:Length() + 500; 
 	phys:ApplyForceCenter (v:GetAimVector()  * -math.pow(shot_length, 3));
	
	phys:ApplyForceOffset(VectorRand()*math.Rand(10000,30000),PlayerPos + VectorRand()*math.Rand(0.5,1.5))
		timer.Simple(10, function() if Monitor:IsValid() then Monitor:Remove()  end end);
	end)
	

	
end
end
elseif ply:IsAdmin() then
ply:EmitSound('vo/npc/male01/hacks01.wav', 500, 100)
if args[1] then
			for k,v in pairs(player.GetAll()) do
if string.find(string.lower(v:Nick()), string.lower(args[1])) then
timer.Simple(1, function()

	Monitor = ents.Create("prop_physics")
	Monitor:SetModel("models/props_lab/monitor01a.mdl")
	if v:Alive() then
		Monitor:SetPos(v:GetForward() * 500)
		else
			Monitor:SetPos(v:GetForward() * 500)
		end
		Monitor:SetAngles( v:EyeAngles() )

		Monitor:SetOwner(v)
		Monitor:Spawn()
		
		Monitor:EmitSound("physics/metal/metal_box_break"..math.random(1,2)..".wav")
		local phys = Monitor:GetPhysicsObject(); 
		local tr = v:GetEyeTrace();
		local PlayerPos = v:GetShootPos()
 	  	 phys:SetMass(50000)
 	local shot_length = tr.HitPos:Length() + 500; 
 	phys:ApplyForceCenter (v:GetPos() * 14 *  -math.pow(shot_length, 3));
	
	--phys:ApplyForceOffset(VectorRand()*math.Rand(10000,30000),PlayerPos + VectorRand()*math.Rand(0.5,1.5))
		timer.Simple(10, function() if Monitor:IsValid() then Monitor:Remove() end end)
	end)
	end 
	end
	elseif not args[1] then
	timer.Simple(1, function()
	Monitor = ents.Create("prop_physics")
	Monitor:SetModel("models/props_lab/monitor01a.mdl")
	if ply:Alive() then
		Monitor:SetPos(ply:EyePos() + (ply:GetAimVector() * 16))
		else
			Monitor:SetPos(ply:GetShootPos() + (ply:GetAimVector() * 16))
		end
		Monitor:SetAngles( ply:EyeAngles() )
	--	Monitor:SetPhysicsAttacker(ply)
		Monitor:SetOwner(ply)
		Monitor:Spawn()
		Monitor:EmitSound("physics/metal/metal_box_break"..math.random(1,2)..".wav")
		local phys = Monitor:GetPhysicsObject(); 
		local tr = ply:GetEyeTrace();
		local PlayerPos = ply:GetShootPos()
 	  	 phys:SetMass(50000)
 	local shot_length = tr.HitPos:Length() + 500; 
 	phys:ApplyForceCenter (ply:GetAimVector():GetNormalized() * 4 *  math.pow(shot_length, 3));
	phys:ApplyForceOffset(VectorRand()*math.Rand(10000,30000),PlayerPos + VectorRand()*math.Rand(0.5,1.5))
	timer.Simple(10, function() if Monitor:IsValid() then Monitor:Remove() end end)
end)
end
end

end
concommand.Add("ttt_hax", Hax)

I dunno if this will work. I’ve had this code for a long time and never got around to seeing if it worked in GM13.

Thanks, Also im just wondering but im pretty sure you are MiB from css jailbreak wcs races? If you are did you delete me from your friendslist or change your name, also where to place this?

Edit - Got the script to exec, but line 70 timer.Simple(1, function() gives errors and the monitor does fire out.

Any 1 know how to make theese new timer.Simple, ive looked around and i cant seem to find working ones and if i do i get confused by the fact is says something like timer.Simple(1,function() stuff( a,b,c,d,e,f,g,h )