Good afternoon,
I recently started a murder server and I customized it, I changed the names, and several other things. The problem is I changed the weapon models from Magnum to deagle and Knife to TTT knife. So it works great but I have two problems. When I kill someone with the gun or knife the player just disappears… If the player kills an innocent bystander with a gun it also doesn’t drop.
Here is the code for weapon_mu_knife
SWEP.ViewModel = "models/weapons/cstrike/c_knife_t.mdl"
SWEP.WorldModel = "models/weapons/w_knife_t.mdl"
SWEP.PrintName = "Shank"
SWEP.Author = "Zachary Sutton"
SWEP.Contact = ""
SWEP.Purpose = "To kill them bystanders."
SWEP.Instructions = "Weapon: 'CS:S Knife' Melee Attack: 'Left Click' Throw Knife: 'Right Click'"
SWEP.Weight = 0
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.Primary.Delay = 0.5
SWEP.Primary.Recoil = 3
SWEP.Primary.Damage = 120
SWEP.Primary.NumShots = 1
SWEP.Primary.Cone = 0.04
SWEP.Primary.ClipSize = -1
SWEP.Primary.Force = 10
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = true
SWEP.UseHands = true
SWEP.Primary.Ammo = "none"
SWEP.Secondary.Delay = 0.9
SWEP.Secondary.Recoil = 0
SWEP.Secondary.Damage = 0
SWEP.Secondary.NumShots = 1
SWEP.Secondary.Cone = 0
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
function SWEP:GetTrace(ang)
local trace = {}
trace.filter = self.Owner
trace.start = self.Owner:GetShootPos()
trace.mask = MASK_SHOT
local vec = self.Owner:GetAimVector()
if ang then vec:Rotate(ang) end
trace.endpos = trace.start + vec * 60
//trace.mask = MASK_SHOT
local tr = util.TraceLine(trace)
tr.TraceAimVector = vec
tr.TraceAngle = ang
return tr
end
function SWEP:PrimaryAttack()
if self.FistCanAttack then return end
if self.IdleTime && self.IdleTime > CurTime() then return end
self.FistCanAttack = CurTime() + self.Primary.Delay
self.Owner:SetAnimation( PLAYER_ATTACK1 )
self:SendWeaponAnim( ACT_VM_MISSCENTER )
self.FistHit = CurTime() + 0.1
end
function SWEP:SecondaryAttack()
if self.FistCanAttack then return end
if self.IdleTime && self.IdleTime > CurTime() then return end
self.FistCanAttack = CurTime() + self.Primary.Delay
self.Owner:SetAnimation( PLAYER_ATTACK1 )
self:SendWeaponAnim( ACT_VM_HITCENTER )
if SERVER then
local ent = ents.Create("mu_knife")
ent:SetOwner(self.Owner)
ent:SetPos(self.Owner:GetShootPos())
local knife_ang = Angle(-28,0,0) + self.Owner:EyeAngles()
knife_ang:RotateAroundAxis(knife_ang:Right(), -90)
ent:SetAngles(knife_ang)
ent:Spawn()
local phys = ent:GetPhysicsObject()
phys:SetVelocity(self.Owner:GetAimVector() * 1000)
phys:AddAngleVelocity(Vector(0, 1500, 0))
self:Remove()
end
end
function SWEP:Think()
if self.FistCanAttack && self.FistCanAttack < CurTime() then
self.FistCanAttack = nil
self:SendWeaponAnim( ACT_VM_IDLE )
self.IdleTime = CurTime() + 0.1
end
if self.FistHit && self.FistHit < CurTime() then
self.Owner:LagCompensation(true)
self.FistHit = nil
local tr = self:GetTrace()
// aim around
if !tr.Hit then tr = self:GetTrace(Angle(0,20,0)) end
if !tr.Hit then tr = self:GetTrace(Angle(0,-20,0)) end
if !tr.Hit then tr = self:GetTrace(Angle(0,0,20)) end
if !tr.Hit then tr = self:GetTrace(Angle(0,0,-20)) end
if tr.Hit then
self.Owner:ViewPunch(Angle(0, 3, 0))
if IsValid(tr.Entity) then
// only play the sound for the murderer
if CLIENT && LocalPlayer() == self.Owner then
self:EmitSound("Weapon_Crowbar.Melee_Hit")
end
else
self:EmitSound("Weapon_Crowbar.Melee_Hit")
end
local bullet = {} -- Set up the shot
bullet.Num = 1
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = tr.TraceAimVector
bullet.Spread = Vector( 0, 0, 0 )
bullet.Tracer = 0
bullet.Force = self.Primary.Force
bullet.Damage = self.Primary.Damage
self.Owner:FireBullets( bullet )
else
// only play the sound for the murderer
if CLIENT && LocalPlayer() == self.Owner then
self:EmitSound("Weapon_Crowbar.Single")
end
end
self.Owner:LagCompensation(false)
end
end
and the code for weapon_mu_magnum:
if ( SERVER ) then
AddCSLuaFile( "shared.lua" )
else
killicon.AddFont( "weapon_mu_magnum", "HL2MPTypeDeath", "1", Color( 255, 0, 0 ) )
end
SWEP.Base = "weapon_base"
SWEP.PrintName = "Deagle"
SWEP.Slot = 2
SWEP.SlotPos = 1
SWEP.DrawAmmo = true
SWEP.DrawCrosshair = true
SWEP.UseHands = true
SWEP.ViewModelFlip = false
SWEP.ViewModelFOV = 54
SWEP.ViewModel = "models/weapons/cstrike/c_pist_deagle.mdl"
SWEP.WorldModel = "models/weapons/w_pist_deagle.mdl"
SWEP.HoldType = "pistol"
SWEP.PKOneOnly = true
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.Author = "Zachary Sutton"
SWEP.Contact = ""
SWEP.Purpose = "To kill them murders."
SWEP.Instructions = "Weapon: 'Deagle' Shoot: 'Left Click' Reload: 'R'"
SWEP.Icon = "VGUI/ttt/icon_deagle"
SWEP.Primary.Sound = "Weapon_Deagle.Single"
SWEP.Primary.Damage = 120
SWEP.Primary.NumShots = 1
SWEP.Primary.Recoil = 0.9
SWEP.Primary.Cone = 1
SWEP.Primary.Delay = 3
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Tracer = 1
SWEP.Primary.Force = 420
SWEP.Primary.TakeAmmoPerBullet = false
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Primary.ReloadTime = 2.6
SWEP.ReloadFinishedSound = Sound("Weapon_Crossbow.BoltElectrify")
SWEP.ReloadSound = Sound("Weapon_Glock.Reload")
SWEP.Secondary.Sound = ""
SWEP.Secondary.Damage = 10
SWEP.Secondary.NumShots = 1
SWEP.Secondary.Recoil = 1
SWEP.Secondary.Cone = 0
SWEP.Secondary.Delay = 0.25
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Tracer = -1
SWEP.Secondary.Force = 5
SWEP.Secondary.TakeAmmoPerBullet = false
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
if SERVER then
util.AddNetworkString("pkshotguncanattack")
end
function SWEP:Initialize()
self:SetWeaponHoldType( self.HoldType )
self.CanAttack = true
end
function SWEP:BulletCallback(att, tr, dmg)
return {effects = true,damage = true}
end
function SWEP:PrimaryAttack()
if !self.CanAttack then return false end
local bullet = {} -- Set up the shot
bullet.Num = self.Primary.NumShots
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = self.Owner:GetAimVector()
bullet.Spread = Vector( self.Primary.Cone / 90, self.Primary.Cone / 90, 0 )
bullet.Tracer = self.Primary.Tracer
bullet.Force = self.Primary.Force
bullet.Damage = self.Primary.Damage
-- function bullet.Callback(att,tr,dmg)
-- self:BulletCallback(att, tr, dmg)
-- end
self.Owner:FireBullets( bullet )
self:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
self.Owner:SetAnimation( PLAYER_ATTACK1 )
self:EmitSound(Sound(self.Primary.Sound))
self.Owner:ViewPunch(Angle( -self.Primary.Recoil, 0, 0 ))
self.NextLower = CurTime() + 0.4
self.CanAttack = false
// hacky fix for client, don't send immediately
timer.Simple(0, function () if IsValid(self) then self:NetCanAttack() end end)
end
function SWEP:SecondaryAttack()
end
function SWEP:Think()
if self.NextAttack && self.NextAttack < CurTime() then
self.NextAttack = nil
self.CanAttack = true
self:NetCanAttack()
//self:SendWeaponAnim( ACT_VM_IDLE)
//self.Owner:ChatPrint("Cake")
end
if self.NextLower && self.NextLower < CurTime() then
self.NextLower = nil
self.NextUpper = CurTime() + self.Primary.ReloadTime
self:SendWeaponAnim(ACT_VM_RELOAD)
-- self:EmitSound(self.ReloadSound)
local i = math.random(1,3)
if i == 2 then i = 4 end
self:EmitSound("weapons/357/357_reload" .. i .. ".wav")
self.Owner:SetAnimation( PLAYER_RELOAD )
end
if self.NextUpper && self.NextUpper < CurTime() then
self.NextUpper = nil
self.NextAttack = CurTime() + 0.1
-- self:SendWeaponAnim(ACT_VM_IDLE)
-- self:EmitSound(self.ReloadFinishedSound)
end
end
function SWEP:Reload()
end
if CLIENT then
net.Receive("pkshotguncanattack", function (len)
local ent = net.ReadEntity()
local canattack = net.ReadUInt(8)
if IsValid(ent) then
ent.CanAttack = canattack != 0
end
end)
end
function SWEP:NetCanAttack()
if SERVER then
if IsValid(self.Owner) && self.Owner:IsPlayer() then
net.Start("pkshotguncanattack")
net.WriteEntity(self)
net.WriteUInt(self.CanAttack and 1 or 0,8)
net.Send(self.Owner)
end
end
end
function SWEP:Deploy()
if !self.CanAttack then
self.NextAttack = nil
self.NextLower = nil
self.NextUpper = CurTime() + self.Primary.ReloadTime
self:EmitSound(self.ReloadSound)
self:SendWeaponAnim(ACT_VM_RELOAD)
self:NetCanAttack()
end
return true
end
function SWEP:Holster()
return true
end
function SWEP:OnRemove()
end
function SWEP:OnRestore()
end
function SWEP:Precache()
end
function SWEP:OwnerChanged()
end