Can someone make this HealthStation Kill?

Basically, I need someone kind enough to transform the code below - so that when goes in to get health, it kills them instantly :slight_smile:

Ignore the /a’s - i used to for formatting but obviously don’t know how to use it properly lol.

Gamemode > terrortown > entities > weapons > weapon_ttt_healthstation

[lua]
if SERVER then
AddCSLuaFile( “shared.lua” )
end

SWEP.HoldType = “normal”

if CLIENT then
SWEP.PrintName = “Health Station”
SWEP.Slot = 6
SWEP.SlotPos = 0

SWEP.ViewModelFOV = 10

SWEP.EquipMenuData = {
type=“Weapon”,
model=“models/props/cs_office/microwave.mdl”,
desc="Allows people to heal when placed.

Slow recharge. Anyone can use it, and
it can be damaged. Can be checked for
DNA samples of its users."
};

SWEP.Icon = “VGUI/ttt/icon_health”
end

SWEP.Base = “weapon_tttbase”

SWEP.Spawnable = true
SWEP.AdminSpawnable = false
SWEP.ViewModel = “models/weapons/v_crowbar.mdl”
SWEP.WorldModel = “models/props/cs_office/microwave.mdl”
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.DrawCrosshair = true
SWEP.ViewModelFlip = false
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = “none”
SWEP.Primary.Delay = 1.0

SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = true
SWEP.Secondary.Ammo = “none”
SWEP.Secondary.Delay = 1.0

– This is special equipment

SWEP.Kind = WEAPON_EQUIP
SWEP.CanBuy = {ROLE_DETECTIVE} – only detectives can buy
SWEP.LimitedStock = true – only buyable once
SWEP.WeaponID = AMMO_HEALTHSTATION

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
[/lua]

Next this is the file from

Gamemode > terrortown > entities > entities > ttt_healthstation

[lua]

---- Health dispenser

if SERVER then AddCSLuaFile(“shared.lua”) end

if CLIENT then
– this entity can be DNA-sampled so we need some display info
ENT.Icon = “VGUI/ttt/icon_health”
ENT.PrintName = “Health Station”

ENT.TargetIDHint = {
name=“Health Station”,
hint=“USE to receive health. Charge: %d.”,
fmt=function(ent, str)
return Format(str, IsValid(ent) and ent:GetStoredHealth() or 0)
end
};
end

ENT.Type = “anim”
ENT.Model = Model(“models/props/cs_office/microwave.mdl”)

ENT.CanUseKey = true
ENT.CanHavePrints = true
ENT.MaxHeal = 25
ENT.MaxStored = 200
ENT.RechargeRate = 1
ENT.RechargeFreq = 2 – in seconds

AccessorFuncDT(ENT, “StoredHealth”, “StoredHealth”)

function ENT:SetupDataTables()
self:DTVar(“Int”, 0, “StoredHealth”)
end

function ENT:Initialize()
self.Entity:SetModel(self.Model)

self.Entity:PhysicsInit(SOLID_VPHYSICS)
self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
self.Entity:SetSolid(SOLID_VPHYSICS)
self.Entity:SetCollisionGroup(COLLISION_GROUP_NONE)
if SERVER then
self.Entity:SetMaxHealth(200)

  local phys = self.Entity:GetPhysicsObject()
  if IsValid(phys) then
     phys:SetMass(200)
  end

end
self.Entity:SetHealth(200)

self.Entity:SetColor(180, 180, 255, 255)

self:SetStoredHealth(200)

self.fingerprints = {}
end

function ENT:UseOverride(activator)
if ValidEntity(activator) and activator:IsPlayer() and activator:IsActive() then
self:GiveHealth(activator)
end
end

function ENT:AddToStorage(amount)
self:SetStoredHealth(math.min(self.MaxStored, self:GetStoredHealth() + amount))
end

function ENT:TakeFromStorage(amount)
– if we only have 5 healthpts in store, that is the amount we heal
amount = math.min(amount, self:GetStoredHealth())
self:SetStoredHealth(math.max(0, self:GetStoredHealth() - amount))
return amount
end

local healsound = Sound(“items/medshot4.wav”)
local failsound = Sound(“items/medshotno1.wav”)
function ENT:GiveHealth(ply)
if self:GetStoredHealth() > 0 then
local dmg = ply:GetMaxHealth() - ply:Health()
if dmg > 0 then
– constant clamping, no risks
local healed = self:TakeFromStorage(math.min(self.MaxHeal, dmg))
local new = math.min(ply:GetMaxHealth(), ply:Health() + healed)

     ply:SetHealth(new)

     self:EmitSound(healsound)

     if not table.HasValue(self.fingerprints, ply) then
        table.insert(self.fingerprints, ply)
     end
  else
     ply:ChatPrint("Your health is full.")
     self:EmitSound(failsound)
  end

else
ply:ChatPrint(“The health station is empty!”)
self:EmitSound(failsound)
end
end

– traditional equipment destruction effects
local zapsound = Sound(“npc/assassin/ball_zap1.wav”)
function ENT:OnTakeDamage(dmginfo)
self:TakePhysicsDamage(dmginfo)

self:SetHealth(self:Health() - dmginfo:GetDamage())
if self:Health() < 0 then
self:Remove()

  local effect = EffectData()
  effect:SetOrigin(self:GetPos())
  util.Effect("cball_explode", effect)
  WorldSound(zapsound, self:GetPos())

  if IsValid(self:GetOwner()) then
     TraitorMsg(self:GetOwner(), "YOUR HEALTH STATION HAS BEEN DESTROYED!")
  end

end
end

if CLIENT then
– flash effect
local nextflash = 0
function ENT:Think()
if nextflash < CurTime() then
local dlight = CLIENT and DynamicLight(self:EntIndex())
if dlight then
dlight.Pos = self:GetPos()
dlight.r = 0
dlight.g = 0
dlight.b = 255
dlight.Brightness = 1
dlight.Size = 100
dlight.Decay = 120
dlight.DieTime = CurTime() + 0.3
end

     nextflash = CurTime() + 3
  end

end
elseif SERVER then
– recharge
local nextcharge = 0
function ENT:Think()
if nextcharge < CurTime() then
self:AddToStorage(self.RechargeRate)

     nextcharge = CurTime() + self.RechargeFreq
  end

end
end
[/lua]

Is that [/a] in your code?

yes sir :slight_smile:

Why do you have the entity in the weapons folder? You only need 1 entity, then just spawn it.

[editline]04:17PM[/editline]

… Then delete the [/a].

I’m not sure, but you apparently need it… I’m really confused, someone said, I have the entity but I need the entity, which didn’t help that much lol just confused me more!!! :stuck_out_tongue:

Tell me slowly, correctly and precisely what you want done. The weapon is not an entity; it’s a weapon. Anyways, I’m going off for some while, I’ll probabl be back within a few hours or something.

Okay, well basically, it has to mimic the healh station, but instead of healing when you go to it - it should kill you instantly without fail.

http://www.facepunch.com/showthread.php?t=983324