if( SERVER ) then AddCSLuaFile( "shared.lua" );endif( CLIENT ) then SWEP.PrintName = "Knock Out"; SWEP.Slot = 1; SWEP.SlotPos = 3; SWEP.DrawAmmo = false; SWEP.DrawCrosshair = false;end// Variables that are used on both client and serverSWEP.Author = "Ben Swanson"SWEP.Instructions = "Left click to knock them out"SWEP.Contact = ""SWEP.Purpose = ""SWEP.ViewModelFOV = 62SWEP.ViewModelFlip = falseSWEP.AnimPrefix = "stunstick"SWEP.Spawnable = falseSWEP.AdminSpawnable = trueSWEP.NextStrike = 0;SWEP.ViewModel = Model( "models/weapons/v_stunstick.mdl" );SWEP.WorldModel = Model( "models/weapons/w_stunbaton.mdl" );SWEP.Sound = Sound( "weapons/stunstick/stunstick_swing1.wav" );SWEP.Primary.ClipSize = -1 // Size of a clipSWEP.Primary.DefaultClip = 0 // Default number of bullets in a clipSWEP.Primary.Automatic = false // Automatic/Semi AutoSWEP.Primary.Ammo = ""SWEP.Secondary.ClipSize = -1 // Size of a clipSWEP.Secondary.DefaultClip = 0 // Default number of bullets in a clipSWEP.Secondary.Automatic = false // Automatic/Semi AutoSWEP.Secondary.Ammo = ""/*--------------------------------------------------------- Name: SWEP:Initialize( ) Desc: Called when the weapon is first loaded---------------------------------------------------------*/function SWEP:Initialize() if( SERVER ) then self:SetWeaponHoldType( "melee" ); endend/*--------------------------------------------------------- Name: SWEP:Precache( ) Desc: Use this function to precache stuff---------------------------------------------------------*/function SWEP:Precache()end/*--------------------------------------------------------- Name: SWEP:PrimaryAttack( ) Desc: +attack1 has been pressed---------------------------------------------------------*/ function SWEP:PrimaryAttack() if( CurTime() < self.NextStrike ) then return; end self.Owner:SetAnimation( PLAYER_ATTACK1 ); self.Weapon:EmitSound( self.Sound ); self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER ); if( CLIENT ) then return; end local trace = self.Owner:GetEyeTrace(); self.NextStrike = ( CurTime() + .4 ); if( not trace.Entity:IsValid() and not trace.Entity:IsPlayer() ) then return; end if( self.Owner:EyePos():Distance( trace.Entity:GetPos() ) > 180 ) then return; end Notify( trace.Entity, 1, 3, "You've been knocked out by " .. self.Owner:Nick() ); local newang = ply:EyeAngles() newang.pitch = 0 newang.roll = 0 newang.yaw = newang.yaw + 180 target:SetPos( newpos ) target:SetEyeAngles( newang ) end