Need help coding traitor indicator for a traitor item

SO i found a painstation, that insta kills you when used. Its a Traitor Only item, but the problem is when placed, it doesn’t have a indicator on top of it so other Ts can now that specific health station kills you. I’m looking to see if there is a solution to that by adding some type of code to the painstation SWEP, so that it has the C4 indicator without the timer though.

Im basically trying to replicate the C4 Indicator that all Ts can see through walls and such, use that code for the painstation, but modify it so it only is a indicator and not the timer with the indicator. (If that makes sense.)

All im trying to do is use the C4 indicator code for the painstation, so other Ts know that one specific health station kills you.

Sorry if i explain horrible and repeated, but i didn’t want to be “unclear”.

I’m completely stumped on where to find this indicator / timer code in the C4 Weapon SWEP, to even copy it to the painstation weapon swep.

Painstation SWEP:



if SERVER then
   AddCSLuaFile( "shared.lua" )
	resource.AddFile("materials/vgui/ttt/icon_fon_death_station.vtf")
	resource.AddFile("materials/vgui/ttt/icon_fon_death_station.vmt")
end

SWEP.HoldType = "normal"


if CLIENT then
   SWEP.PrintName = "Death Station"
   SWEP.Slot = 6

   SWEP.ViewModelFOV = 10

   SWEP.EquipMenuData = {
      type = "item_weapon",
      desc = "The Death Station is the opposite of the Health Station, it Kills instead of Healing."
   };

   SWEP.Icon = "VGUI/ttt/icon_fon_death_station"
end

SWEP.Base = "weapon_tttbase"

SWEP.ViewModel          = "models/weapons/v_crowbar.mdl"
SWEP.WorldModel         = "models/props/cs_office/microwave.mdl"

SWEP.DrawCrosshair      = 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

SWEP.Kind = WEAPON_EQUIP
SWEP.CanBuy = {ROLE_TRAITOR} -- Traitor Weapon
SWEP.LimitedStock = true -- True = You can buy only once per round

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" )

-- Original Health Station Drop Code.... With some changes.
function SWEP:HealthDrop()
   if SERVER then
      local ply = self.Owner
      if not IsValid(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_death_station")
      if IsValid(health) then
         health:SetPos(vsrc + vang * 10)
         health:Spawn()

         health:SetPlacer(ply)

         health:PhysWake()
         local phys = health:GetPhysicsObject()
         if IsValid(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 IsValid(self.Owner) and self.Owner == LocalPlayer() and self.Owner:Alive() then
      RunConsoleCommand("lastinv")
   end
end

if CLIENT then
   function SWEP:Initialize()
      self:AddHUDHelp("If someone is with 100hp he can't use the Death Station, only when injured.", nil, true)

      return self.BaseClass.Initialize(self)
   end
end

function SWEP:Deploy()
   if SERVER and IsValid(self.Owner) then
      self.Owner:DrawViewModel(false)
   end
   return true
end

function SWEP:DrawWorldModel()
end

function SWEP:DrawWorldModelTranslucent()
end


Plz, in simpler terms im trying to get the Traitor C4 Indicator that only traitors can see through walls WITHOUT the timer, and have that on the painstation, so traitors know that health station kills you. Is the indicator code in the C4 Swep? Please help!

You need to use grammer and moderate spelling in order to get anything close to an answer :confused:

And what the fuck does your title even mean? ‘A traitor indicator for a traitor item’? Why would you even need that?

He wants there to be an icon over the painstation so other fellow traitors won’t stumble upon it accidentally and use it. His posts reveal what he wants quite clearly. The C4 in TTT does the exact same thing except it also shows the remaining time that the bomb has until it explodes. Like he said, all he wants is an icon such as that to display on the painstation to other traitors.

FYI, you misspelled grammar. :eng101:

I don’t recommend using the same indicator used for other fellow traitors, But I would make a new icon specifically for it. (Maybe a nice skull)
After that, you need to use a code similar to this, in a client script:

[lua]
function DrawPainStationMarker()
local Texture = surface.GetTextureID(“ICON PATH WITH NO EXTENSION”)
local width, height = surface.GetTextureSize(Texture)
local screenpos = v:OBBCenter():ToScreen()

if !LocalPlayer():IsTraitor() then
	return
end

for k, v in pairs (ents.GetAll()) do
	if IsValid(v) and v:GetClass() == "NAME OF THE FOLDER WHERE YOU PUT THE ENTITY LUA FILES" then
		surface.SetDrawColor(255, 255, 255, 255)
		surface.SetTexture(Texture)
		surface.DrawTexturedRect(screenpos.x - (width / 2), screenpos.y  - (height / 2), width, height)
	end
end

end
hook.Add(“HUDPaint”, “PainStations”, DrawPainStationMarker)
[/lua]

Edited it to only show for traitors, no idea how could I do such a mistake.

Notes:

Remember to replace “ICON PATH WITH NO EXTENSION” and “NAME OF THE FOLDER WHERE YOU PUT THE ENTITY LUA FILES”.

More instructions:

Make a file into gamemodes/terrortown/gamemode called “painstation.lua” and put the code I gave you inside it. (Remembering to replace what’s needed)
Open init.lua and add this: AddCSLuaFile(“painstation.lua”) At the beginning of the file
Open cl_init.lua and add this: include(“painstation.lua”) at the beginning of the file

Let me know if this works. Didn’t test it, and can’t even do it anyway.

Wouldn’t that show for everyone?

You are actually right, my bad x3
Edited