TTT Dear sister error.

Hello! I’ve been working on porting of TTT Dear Sister v2 SWEP to TTT. So far I can equip it, however when I try to fire I get greeted with this error:



[ERROR] addons/ttt dear sister/lua/weapons/ttt_dearsister/shared.lua:63: attempt to call global 'TurnOFFEffects' (a nil value)
  1. unknown - addons/ttt dear sister/lua/weapons/ttt_dearsister/shared.lua:63


Been looking around on forums but I can’t find a fix. Here is the code:



---- Example TTT custom weapon

resource.AddFile( "materials/vgui/entities/dearsister.vmt" )
resource.AddFile( "materials/vgui/entities/dearsister_nodrop.vmt" )
resource.AddFile( "materials/vgui/entities/dearsister_rmx.vmt" )
resource.AddFile( "materials/vgui/entities/dearsister_suicide.vmt" )
resource.AddFile( "materials/vgui/entities/dearsister_suicide_rmx.vmt" )
resource.AddFile( "materials/vgui/entities/slowmogun.vmt" )
resource.AddFile( "sound/weapons/dearsister_127089860/dearsister.wav" )
resource.AddFile( "sound/weapons/dearsister_127089860/dearsister_rmx.wav" )

-- First some standard GMod stuff
if SERVER then
   AddCSLuaFile( "shared.lua" )
end

if CLIENT then
   SWEP.PrintName = "Dear Sister"
   SWEP.Slot      = 6 -- add 1 to get the slot number key

   SWEP.ViewModelFOV  = 72
   SWEP.ViewModelFlip = true
end

-- Always derive from weapon_tttbase.
SWEP.Base				= "weapon_tttbase"

--- Standard GMod values

SWEP.HoldType			= "pistol"

SWEP.Primary.Delay       = 0.08
SWEP.Primary.Recoil      = 6
SWEP.Primary.RecoilXRand	= 1.5
SWEP.Primary.RecoilYRand	= 0.1
SWEP.Primary.Automatic   = false
SWEP.Primary.Damage		= 9999999999999999999999
SWEP.Primary.Force		= 9999999999999999999999
SWEP.Primary.Cone        = 0.025
SWEP.Primary.Ammo        = "dearsister"
SWEP.Primary.ClipSize    = 1
SWEP.Primary.ClipMax     = 1
SWEP.Primary.DefaultClip = 1
SWEP.Primary.Sound       = Sound( "weapons/dearsister/dearsister.wav" )

SWEP.IronSightsPos 		= Vector( 5.15, -2, 2.6 )
SWEP.IronSightsAng 		= Vector( 0, 0, 0 )

SWEP.ViewModel			= "models/weapons/v_pist_deagle.mdl"
SWEP.WorldModel			= "models/weapons/w_pist_deagle.mdl"

function SWEP:PrimaryAttack()

	if ( !self:CanPrimaryAttack() ) then return end

	if (SERVER) then
		game.SetTimeScale( 0.1 )
		AdjustTimeScale( 3.2, 1 )
		timer.Simple(1, function() self.Owner:DropWeapon(self.Owner:GetActiveWeapon()) end) --I couldn't fix this line.
	end
--	RunConsoleCommand( "pp_dof", "1" )
	RunConsoleCommand( "pp_motionblur", "1" )
	local TurnOFFEffects( 3.2 )
	
	self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
	self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
	
	if ( !self:CanPrimaryAttack() ) then return end
	self.Weapon:EmitSound( self.Primary.Sound )
	self:CSShootBullet( self.Primary.Damage, self.Primary.Recoil, self.Primary.NumShots, self.Primary.Cone )
	self:TakePrimaryAmmo( 1 )

	self.Owner:ViewPunch( Angle( math.Rand(-self.Primary.RecoilXRand,-self.Primary.RecoilXRand) * self.Primary.Recoil, math.Rand(self.Primary.RecoilYRand,-self.Primary.RecoilYRand) *self.Primary.Recoil, 0 ) )
	
end



--- TTT config values

-- Kind specifies the category this weapon is in. Players can only carry one of
-- each. Can be: WEAPON_... MELEE, PISTOL, HEAVY, NADE, CARRY, EQUIP1, EQUIP2 or ROLE.
-- Matching SWEP.Slot values: 0      1       2     3      4      6       7        8
SWEP.Kind = WEAPON_EQUIP1

-- If AutoSpawnable is true and SWEP.Kind is not WEAPON_EQUIP1/2, then this gun can
-- be spawned as a random weapon. Of course this AK is special equipment so it won't,
-- but for the sake of example this is explicitly set to false anyway.
SWEP.AutoSpawnable = false

-- The AmmoEnt is the ammo entity that can be picked up when carrying this gun.
SWEP.AmmoEnt = "dearsister"

-- CanBuy is a table of ROLE_* entries like ROLE_TRAITOR and ROLE_DETECTIVE. If
-- a role is in this table, those players can buy this.
SWEP.CanBuy = { ROLE_DETECTIVE }

-- InLoadoutFor is a table of ROLE_* entries that specifies which roles should
-- receive this weapon as soon as the round starts. In this case, none.
SWEP.InLoadoutFor = nil

-- If LimitedStock is true, you can only buy one per round.
SWEP.LimitedStock = true

-- If AllowDrop is false, players can't manually drop the gun with Q
SWEP.AllowDrop = true

-- If IsSilent is true, victims will not scream upon death.
SWEP.IsSilent = false

-- If NoSights is true, the weapon won't have ironsights
SWEP.NoSights = false

-- Equipment menu information is only needed on the client
if CLIENT then
   -- Path to the icon material
   SWEP.Icon = "VGUI/ttt/dearsister"

   -- Text shown in the equip menu
   SWEP.EquipMenuData = {
      type = "Weapon",
      desc = "Example custom weapon."
   };
end

-- Tell the server that it should download our icon to clients.
if SERVER then
   -- It's important to give your icon a unique name. GMod does NOT check for
   -- file differences, it only looks at the name. This means that if you have
   -- an icon_ak47, and another server also has one, then players might see the
   -- other server's dumb icon. Avoid this by using a unique name.
   resource.AddFile("materials/VGUI/ttt/dearsister.vmt")
end


Anyone know a possible fix?

local TurnOFFEffects( 3.2 ) this is not valid syntax, nor is that a default function

I have tried removing local and it still provides the same error.

Remove the complete line.
It’s like code_gs said:

Ok so there has been progress. There are no more errors (Had to remove another line) but slow motion lasts forever and no sound is heard.



Failed to load sound "sound\weapons\dearsister\dearsister.wav", file probably missing from disk/repository


I’m sure I have it in the right place, I even checked the server files. I’m not sure how to fix the forever slowmotion issue, here is the current code.



---- Example TTT custom weapon

resource.AddFile( "materials/vgui/entities/dearsister.vmt" )
resource.AddFile( "materials/vgui/entities/dearsister_nodrop.vmt" )
resource.AddFile( "materials/vgui/entities/dearsister_rmx.vmt" )
resource.AddFile( "materials/vgui/entities/dearsister_suicide.vmt" )
resource.AddFile( "materials/vgui/entities/dearsister_suicide_rmx.vmt" )
resource.AddFile( "materials/vgui/entities/slowmogun.vmt" )
resource.AddFile( "sound/weapons/dearsister_127089860/dearsister.wav" )
resource.AddFile( "sound/weapons/dearsister_127089860/dearsister_rmx.wav" )

-- First some standard GMod stuff
if SERVER then
   AddCSLuaFile( "shared.lua" )
end

if CLIENT then
   SWEP.PrintName = "Dear Sister"
   SWEP.Slot      = 6 -- add 1 to get the slot number key

   SWEP.ViewModelFOV  = 72
   SWEP.ViewModelFlip = true
end

-- Always derive from weapon_tttbase.
SWEP.Base				= "weapon_tttbase"

--- Standard GMod values

SWEP.HoldType			= "pistol"

SWEP.Primary.Delay       = 0.08
SWEP.Primary.Recoil      = 6
SWEP.Primary.RecoilXRand	= 1.5
SWEP.Primary.RecoilYRand	= 0.1
SWEP.Primary.Automatic   = false
SWEP.Primary.Damage		= 9999999999999999999999
SWEP.Primary.Force		= 9999999999999999999999
SWEP.Primary.Cone        = 0.025
SWEP.Primary.Ammo        = "dearsister"
SWEP.Primary.ClipSize    = 1
SWEP.Primary.ClipMax     = 1
SWEP.Primary.DefaultClip = 1
SWEP.Primary.Sound       = "sound/weapons/dearsister/dearsister.wav"

SWEP.IronSightsPos 		= Vector( 5.15, -2, 2.6 )
SWEP.IronSightsAng 		= Vector( 0, 0, 0 )

SWEP.ViewModel			= "models/weapons/v_pist_deagle.mdl"
SWEP.WorldModel			= "models/weapons/w_pist_deagle.mdl"

function SWEP:PrimaryAttack()

	if ( !self:CanPrimaryAttack() ) then return end

	if (SERVER) then
		game.SetTimeScale( 0.1 )
		AdjustTimeScale( 3.2, 1 )
		timer.Simple(1, function() self.Owner:DropWeapon(self.Owner:GetActiveWeapon()) end) --I couldn't fix this line.
	end
--	RunConsoleCommand( "pp_dof", "1" )
	RunConsoleCommand( "pp_motionblur", "1" )
	
	self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
	self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
	
	if ( !self:CanPrimaryAttack() ) then return end
	self.Weapon:EmitSound( self.Primary.Sound )
	self:TakePrimaryAmmo( 1 )

	self.Owner:ViewPunch( Angle( math.Rand(-self.Primary.RecoilXRand,-self.Primary.RecoilXRand) * self.Primary.Recoil, math.Rand(self.Primary.RecoilYRand,-self.Primary.RecoilYRand) *self.Primary.Recoil, 0 ) )
	
end



--- TTT config values

-- Kind specifies the category this weapon is in. Players can only carry one of
-- each. Can be: WEAPON_... MELEE, PISTOL, HEAVY, NADE, CARRY, EQUIP1, EQUIP2 or ROLE.
-- Matching SWEP.Slot values: 0      1       2     3      4      6       7        8
SWEP.Kind = WEAPON_EQUIP1

-- If AutoSpawnable is true and SWEP.Kind is not WEAPON_EQUIP1/2, then this gun can
-- be spawned as a random weapon. Of course this AK is special equipment so it won't,
-- but for the sake of example this is explicitly set to false anyway.
SWEP.AutoSpawnable = false

-- The AmmoEnt is the ammo entity that can be picked up when carrying this gun.
SWEP.AmmoEnt = "dearsister"

-- CanBuy is a table of ROLE_* entries like ROLE_TRAITOR and ROLE_DETECTIVE. If
-- a role is in this table, those players can buy this.
SWEP.CanBuy = { ROLE_DETECTIVE }

-- InLoadoutFor is a table of ROLE_* entries that specifies which roles should
-- receive this weapon as soon as the round starts. In this case, none.
SWEP.InLoadoutFor = nil

-- If LimitedStock is true, you can only buy one per round.
SWEP.LimitedStock = true

-- If AllowDrop is false, players can't manually drop the gun with Q
SWEP.AllowDrop = true

-- If IsSilent is true, victims will not scream upon death.
SWEP.IsSilent = false

-- If NoSights is true, the weapon won't have ironsights
SWEP.NoSights = false

-- Equipment menu information is only needed on the client
if CLIENT then
   -- Path to the icon material
   SWEP.Icon = "VGUI/ttt/dearsister"

   -- Text shown in the equip menu
   SWEP.EquipMenuData = {
      type = "Weapon",
      desc = "Example custom weapon."
   };
end

-- Tell the server that it should download our icon to clients.
if SERVER then
   -- It's important to give your icon a unique name. GMod does NOT check for
   -- file differences, it only looks at the name. This means that if you have
   -- an icon_ak47, and another server also has one, then players might see the
   -- other server's dumb icon. Avoid this by using a unique name.
   resource.AddFile("materials/VGUI/ttt/dearsister.vmt")
end


dearsister_127089860 is not dearsister

The TurnOFFEffects function probably reset the timescale, instead of removing the line you need to find the function

You were right, it used it’s own base so I had to grab some of the functions from there and add it to the swep. it works great now! Code below for anyone interested in trying it. (Audio and other files not included)



---- Example TTT custom weapon

resource.AddFile( "materials/vgui/entities/dearsister.vmt" )
resource.AddFile( "materials/vgui/entities/dearsister_nodrop.vmt" )
resource.AddFile( "materials/vgui/entities/dearsister_rmx.vmt" )
resource.AddFile( "materials/vgui/entities/dearsister_suicide.vmt" )
resource.AddFile( "materials/vgui/entities/dearsister_suicide_rmx.vmt" )
resource.AddFile( "materials/vgui/entities/slowmogun.vmt" )
resource.AddFile( "sound/weapons/dearsister/dearsister.wav" )
resource.AddFile( "sound/weapons/dearsister_127089860/dearsister_rmx.wav" )

-- First some standard GMod stuff
if SERVER then
   AddCSLuaFile( "shared.lua" )
end

if CLIENT then
   SWEP.PrintName = "Dear Sister"
   SWEP.Slot      = 6 -- add 1 to get the slot number key

   SWEP.ViewModelFOV  = 72
   SWEP.ViewModelFlip = true
end

-- Always derive from weapon_tttbase.
SWEP.Base				= "weapon_tttbase"

--- Standard GMod values

SWEP.HoldType			= "pistol"

SWEP.Primary.Delay       = 0.08
SWEP.Primary.Recoil      = 6
SWEP.Primary.RecoilXRand	= 1.5
SWEP.Primary.RecoilYRand	= 0.1
SWEP.Primary.Automatic   = false
SWEP.Primary.Damage		= 9999999999999999999999
SWEP.Primary.Force		= 9999999999999999999999
SWEP.Primary.Cone        = 0.025
SWEP.Primary.Ammo        = "dearsister"
SWEP.Primary.ClipSize = 1
SWEP.Primary.ClipMax = 1
SWEP.Primary.DefaultClip = 1
SWEP.Primary.Sound       = Sound( "weapons/dearsister/dearsister.wav" )

SWEP.IronSightsPos 		= Vector( 5.15, -2, 2.6 )
SWEP.IronSightsAng 		= Vector( 0, 0, 0 )

SWEP.ViewModel			= "models/weapons/v_pist_deagle.mdl"
SWEP.WorldModel			= "models/weapons/w_pist_deagle.mdl"

function SWEP:PrimaryAttack()

	if ( !self:CanPrimaryAttack() ) then return end

	if (SERVER) then
		game.SetTimeScale( 0.1 )
		AdjustTimeScale( 3.2, 1 )
		timer.Simple(1, function() self.Owner:DropWeapon(self.Owner:GetActiveWeapon()) end) --I couldn't fix this line.
	end
--	RunConsoleCommand( "pp_dof", "1" )
	RunConsoleCommand( "pp_motionblur", "1" )
	TurnOFFEffects( 3.2 )
	
	self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
	self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
	
	if ( !self:CanPrimaryAttack() ) then return end
	self.Weapon:EmitSound( self.Primary.Sound )
	self:CSShootBullet( self.Primary.Damage, self.Primary.Recoil, self.Primary.NumShots, self.Primary.Cone )
	self:TakePrimaryAmmo( 1 )

	self.Owner:ViewPunch( Angle( math.Rand(-self.Primary.RecoilXRand,-self.Primary.RecoilXRand) * self.Primary.Recoil, math.Rand(self.Primary.RecoilYRand,-self.Primary.RecoilYRand) *self.Primary.Recoil, 0 ) )
	
end

function AdjustTimeScale( t, s )
	timer.Simple( t, function() game.SetTimeScale( s ) end )
end

function SWEP:Reload()
	self.Weapon:DefaultReload( ACT_VM_RELOAD );
	self:SetIronsights( false )
	if ( SERVER ) then self.Owner:CrosshairEnable() end
end

function SWEP:Deploy()

--	self.Owner:ConCommand("pp_dof_initlength 256
")
--	self.Owner:ConCommand("pp_dof_spacing 512
")
	RunConsoleCommand( "pp_motionblur_addalpha", "0.2") 
	RunConsoleCommand( "pp_motionblur_delay", "0.0")
	RunConsoleCommand( "pp_motionblur_drawalpha", "1")
	if ( SERVER ) and ( self.Weapon:GetNetworkedBool( "Ironsights" ) ) then self.Owner:CrosshairDisable() end
	return true
	
end

function AdjustAngles( t, r )
	local function GetEyeAngles()
		local n = LocalPlayer():EyeAngles()
		return n
	end
	hook.Add( "GetEyeAngles", GetEyeAngles)
	timer.Simple( t, function() 
	LocalPlayer():SetEyeAngles( Angle( GetEyeAngles().pitch, GetEyeAngles().yaw, r ) ) end)
end

function SWEP:CSShootBullet( dmg, recoil, numbul, cone )

	numbul 	= numbul 	or 1
	cone 	= cone 		or 0.01

	local bullet = {}
	bullet.Num 		= numbul
	bullet.Src 		= self.Owner:GetShootPos()			// Source
	bullet.Dir 		= self.Owner:GetAimVector()			// Dir of bullet
	bullet.Spread 	= Vector( cone, cone, 0 )			// Aim Cone
	bullet.Tracer	= self.TracerFreq					// Show a tracer on every x bullets 
	bullet.Force	= self.ForceApply					// Amount of force to give to phys objects
	bullet.Damage	= dmg
	
	self.Owner:FireBullets( bullet )
	self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) 		// View model animation
	self.Owner:MuzzleFlash()								// Crappy muzzle light
	self.Owner:SetAnimation( PLAYER_ATTACK1 )				// 3rd Person Animation

end



function TurnOFFEffects( t )
	timer.Simple( t, function() RunConsoleCommand( "pp_motionblur", "0" ) end )
--	timer.Simple( t, function() RunConsoleCommand( "pp_dof", "0" ) end )
end



--- TTT config values

-- Kind specifies the category this weapon is in. Players can only carry one of
-- each. Can be: WEAPON_... MELEE, PISTOL, HEAVY, NADE, CARRY, EQUIP1, EQUIP2 or ROLE.
-- Matching SWEP.Slot values: 0      1       2     3      4      6       7        8
SWEP.Kind = WEAPON_EQUIP1

-- If AutoSpawnable is true and SWEP.Kind is not WEAPON_EQUIP1/2, then this gun can
-- be spawned as a random weapon. Of course this AK is special equipment so it won't,
-- but for the sake of example this is explicitly set to false anyway.
SWEP.AutoSpawnable = false

-- The AmmoEnt is the ammo entity that can be picked up when carrying this gun.
SWEP.AmmoEnt = "dearsister"

-- CanBuy is a table of ROLE_* entries like ROLE_TRAITOR and ROLE_DETECTIVE. If
-- a role is in this table, those players can buy this.
SWEP.CanBuy = { ROLE_DETECTIVE }

-- InLoadoutFor is a table of ROLE_* entries that specifies which roles should
-- receive this weapon as soon as the round starts. In this case, none.
SWEP.InLoadoutFor = nil

-- If LimitedStock is true, you can only buy one per round.
SWEP.LimitedStock = true

-- If AllowDrop is false, players can't manually drop the gun with Q
SWEP.AllowDrop = true

-- If IsSilent is true, victims will not scream upon death.
SWEP.IsSilent = false

-- If NoSights is true, the weapon won't have ironsights
SWEP.NoSights = false

-- Equipment menu information is only needed on the client
if CLIENT then
   -- Path to the icon material
   SWEP.Icon = "VGUI/ttt/dearsister"

   -- Text shown in the equip menu
   SWEP.EquipMenuData = {
      type = "Weapon",
      desc = "Example custom weapon."
   };
end

-- Tell the server that it should download our icon to clients.
if SERVER then
   -- It's important to give your icon a unique name. GMod does NOT check for
   -- file differences, it only looks at the name. This means that if you have
   -- an icon_ak47, and another server also has one, then players might see the
   -- other server's dumb icon. Avoid this by using a unique name.
   resource.AddFile("materials/VGUI/ttt/dearsister.vmt")
end