ConCommand Question?

Hey guys,

I founded this code at toybox in Gmod,

[lua]
if CLIENT then
SWEP.PrintName = “Haax!”
SWEP.Author = “Otger”
SWEP.Contact = “”
SWEP.Purpose = “Throw monitors at your enemies! Based on the ‘The Gmod Idiot Box’ YouTube series by DasBoSchitt.”
SWEP.Instructions = “Left click to shoot a monitor. Right click to attack with the spawned monitors. Reload to open the menu.”
SWEP.Slot = 1
SWEP.SlotPos = 3
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = true
end
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.ViewModel = “models/weapons/V_hands.mdl”
SWEP.WorldModel = “models/props_junk/PopCan01a.mdl”

SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = “none”
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = “none”

SWEP.SndSpawn = Sound(“vo/npc/male01/herecomehacks01.wav”)
SWEP.SndHaax = Sound(“vo/npc/male01/hacks01.wav”)

util.PrecacheModel(“models/props_lab/monitor01a.mdl”)
util.PrecacheModel(“models/props_lab/monitor02.mdl”)

if SERVER then
if !HaaxSettings then
HaaxSettings = {}
HaaxSettings.Grav = false
HaaxSettings.DmgSelf = true
HaaxSettings.RndMdl = false
end

concommand.Add("HaaxConfig", function(ply,cmd,args)
    local wep = Entity(tonumber(args[1]))
    if ValidEntity(wep) && wep.IsHaaxSWEP then
        if (ply == wep.Owner) && ply:IsAdmin() then
            wep:HaaxUpdateGravity(tobool(args[2]))
            HaaxSettings.DmgSelf = tobool(args[3])
            wep:HaaxUpdateModels(tobool(args[4]))
        end
    end
end)

concommand.Add("HaaxClear", function(ply,cmd,args)
    local wep = Entity(tonumber(args[1]))
    if ValidEntity(wep) && wep.IsHaaxSWEP then
        if (ply == wep.Owner) && ply:IsAdmin() then
            wep:HaaxClear()
        end
    end
end)

local function HaaxOverrideDamage(ent,inflictor,attacker,amount,dmginfo)
    if inflictor:GetClass() == "prop_haax" && ValidEntity(inflictor.SWEP) then
        if ent:IsPlayer() then
            if (inflictor.HaaxOwner == ent) && !HaaxSettings.DmgSelf then
                dmginfo:SetDamage(0)
            end
        end
    end
end
hook.Add("EntityTakeDamage", "HaaxOverrideDamage", HaaxOverrideDamage)

function SWEP:HaaxClear()
    local props = ents.FindByClass("prop_haax")
    
    if table.Count(props) > 0 then
        SendUserMessage("HaaxClear", self.Owner)
        for _,ent in pairs(props) do
            if ValidEntity(ent) && ValidEntity(ent.HaaxOwner) && (ent.HaaxOwner == self.Owner) then
                ent:Remove()
            end
        end
    end
end

function SWEP:HaaxUpdateGravity(bGrav)
    if HaaxSettings.Grav ~= bGrav then
        local props = ents.FindByClass("prop_haax")
        
        if table.Count(props) > 0 then
            for _,ent in pairs(props) do
                if ValidEntity(ent) && ValidEntity(ent.HaaxOwner) && (ent.HaaxOwner == self.Owner) then
                    ent:GetPhysicsObject():EnableGravity(bGrav)
                end
            end
        end
    end
    HaaxSettings.Grav = bGrav
end

function SWEP:HaaxUpdateModels(bNotRandom)
    if HaaxSettings.RndMdl ~= bNotRandom then
        local props = ents.FindByClass("prop_haax")
        
        if table.Count(props) > 0 then
            for _,ent in pairs(props) do
                if ValidEntity(ent) && ValidEntity(ent.HaaxOwner) && (ent.HaaxOwner == self.Owner) then
                    if bNotRandom then
                        if ent:GetModel() ~= "models/props_lab/monitor01a.mdl" then
                            ent:SetModel("models/props_lab/monitor01a.mdl")
                        end
                    else
                        if math.random(3) == 1 then
                            ent:SetModel("models/props_lab/monitor01a.mdl")
                        else
                            ent:SetModel("models/props_lab/monitor02.mdl")
                            ent:SetSkin(math.random(3))
                        end
                    end
                end
            end
        end
    end
    HaaxSettings.RndMdl = bNotRandom
end

end

if CLIENT then
local HaaxSndRemove = Sound(“buttons/button15.wav”)

killicon.AddFont("prop_haax", "HL2MPTypeDeath", "9", Color(160,160,128,255))
language.Add("prop_haax", "Haax!")

usermessage.Hook("HaaxClear",function(um)
    GAMEMODE:AddNotify("Removed Haax Monitors", NOTIFY_UNDO, 4)
    LocalPlayer():EmitSound(HaaxSndRemove)
end)

usermessage.Hook("HaaxMenu",function(um)
    local wep = LocalPlayer():GetActiveWeapon()
    if wep && wep.IsHaaxSWEP then
        local tData = string.Explode(",",um:ReadString())
        wep:MenuOpen(tData)
    end
end)    

function SWEP:MenuCreate()
    if self.Menu then
        self.Menu:SetVisible(false)
        self.Menu:Remove()
    end
    self.Menu = vgui.Create("DFrame")
        self.Menu:SetName("HaaxMenu")
        self.Menu:SetTitle("Haax! - Settings")
        self.Menu:SetDraggable(true)
        self.Menu:ShowCloseButton(true)
        self.Menu:SetDeleteOnClose(false)
        self.Menu:SetSize(256,192)
        self.Menu:SetVisible(false)
        
        self.Menu.ChkGrav = vgui.Create("DCheckBoxLabel", self.Menu)
            self.Menu.ChkGrav:SetPos(16,32)
            self.Menu.ChkGrav:SetText("Enable gravity")
            self.Menu.ChkGrav:SetTooltip("If checked, the monitors will be affected by the gravity.")
            self.Menu.ChkGrav:SizeToContents()
            
        self.Menu.ChkDmgSelf = vgui.Create("DCheckBoxLabel", self.Menu)
            self.Menu.ChkDmgSelf:SetPos(16,64)
            self.Menu.ChkDmgSelf:SetText("Damage owner")
            self.Menu.ChkDmgSelf:SetTooltip("If checked, the monitors will inflict damage to their owner.")
            self.Menu.ChkDmgSelf:SizeToContents()
            
        self.Menu.ChkRndMdl = vgui.Create("DCheckBoxLabel", self.Menu)
            self.Menu.ChkRndMdl:SetPos(16,96)
            self.Menu.ChkRndMdl:SetText("Disable random models")
            self.Menu.ChkRndMdl:SetTooltip("If checked, all the monitors will have the default model. (Use it in case you see missing textures)")
            self.Menu.ChkRndMdl:SizeToContents()
            
        self.Menu.BtnClear = vgui.Create("DButton", self.Menu)
            self.Menu.BtnClear:SetText("Remove monitors")
            self.Menu.BtnClear:SetPos(16,128)
            self.Menu.BtnClear:SetSize(224,24)
            self.Menu.BtnClear.SWEP = self
            self.Menu.BtnClear.DoClick = function(button)
                RunConsoleCommand("HaaxClear", button.SWEP:EntIndex())
                button.SWEP.Menu:SetVisible(false)
            end
            
        self.Menu.BtnSave = vgui.Create("DButton", self.Menu)
            self.Menu.BtnSave:SetText("Apply settings")
            self.Menu.BtnSave:SetPos(16,160)
            self.Menu.BtnSave:SetSize(224,24)
            self.Menu.BtnSave.SWEP = self
            self.Menu.BtnSave.DoClick = function(button)
                RunConsoleCommand("HaaxConfig",
                    button.SWEP:EntIndex(),
                    tostring(button.SWEP.Menu.ChkGrav:GetChecked()),
                    tostring(button.SWEP.Menu.ChkDmgSelf:GetChecked()),
                    tostring(button.SWEP.Menu.ChkRndMdl:GetChecked())
                )
                GAMEMODE:AddNotify("Haax Settings Applied", NOTIFY_GENERIC, 4)
                LocalPlayer():EmitSound(HaaxSndRemove)
                button.SWEP.Menu:SetVisible(false)
            end
end

function SWEP:MenuOpen(tOpts)
    if not self.Menu then
        self:MenuCreate()
    end
    self.Menu.ChkGrav:SetValue(tobool(tOpts[1]) or false)
    self.Menu.ChkDmgSelf:SetValue(tobool(tOpts[2]) or false)
    self.Menu.ChkRndMdl:SetValue(tobool(tOpts[3]) or false)
    self.Menu:SetPos(ScrW()/2-128,ScrH()/2-138)
    self.Menu:SetVisible(true)
    self.Menu:MakePopup()
end

end

function SWEP:Initialize()
self.IsHaaxSWEP = true
self:SetWeaponHoldType(“melee”)
end

function SWEP:OnRemove()
if CLIENT then
if(self.Menu && self.Menu:IsValid()) then
self.Menu:SetVisible(false)
self.Menu:Remove()
end
end
end

function SWEP:Deploy()
if SERVER then
self.Owner:DrawWorldModel(false)
self:EmitSound(self.SndSpawn)
end
return true
end

function SWEP:Holster()
if SERVER then
self.Owner:DrawWorldModel(true)
end
return true
end

function SWEP:PrimaryAttack()
if (!SERVER) then return end

self:EmitSound(self.SndHaax)

local tr = self.Owner:GetEyeTrace()

local ent = ents.Create("prop_haax")
    ent:SetPos(self.Owner:EyePos()+self.Owner:GetAimVector()*(16+self.Owner:GetVelocity():Length()/64))
    ent:SetAngles(self.Owner:EyeAngles())
    ent.HaaxOwner = self.Owner
    ent.SWEP = self
ent:Spawn()

local phys = ent:GetPhysicsObject()
if phys:IsValid() then
    local dist = tr.HitPos:Distance(self.Owner:GetPos())
    phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized()*math.pow(dist,3))
end

cleanup.Add(self.Owner, "props", ent)

undo.Create("HaaxMonitor")
    undo.AddEntity(ent)
    undo.SetPlayer(self.Owner)
    undo.SetCustomUndoText("Undone Haax Monitor")
undo.Finish()

self.Owner:DoAttackEvent()
self.Weapon:SetNextPrimaryFire(CurTime()+0.2)

end

function SWEP:SecondaryAttack()
if (!SERVER) then return end

local props = ents.FindByClass("prop_haax")

if table.Count(props) > 0 then
    self:EmitSound(self.SndHaax)
    
    local tr = self.Owner:GetEyeTrace()
    
    for _,ent in pairs(props) do
        if IsValid(ent.HaaxOwner) && (ent.HaaxOwner == self.Owner) then
            local phys = ent:GetPhysicsObject()
            local pos = ent:GetPos()
            phys:ApplyForceCenter((tr.HitPos-pos)*math.pow(tr.HitPos:Distance(pos),3))
        end
    end
    
    self.Weapon:SetNextSecondaryFire(CurTime()+0.5)
else
    self.Weapon:SetNextSecondaryFire(CurTime()+0.1)
end

end

function SWEP:Reload()
if (!SERVER) then return end

if SERVER && self.Owner:IsAdmin() then
    umsg.Start("HaaxMenu",self.Owner)
        umsg.String(tostring(HaaxSettings.Grav)..","..tostring(HaaxSettings.DmgSelf)..","..tostring(HaaxSettings.RndMdl))
    umsg.End()
end

end

function SWEP:Think() end

function SWEP:ShouldDropOnDie() return false end

– Haax monitor SENT

local ENT = {}
ENT.Type = “anim”
ENT.Base = “base_anim”
ENT.PrintName = “Haax Monitor”
ENT.RenderGroup = RENDERGROUP_TRANSLUCENT

function ENT:Initialize()
if (SERVER) then
if (HaaxSettings.RndMdl) or (math.random(3) == 1) then
self.Entity:SetModel(“models/props_lab/monitor01a.mdl”)
else
self.Entity:SetModel(“models/props_lab/monitor02.mdl”)
self.Entity:SetSkin(math.random(3))
end

    self.Entity:PhysicsInit(SOLID_VPHYSICS)
    self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
    
    local phys = self.Entity:GetPhysicsObject()
    if phys:IsValid() then
         phys:EnableGravity(HaaxSettings.Grav)
         phys:Wake()
    end
end

end

function ENT:Touch(ent)
if ValidEntity(ent) then
if ent:IsPlayer() or (ent:IsNPC() && (ent:GetNPCState()~=NPC_STATE_DEAD)) then
if self:GetPhysicsObject():GetVelocity():Length() > 512 then
ent:TakeDamage(9999,self.Entity,self.Entity)
end
end
end
end

function ENT:Think() end

function ENT:OnRemove()
ParticleEffect(“warp_shield_impact”,self.Entity:GetPos(),Angle(0,0,0),NULL)
end

scripted_ents.Register(ENT,“prop_haax”,true)
[/lua]

But my question is:

Can you trigger to shoot a monitor with a command?

Eg.

ConCommandAdd: “shoothax”
if ply:IsAdmin then (shoot the hax)

if you guys understand what i mean with that?

Thanks :smiley:

Yep, look at line 41 of that code you pasted. Same idea.

But that dont trigger to shoot a monitor right? What i exacly mean is that it shoots a monitor when u enter a command but you need to be admin to use it. Sorry, quite new with this command.

Anybody?

You have to code it.

Yeah but where? I mean the code of shooting something though command, never made something like that before

Too busy right now to do it myself. But this is what you would do…
[lua]

concommand.Add(“HaxShoot”, function(ply,cmd,args)

//code for spawning a monitor and shooting it?

end)

[/lua]

The code for it is in the swep. Just find it.
Code doesn’t go in a clientside file.

So it would be:

[lua]
concommand.Add(“HaxShoot”, function(ply,cmd,args)
if (!SERVER) then return end

if ply:IsAdmin then

self:EmitSound(self.SndHaax)
 
local tr = self.Owner:GetEyeTrace()

local ent = ents.Create("prop_haax")
    ent:SetPos(self.Owner:EyePos()+self.Owner:GetAimVector()*(16+self.Owner:GetVelocity():Length()/64))
    ent:SetAngles(self.Owner:EyeAngles())
    ent.HaaxOwner = self.Owner
    ent.SWEP = self
ent:Spawn()
 
local phys = ent:GetPhysicsObject()
if phys:IsValid() then
    local dist = tr.HitPos:Distance(self.Owner:GetPos())
    phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized()*math.pow(dist,3))
end
 
cleanup.Add(self.Owner, "props", ent)
 
undo.Create("HaaxMonitor")
    undo.AddEntity(ent)
    undo.SetPlayer(self.Owner)
    undo.SetCustomUndoText("Undone Haax Monitor")
undo.Finish()
 
self.Owner:DoAttackEvent()
self.Weapon:SetNextPrimaryFire(CurTime()+0.2)

end)
[/lua]

Maybe a stupid question but where am i suppose to put this shared.lua, Just in lua/weapons ?

The code your using is a console command. Not a swep. Unless you put the code there. It would go in lua/autorun or something of the sorts. Oh, and at the top of the code you should put

[lua] self=ply
self.Owner=ply
[/lua]

and remove line 32 and 31.

edit:

[lua]
concommand.Add(“HaxShoot”, function(ply,cmd,args)
if (!SERVER) then return end
self=ply
self.Owner=ply

if ply:IsAdmin then

self:EmitSound(self.SndHaax)
 
local tr = self.Owner:GetEyeTrace()

local ent = ents.Create("prop_haax")
    ent:SetPos(self.Owner:EyePos()+self.Owner:GetAimVector()*(16+self.Owner:GetVelocity():Length()/64))
    ent:SetAngles(self.Owner:EyeAngles())
    ent.HaaxOwner = ply
    ent.SWEP = self
ent:Spawn()
 
local phys = ent:GetPhysicsObject()
if phys:IsValid() then
    local dist = tr.HitPos:Distance(self.Owner:GetPos())
    phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized()*math.pow(dist,3))
end
 
cleanup.Add(self.Owner, "props", ent)
 
undo.Create("HaaxMonitor")
    undo.AddEntity(ent)
    undo.SetPlayer(self.Owner)
    undo.SetCustomUndoText("Undone Haax Monitor")
undo.Finish()

end)
[/lua]

I have placed the LUA in lua\autorun\server and there it seemed like to see the LUA file, In autorun it dint worked.

But it gave this error: [lua/autorun/server/hax.lua:132] function arguments expected near “then”

This is final code:

[lua]
if CLIENT then
SWEP.PrintName = “Haax!”
SWEP.Author = “Otger”
SWEP.Contact = “”
SWEP.Purpose = “Throw monitors at your enemies! Based on the ‘The Gmod Idiot Box’ YouTube series by DasBoSchitt.”
SWEP.Instructions = “Left click to shoot a monitor. Right click to attack with the spawned monitors. Reload to open the menu.”
SWEP.Slot = 1
SWEP.SlotPos = 3
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = true
end
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.ViewModel = “models/weapons/V_hands.mdl”
SWEP.WorldModel = “models/props_junk/PopCan01a.mdl”

SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = “none”
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = “none”

SWEP.SndSpawn = Sound(“vo/npc/male01/herecomehacks01.wav”)
SWEP.SndHaax = Sound(“vo/npc/male01/hacks01.wav”)

util.PrecacheModel(“models/props_lab/monitor01a.mdl”)
util.PrecacheModel(“models/props_lab/monitor02.mdl”)

if SERVER then
if !HaaxSettings then
HaaxSettings = {}
HaaxSettings.Grav = false
HaaxSettings.DmgSelf = true
HaaxSettings.RndMdl = false
end

concommand.Add("HaaxConfig", function(ply,cmd,args)
    local wep = Entity(tonumber(args[1]))
    if ValidEntity(wep) && wep.IsHaaxSWEP then
        if (ply == wep.Owner) && ply:IsAdmin() then
            wep:HaaxUpdateGravity(tobool(args[2]))
            HaaxSettings.DmgSelf = tobool(args[3])
            wep:HaaxUpdateModels(tobool(args[4]))
        end
    end
end)

concommand.Add("HaaxClear", function(ply,cmd,args)
    local wep = Entity(tonumber(args[1]))
    if ValidEntity(wep) && wep.IsHaaxSWEP then
        if (ply == wep.Owner) && ply:IsAdmin() then
            wep:HaaxClear()
        end
    end
end)
 
local function HaaxOverrideDamage(ent,inflictor,attacker,amount,dmginfo)
    if inflictor:GetClass() == "prop_haax" && ValidEntity(inflictor.SWEP) then
        if ent:IsPlayer() then
            if (inflictor.HaaxOwner == ent) && !HaaxSettings.DmgSelf then
                dmginfo:SetDamage(0)
            end
        end
    end
end
hook.Add("EntityTakeDamage", "HaaxOverrideDamage", HaaxOverrideDamage)
 
function SWEP:HaaxClear()
    local props = ents.FindByClass("prop_haax")
     
    if table.Count(props) > 0 then
        SendUserMessage("HaaxClear", self.Owner)
        for _,ent in pairs(props) do
            if ValidEntity(ent) && ValidEntity(ent.HaaxOwner) && (ent.HaaxOwner == self.Owner) then
                ent:Remove()
            end
        end
    end
end

function SWEP:HaaxUpdateGravity(bGrav)
    if HaaxSettings.Grav ~= bGrav then
        local props = ents.FindByClass("prop_haax")
         
        if table.Count(props) > 0 then
            for _,ent in pairs(props) do
                if ValidEntity(ent) && ValidEntity(ent.HaaxOwner) && (ent.HaaxOwner == self.Owner) then
                    ent:GetPhysicsObject():EnableGravity(bGrav)
                end
            end
        end
    end
    HaaxSettings.Grav = bGrav
end

function SWEP:HaaxUpdateModels(bNotRandom)
    if HaaxSettings.RndMdl ~= bNotRandom then
        local props = ents.FindByClass("prop_haax")
         
        if table.Count(props) > 0 then
            for _,ent in pairs(props) do
                if ValidEntity(ent) && ValidEntity(ent.HaaxOwner) && (ent.HaaxOwner == self.Owner) then
                    if bNotRandom then
                        if ent:GetModel() ~= "models/props_lab/monitor01a.mdl" then
                            ent:SetModel("models/props_lab/monitor01a.mdl")
                        end
                    else
                        if math.random(3) == 1 then
                            ent:SetModel("models/props_lab/monitor01a.mdl")
                        else
                            ent:SetModel("models/props_lab/monitor02.mdl")
                            ent:SetSkin(math.random(3))
                        end
                    end
                end
            end
        end
    end
    HaaxSettings.RndMdl = bNotRandom
end

end

concommand.Add(“ttt_hax”, function(ply,cmd,args)
if (!SERVER) then return end
self=ply
self.Owner=ply

if ply:IsAdmin then

self:EmitSound(self.SndHaax)
  
local tr = self.Owner:GetEyeTrace()

local ent = ents.Create("prop_haax")
    ent:SetPos(self.Owner:EyePos()+self.Owner:GetAimVector()*(16+self.Owner:GetVelocity():Length()/64))
    ent:SetAngles(self.Owner:EyeAngles())
    ent.HaaxOwner = ply
    ent.SWEP = self
ent:Spawn()
  
local phys = ent:GetPhysicsObject()
if phys:IsValid() then
    local dist = tr.HitPos:Distance(self.Owner:GetPos())
    phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized()*math.pow(dist,3))
end
  
cleanup.Add(self.Owner, "props", ent)
  
undo.Create("HaaxMonitor")
    undo.AddEntity(ent)
    undo.SetPlayer(self.Owner)
    undo.SetCustomUndoText("Undone Haax Monitor")
undo.Finish()

end)

if CLIENT then
local HaaxSndRemove = Sound(“buttons/button15.wav”)

killicon.AddFont("prop_haax", "HL2MPTypeDeath", "9", Color(160,160,128,255))
language.Add("prop_haax", "Haax!")

usermessage.Hook("HaaxClear",function(um)
    GAMEMODE:AddNotify("Removed Haax Monitors", NOTIFY_UNDO, 4)
    LocalPlayer():EmitSound(HaaxSndRemove)
end)

usermessage.Hook("HaaxMenu",function(um)
    local wep = LocalPlayer():GetActiveWeapon()
    if wep && wep.IsHaaxSWEP then
        local tData = string.Explode(",",um:ReadString())
        wep:MenuOpen(tData)
    end
end)    

function SWEP:MenuCreate()
    if self.Menu then
        self.Menu:SetVisible(false)
        self.Menu:Remove()
    end
    self.Menu = vgui.Create("DFrame")
        self.Menu:SetName("HaaxMenu")
        self.Menu:SetTitle("Haax! - Settings")
        self.Menu:SetDraggable(true)
        self.Menu:ShowCloseButton(true)
        self.Menu:SetDeleteOnClose(false)
        self.Menu:SetSize(256,192)
        self.Menu:SetVisible(false)
         
        self.Menu.ChkGrav = vgui.Create("DCheckBoxLabel", self.Menu)
            self.Menu.ChkGrav:SetPos(16,32)
            self.Menu.ChkGrav:SetText("Enable gravity")
            self.Menu.ChkGrav:SetTooltip("If checked, the monitors will be affected by the gravity.")
            self.Menu.ChkGrav:SizeToContents()
             
        self.Menu.ChkDmgSelf = vgui.Create("DCheckBoxLabel", self.Menu)
            self.Menu.ChkDmgSelf:SetPos(16,64)
            self.Menu.ChkDmgSelf:SetText("Damage owner")
            self.Menu.ChkDmgSelf:SetTooltip("If checked, the monitors will inflict damage to their owner.")
            self.Menu.ChkDmgSelf:SizeToContents()
             
        self.Menu.ChkRndMdl = vgui.Create("DCheckBoxLabel", self.Menu)
            self.Menu.ChkRndMdl:SetPos(16,96)
            self.Menu.ChkRndMdl:SetText("Disable random models")
            self.Menu.ChkRndMdl:SetTooltip("If checked, all the monitors will have the default model. (Use it in case you see missing textures)")
            self.Menu.ChkRndMdl:SizeToContents()
             
        self.Menu.BtnClear = vgui.Create("DButton", self.Menu)
            self.Menu.BtnClear:SetText("Remove monitors")
            self.Menu.BtnClear:SetPos(16,128)
            self.Menu.BtnClear:SetSize(224,24)
            self.Menu.BtnClear.SWEP = self
            self.Menu.BtnClear.DoClick = function(button)
                RunConsoleCommand("HaaxClear", button.SWEP:EntIndex())
                button.SWEP.Menu:SetVisible(false)
            end
             
        self.Menu.BtnSave = vgui.Create("DButton", self.Menu)
            self.Menu.BtnSave:SetText("Apply settings")
            self.Menu.BtnSave:SetPos(16,160)
            self.Menu.BtnSave:SetSize(224,24)
            self.Menu.BtnSave.SWEP = self
            self.Menu.BtnSave.DoClick = function(button)
                RunConsoleCommand("HaaxConfig",
                    button.SWEP:EntIndex(),
                    tostring(button.SWEP.Menu.ChkGrav:GetChecked()),
                    tostring(button.SWEP.Menu.ChkDmgSelf:GetChecked()),
                    tostring(button.SWEP.Menu.ChkRndMdl:GetChecked())
                )
                GAMEMODE:AddNotify("Haax Settings Applied", NOTIFY_GENERIC, 4)
                LocalPlayer():EmitSound(HaaxSndRemove)
                button.SWEP.Menu:SetVisible(false)
            end
end
 
function SWEP:MenuOpen(tOpts)
    if not self.Menu then
        self:MenuCreate()
    end
    self.Menu.ChkGrav:SetValue(tobool(tOpts[1]) or false)
    self.Menu.ChkDmgSelf:SetValue(tobool(tOpts[2]) or false)
    self.Menu.ChkRndMdl:SetValue(tobool(tOpts[3]) or false)
    self.Menu:SetPos(ScrW()/2-128,ScrH()/2-138)
    self.Menu:SetVisible(true)
    self.Menu:MakePopup()
end

end

function SWEP:Initialize()
self.IsHaaxSWEP = true
self:SetWeaponHoldType(“melee”)
end

function SWEP:OnRemove()
if CLIENT then
if(self.Menu && self.Menu:IsValid()) then
self.Menu:SetVisible(false)
self.Menu:Remove()
end
end
end

function SWEP:Deploy()
if SERVER then
self.Owner:DrawWorldModel(false)
self:EmitSound(self.SndSpawn)
end
return true
end

function SWEP:Holster()
if SERVER then
self.Owner:DrawWorldModel(true)
end
return true
end

function SWEP:PrimaryAttack()
if (!SERVER) then return end

self:EmitSound(self.SndHaax)
 
local tr = self.Owner:GetEyeTrace()

local ent = ents.Create("prop_haax")
    ent:SetPos(self.Owner:EyePos()+self.Owner:GetAimVector()*(16+self.Owner:GetVelocity():Length()/64))
    ent:SetAngles(self.Owner:EyeAngles())
    ent.HaaxOwner = self.Owner
    ent.SWEP = self
ent:Spawn()
 
local phys = ent:GetPhysicsObject()
if phys:IsValid() then
    local dist = tr.HitPos:Distance(self.Owner:GetPos())
    phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized()*math.pow(dist,3))
end
 
cleanup.Add(self.Owner, "props", ent)
 
undo.Create("HaaxMonitor")
    undo.AddEntity(ent)
    undo.SetPlayer(self.Owner)
    undo.SetCustomUndoText("Undone Haax Monitor")
undo.Finish()
 
self.Owner:DoAttackEvent()
self.Weapon:SetNextPrimaryFire(CurTime()+0.2)

end

function SWEP:SecondaryAttack()
if (!SERVER) then return end

local props = ents.FindByClass("prop_haax")
 
if table.Count(props) > 0 then
    self:EmitSound(self.SndHaax)
     
    local tr = self.Owner:GetEyeTrace()
     
    for _,ent in pairs(props) do
        if IsValid(ent.HaaxOwner) && (ent.HaaxOwner == self.Owner) then
            local phys = ent:GetPhysicsObject()
            local pos = ent:GetPos()
            phys:ApplyForceCenter((tr.HitPos-pos)*math.pow(tr.HitPos:Distance(pos),3))
        end
    end
     
    self.Weapon:SetNextSecondaryFire(CurTime()+0.5)
else
    self.Weapon:SetNextSecondaryFire(CurTime()+0.1)
end

end

function SWEP:Reload()
if (!SERVER) then return end

if SERVER && self.Owner:IsAdmin() then
    umsg.Start("HaaxMenu",self.Owner)
        umsg.String(tostring(HaaxSettings.Grav)..","..tostring(HaaxSettings.DmgSelf)..","..tostring(HaaxSettings.RndMdl))
    umsg.End()
end

end

function SWEP:Think() end

function SWEP:ShouldDropOnDie() return false end

– Haax monitor SENT

local ENT = {}
ENT.Type = “anim”
ENT.Base = “base_anim”
ENT.PrintName = “Haax Monitor”
ENT.RenderGroup = RENDERGROUP_TRANSLUCENT

function ENT:Initialize()
if (SERVER) then
if (HaaxSettings.RndMdl) or (math.random(3) == 1) then
self.Entity:SetModel(“models/props_lab/monitor01a.mdl”)
else
self.Entity:SetModel(“models/props_lab/monitor02.mdl”)
self.Entity:SetSkin(math.random(3))
end

    self.Entity:PhysicsInit(SOLID_VPHYSICS)
    self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
     
    local phys = self.Entity:GetPhysicsObject()
    if phys:IsValid() then
         phys:EnableGravity(HaaxSettings.Grav)
         phys:Wake()
    end
end

end

function ENT:Touch(ent)
if ValidEntity(ent) then
if ent:IsPlayer() or (ent:IsNPC() && (ent:GetNPCState()~=NPC_STATE_DEAD)) then
if self:GetPhysicsObject():GetVelocity():Length() > 512 then
ent:TakeDamage(9999,self.Entity,self.Entity)
end
end
end
end

function ENT:Think() end

function ENT:OnRemove()
ParticleEffect(“warp_shield_impact”,self.Entity:GetPos(),Angle(0,0,0),NULL)
end

scripted_ents.Register(ENT,“prop_haax”,true)
[/lua]

It’s IsAdmin()

-snip-

That dint work either

[editline]12th March 2011[/editline]

Anybody know how i can fix this? :l

Try reading the errors, fixing them. You have a lot of errors in that code.

But it doesnt give a LUA error only the one i showed a few posts above?

Are you running this locally or on a server?

Locally for test, it goes on my server when its completely optimized and finished etc.

You should be seeing errors then.

Nope only the error what i had above, but i dont want it as SWEP i want it as that it shoots the monitor through command eg. ttt_hax or shoothax

You have a lot of errors in the code you posted.