Tough One

Hey, i’m doing a custom TTT weapon for my server and im new to lua coding I was just wondering how can I change this piece of code below so that when someone activates it, to get health via left click, it kills them instantly;

SWEP.AllowDrop = false

SWEP.NoSights = true

function SWEP:OnDrop()
self:Remove()
end

function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self:HealthDrop()
end
function SWEP:SecondaryAttack()
self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
self:HealthDrop()
end

local throwsound = Sound( “Weapon_SLAM.SatchelThrow” )

– ye olde droppe code
function SWEP:HealthDrop()
if SERVER then
local ply = self.Owner
if not ValidEntity(ply) then return end

  if self.Planted then return end

  local vsrc = ply:GetShootPos()
  local vang = ply:GetAimVector()
  local vvel = ply:GetVelocity()
  
  local vthrow = vvel + vang * 200

  local health = ents.Create("ttt_health_station")
  if ValidEntity(health) then
     health:SetPos(vsrc + vang * 10)
     health:SetOwner(ply)
     health:Spawn()

     health:PhysWake()
     local phys = health:GetPhysicsObject()
     if ValidEntity(phys) then
        phys:SetVelocity(vthrow)
     end   
     self:Remove()

     self.Planted = true
  end

end

self.Weapon:EmitSound(throwsound)
end

function SWEP:Reload()
return false
end

function SWEP:OnRemove()
if CLIENT and ValidEntity(self.Owner) and self.Owner == LocalPlayer() and self.Owner:Alive() then
RunConsoleCommand(“lastinv”)
end
end

if CLIENT then
local hudtxt = {text=“Click to place the health station”, font=“TabLarge”, xalign=TEXT_ALIGN_RIGHT}
function SWEP:DrawHUD()
hudtxt.pos = {ScrW() - 80, ScrH() - 80}
draw.Text(hudtxt)
draw.TextShadow(hudtxt, 2)
end
end
– Invisible, same hacks as holstered weapon

local hidden = false
function SWEP:Deploy()
hidden = false
return true
end

function SWEP:DrawWorldModel()
end

function SWEP:DrawWorldModelTranslucent()
end

– not able to do DrawModel stuff in Deploy, so here’s a hack
function SWEP:Think()
if SERVER and not hidden and ValidEntity(self.Owner) and self.Owner:GetActiveWeapon() == self.Weapon then
self.Owner:DrawViewModel(false)
self.Owner:DrawWorldModel(false)
hidden = true
end
end

I understand this might not be tough to people with LUA experience, but it’s certainly tough to me lol! :slight_smile:

You would replace “ttt_health_station” with the name of your fake health station entity, which can also be the old one copy-pasted but with :Kill() used on the activator instead of :SetHealth().

Hey, sorry, I’m abit slow with this, when you say replace :SetHealth(). with :Kill()

I can’t find :SetHealth(). anywhere :S sorry man >.<

Post some of the code for the entity, and please use [lua][/lua] tags :smiley: