Vulcan Problem - TTT

So I am developing a vulcan for my friend’s server and for some reason I get some errors. Im trying to put into the damagelogs after the timer has ended that it shows that he didn’t suicide but he died from a vulcan suicide.



if SERVER then
   AddCSLuaFile( "shared.lua" )
end
    
SWEP.HoldType = "knife"

if CLIENT then

   SWEP.PrintName    = "Vulcan"
   SWEP.Slot         = 6
  
   SWEP.ViewModelFlip = false

   SWEP.EquipMenuData = {
      type = "Weaponry	",
      desc = "Shoot the fuckers"
   };

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

SWEP.Base               = "weapon_tttbase"

SWEP.UseHands			= true
SWEP.ViewModelFlip		= false
SWEP.ViewModelFOV		= 54
SWEP.ViewModel          = "models/weapons/v_minigun.mdl"
SWEP.WorldModel         = "models/weapons/w_minigun.mdl"

SWEP.DrawCrosshair      = false
SWEP.Primary.Damage         = 21
SWEP.Primary.ClipSize       = 1000
SWEP.Primary.DefaultClip    = 1000
SWEP.Primary.Automatic      = true
SWEP.Primary.Delay = 0.1
SWEP.Primary.Ammo       = "none"
SWEP.Primary.Recoil = 5
SWEP.Secondary.ClipSize     = -1
SWEP.Secondary.DefaultClip  = -1
SWEP.Secondary.Automatic    = true
SWEP.Secondary.Ammo     = "none"
SWEP.Secondary.Delay = 1.4
SWEP.Primary.Sound = Sound( "weapons/p90_mini/p90-1.wav" )

SWEP.Kind = WEAPON_EQUIP
SWEP.CanBuy = {ROLE_TRAITOR} -- only traitors can buy
SWEP.LimitedStock = true -- only buyable once
SWEP.WeaponID = AMMO_VULCAN

SWEP.IsSilent = true

-- Pull out faster than standard guns
SWEP.DeploySpeed = 5

function Kill( ply )
RunConsoleCommand("kill")
DamageLog( string.format( "VULCAN: %s died due to a vulcan suicide!", ply:Nick() ) )
end
timer.Create( "KillTimer", 60, 1, Kill )

SWEP.AllowDrop = false

if CLIENT then
   function SWEP:Initialize()
          chat.AddText(
 	Color(0,255,0),	"[INFO]",
		Color(255,0,0), "WARNING: Someone has a vulcanic eruption happening!!")
   end
end

resource.AddFile("sound/weapons/p90_mini/p90-1.wav")




Also my errors:



[ERROR] gamemodes/terrortown/entities/weapons/weapon_ttt_minigun/shared.lua:58: attempt to index local 'ply' (a nil value)
  1. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_minigun/shared.lua:58


Any help is appreciated.

replace: [lua]timer.Create( “KillTimer”, 60, 1, Kill )[/lua]

with

[lua]timer.Create( “KillTimer”, 60, 1, function( )
if ( SERVER ) then
self.Owner( ):Kill( );
DamageLog( string.format( “VULCAN: %s died due to a vulcan suicide!”, self.Owner:Nick() ) )
end
end );[/lua]

Get rid of the Kill function, anyone can bypass it by typing alias kill “say BLAH” in console.

Thanks - But now after the 60 seconds I don’t die. No errors at all.

Try putting [lua]local self.Owner() = ply[/lua] before creating the timer
then running Kill() with ply instead. But I’m not sure if that causes any difference



[ERROR] gamemodes/terrortown/entities/weapons/weapon_ttt_minigun/shared.lua:56: unexpected symbol near '.'
  1. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_minigun/shared.lua:0

Here is my current code:



if SERVER then
   AddCSLuaFile( "shared.lua" )
end
    
SWEP.HoldType = "knife"

if CLIENT then

   SWEP.PrintName    = "Vulcan"
   SWEP.Slot         = 6
  
   SWEP.ViewModelFlip = false

   SWEP.EquipMenuData = {
      type = "Weaponry	",
      desc = "Shoot the fuckers"
   };

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

SWEP.Base               = "weapon_tttbase"

SWEP.UseHands			= true
SWEP.ViewModelFlip		= false
SWEP.ViewModelFOV		= 54
SWEP.ViewModel          = "models/weapons/v_minigun.mdl"
SWEP.WorldModel         = "models/weapons/w_minigun.mdl"

SWEP.DrawCrosshair      = false
SWEP.Primary.Damage         = 21
SWEP.Primary.ClipSize       = 1000
SWEP.Primary.DefaultClip    = 1000
SWEP.Primary.Automatic      = true
SWEP.Primary.Delay = 0.1
SWEP.Primary.Ammo       = "none"
SWEP.Primary.Recoil = 5
SWEP.Secondary.ClipSize     = -1
SWEP.Secondary.DefaultClip  = -1
SWEP.Secondary.Automatic    = true
SWEP.Secondary.Ammo     = "none"
SWEP.Secondary.Delay = 1.4
SWEP.Primary.Sound = Sound( "weapons/p90_mini/p90-1.wav" )

SWEP.Kind = WEAPON_EQUIP
SWEP.CanBuy = {ROLE_TRAITOR} -- only traitors can buy
SWEP.LimitedStock = true -- only buyable once
SWEP.WeaponID = AMMO_VULCAN

SWEP.IsSilent = true

-- Pull out faster than standard guns
SWEP.DeploySpeed = 5

local self.Owner() = ply

timer.Create( "KillTimer", 60, 1, function( )
	if ( SERVER ) then
		ply:Kill();
		DamageLog( string.format( "VULCAN: %s died due to a vulcan suicide!", self.Owner:Nick() ) )
	end
end );

SWEP.AllowDrop = false

if CLIENT then
   function SWEP:Initialize()
          chat.AddText(
 	Color(0,255,0),	"[INFO]",
		Color(255,0,0), "WARNING: Someone has caused a vulcan eruption!")
   end
end

resource.AddFile("sound/weapons/p90_mini/p90-1.wav")




My bad, I messed up.

This should work:

Also might as well not make the timer for CLIENT as it serves no purpose.
[lua]if ( SERVER ) then
timer.Create( “KillTimer”, 60, 1, function( )
self.Owner:Kill( );
DamageLog( string.format( “VULCAN: %s died due to a vulcan suicide!”, self.Owner:Nick() ) )
end );
end[/lua]

I accidentally added parens to self.Owner…



[ERROR] gamemodes/terrortown/entities/weapons/weapon_ttt_minigun/shared.lua:58: attempt to index global 'self' (a nil value)
  1. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_minigun/shared.lua:58

Timer Failed! [KillTimer][@gamemodes/terrortown/entities/weapons/weapon_ttt_minigun/shared.lua (line 57)]

My current code:



if SERVER then
   AddCSLuaFile( "shared.lua" )
end
    
SWEP.HoldType = "smg"

if CLIENT then

   SWEP.PrintName    = "Vulcan"
   SWEP.Slot         = 6
  
   SWEP.ViewModelFlip = false

   SWEP.EquipMenuData = {
      type = "Weaponry	",
      desc = "Shoot the fuckers"
   };

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

SWEP.Base               = "weapon_tttbase"

SWEP.UseHands			= true
SWEP.ViewModelFlip		= false
SWEP.ViewModelFOV		= 54
SWEP.ViewModel          = "models/weapons/v_minigun.mdl"
SWEP.WorldModel         = "models/weapons/w_minigun.mdl"

SWEP.DrawCrosshair      = false
SWEP.Primary.Damage         = 21
SWEP.Primary.ClipSize       = 1000
SWEP.Primary.DefaultClip    = 1000
SWEP.Primary.Automatic      = true
SWEP.Primary.Delay = 0.1
SWEP.Primary.Ammo       = "none"
SWEP.Primary.Recoil = 5
SWEP.Secondary.ClipSize     = -1
SWEP.Secondary.DefaultClip  = -1
SWEP.Secondary.Automatic    = true
SWEP.Secondary.Ammo     = "none"
SWEP.Secondary.Delay = 1.4
SWEP.Primary.Sound = Sound( "weapons/p90_mini/p90-1.wav" )

SWEP.Kind = WEAPON_EQUIP
SWEP.CanBuy = {ROLE_TRAITOR} -- only traitors can buy
SWEP.LimitedStock = true -- only buyable once
SWEP.WeaponID = AMMO_VULCAN

SWEP.IsSilent = true

-- Pull out faster than standard guns
SWEP.DeploySpeed = 5

if ( CLIENT ) then
	timer.Create( "KillTimer", 60, 1, function( )
		self.Owner:Kill( );
		DamageLog( string.format( "VULCAN: %s died due to a vulcan suicide!", self.Owner:Nick() ) )
	end );
end

SWEP.AllowDrop = false

if CLIENT then
   function SWEP:Initialize()
          chat.AddText(
 	Color(0,255,0),	"[INFO]",
		Color(255,0,0), "WARNING: Someone has caused a vulcan eruption!")
   end
end

resource.AddFile("sound/weapons/p90_mini/p90-1.wav")




I tried both ‘if ( SERVER ) then’ and ‘if ( CLIENT ) then’

Leave it as SERVER because the CLIENT can not :Kill( )

self doesn’t exist because you aren’t calling the timer in a function and it will run as soon as the weapon code is created; not when the player has it.

You can use Initialize, or Deploy. I used deploy here. If you use initialize, remove your CLIENT tags wrapping it, and use

[lua]if ( SERVER ) then
my code
else
your client code
end[/lua]

[lua]function SWEP:Deploy()
if ( SERVER ) then
timer.Create( “KillTimer”, 60, 1, function( )
self.Owner:Kill( );
DamageLog( string.format( “VULCAN: %s died due to a vulcan suicide!”, self.Owner:Nick() ) )
end );
end
end

function SWEP:Holster()
return false;
end[/lua]

Okay so - The kill function does work but the Damagelog does not!


 *** Damage log:

01:04.41 - KILL:	 Xenomorph God [Bastard] [innocent] killed Xenomorph God [Bastard] [innocent]
*** Damage log end.


Also my current code is here:




if SERVER then
   AddCSLuaFile( "shared.lua" )
end
    
SWEP.HoldType = "smg"

if CLIENT then

   SWEP.PrintName    = "Vulcan"
   SWEP.Slot         = 6
  
   SWEP.ViewModelFlip = false

   SWEP.EquipMenuData = {
      type = "Weaponry	",
      desc = "Shoot the fuckers"
   };

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

SWEP.Base               = "weapon_tttbase"

SWEP.UseHands			= true
SWEP.ViewModelFlip		= false
SWEP.ViewModelFOV		= 54
SWEP.ViewModel          = "models/weapons/v_minigun.mdl"
SWEP.WorldModel         = "models/weapons/w_minigun.mdl"

SWEP.DrawCrosshair      = false
SWEP.Primary.Damage         = 21
SWEP.Primary.ClipSize       = 1000
SWEP.Primary.DefaultClip    = 1000
SWEP.Primary.Automatic      = true
SWEP.Primary.Delay = 0.1
SWEP.Primary.Ammo       = "none"
SWEP.Primary.Recoil = 5
SWEP.Secondary.ClipSize     = -1
SWEP.Secondary.DefaultClip  = -1
SWEP.Secondary.Automatic    = true
SWEP.Secondary.Ammo     = "none"
SWEP.Secondary.Delay = 1.4
SWEP.Primary.Sound = Sound( "weapons/p90_mini/p90-1.wav" )

SWEP.Kind = WEAPON_EQUIP
SWEP.CanBuy = {ROLE_TRAITOR} -- only traitors can buy
SWEP.LimitedStock = true -- only buyable once
SWEP.WeaponID = AMMO_VULCAN

SWEP.IsSilent = true

-- Pull out faster than standard guns
SWEP.DeploySpeed = 5
SWEP.AllowDrop = false

if CLIENT then
   function SWEP:Initialize()
          chat.AddText(
 	Color(0,255,0),	"[INFO]",
		Color(255,0,0), "WARNING: Someone has caused a vulcan eruption!")
   end
end

resource.AddFile("sound/weapons/p90_mini/p90-1.wav")


function SWEP:Deploy()
	if ( SERVER ) then
		timer.Create( "KillTimer", 60, 1, function( )
			self.Owner:Kill( );
			DamageLog( string.format( "VULCAN: %s died due to a vulcan suicide!", self.Owner:Nick() ) )
		end );
	end
end

function SWEP:Holster()
	return false;
end


You don’t need WeaponID

Will this fix the damagelog?

No, I doubt it, but the custom weapon creation tutorial on the ttt website says they shouldn’t. Not sure why