Help me fix this TTT weapon

This is a pain station that i have been working on but it’s not working does someone know why?


if SERVER then
   AddCSLuaFile( "shared.lua" )
end

SWEP.HoldType = "normal"


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

   SWEP.ViewModelFOV = 10

   SWEP.EquipMenuData = {
      type="item_weapon",
      model="models/props/cs_office/microwave.mdl",
      desc="If someone uses this health station, they will be damaged."
   };

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

SWEP.Base = "weapon_tttbase"

SWEP.Spawnable          = true
SWEP.AdminSpawnable     = false

SWEP.ViewModel          = "models/props/cs_office/microwave.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_TRAITOR } -- only traitors can buy
SWEP.LimitedStock = true -- only buyable once
SWEP.WeaponID = AMMO_PAINSTATION

SWEP.AllowDrop = false

SWEP.NoSights = true

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

function SWEP:PrimaryAttack()
   self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
   self:HealthDrop(60000)
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_pain_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 IsValid(self.Owner) and self.Owner == LocalPlayer() and self.Owner:Alive() then
      RunConsoleCommand("lasting")
   end
end

if CLIENT then
   local hudtxt = {text="Click to place the pain 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

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

What do you mean by “not working”. Be specific please.

it won’t place on the ground when you left click

Instead of ValidEntity, use IsValid.

where?

Just ctrl+f to find it, or if you’re using Notepad++, use the replace command.

It’s all under the – ye olde droppe code

ok

[editline]14th June 2013[/editline]

na it didn’t work

Could you post what your code looks like now? Also check for any Lua errors in the server console.

There are no lua errors and i rollback the changes so that what it looks like now

in GMod 13, ValidEntity was replaced with IsValid so the changes I mentioned are required and should throw a Lua error.

Try typing “lua_log_sv 1” in the server console and reproduce the problem. After you do that, in the garrysmod/ folder you should see “lua_errors_server.txt” and/or “clientside_errors.txt”. Post the contents of both (or just one if there is only one).

ok

there are no errors