I want to make a gun for my cops that kick people when they are killed with it. However I cant find a hook for doing something on player death (one that I can use with ANY gamemode so I guess GM:OnPlayerDeath wont do it).
What is a good way to do something when a player dies from that gun?
Please feel free to point out any other mistakes. I know I should set the primary delay using the approperate setting BUT it doesnt do anything. So please point out all mistakes if possible
if SERVER then // This is where the init.lua stuff goes.
//This makes sure clients download the file
AddCSLuaFile ("shared.lua")
//How heavy the SWep is
SWEP.Weight = 5
//Allow automatic switching to/from this weapon when weapons are picked up
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Primary.Damage =10
SWEP.Primary.Delay = 10000
elseif CLIENT then // This is where the cl_init.lua stuff goes
//The name of the SWep, as appears in the weapons tab in the spawn menu(Q Menu)
SWEP.PrintName = "banner 5000"
//Sets the position of the weapon in the switching menu
//(appears when you use the scroll wheel or keys 1-6 by default)
SWEP.Slot = 2
SWEP.SlotPos = 1
//Sets drawing the ammuntion levels for this weapon
SWEP.DrawAmmo = true
//Sets the drawing of the crosshair when this weapon is deployed
SWEP.DrawCrosshair = true
end
SWEP.Author = "MoustacheSpy"
SWEP.Contact = "MoustacheSpy@hotmail.com"
SWEP.Purpose = "A gun that bans people for 60 minutes"
SWEP.Instructions = "shoot people"
SWEP.Category = "Cop stuff"
SWEP.Spawnable = true -- Whether regular players can see it
SWEP.AdminSpawnable = true -- Whether Admins/Super Admins can see it
SWEP.ViewModel = "models/weapons/v_Pistol.mdl" -- This is the model used for clients to see in first person.
SWEP.WorldModel = "models/weapons/w_Pistol.mdl" -- This is the model shown to all other clients and in third-person.
//This determins how big each clip/magazine for the gun is. You can
//set it to -1 to disable the ammo system, meaning primary ammo will
//not be displayed and will not be affected.
SWEP.Primary.ClipSize = 30
//This sets the number of rounds in the clip when you first get the gun. Again it can be set to -1.
SWEP.Primary.DefaultClip = 900
//Obvious. Determines whether the primary fire is automatic. This should be true/false
SWEP.Primary.Automatic = true
//Sets the ammunition type the gun uses, see below for a list of types.
SWEP.Primary.Ammo = "Pistol"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = true
SWEP.Secondary.Ammo = "none"
//When the script loads, the sound ''Metal.SawbladeStick'' will be precached,
//and a local variable with the sound name created.
local ShootSound = Sound("Weapon_Pistol.Single")
status_prim = true
status_sec = true
function resetPrim()
status_prim = true
end
function resetSec()
status_sec = true
end
function SWEP:PrimaryAttack()
if status_prim==true then
//Call the throw attack function, with the office chair model
self:ShootBullet(10,1,0.04);
self:EmitSound("./shot_right.wav")
status_prim = false;
timer.Simple(0.005, resetPrim);
end
end
function SWEP:SecondaryAttack()
if status_sec == true then
self:ShootBullet(14,3,0.00000000001);
self:EmitSound(ShootSound)
self.Owner:ViewPunch( Angle( -5, 0, 0 ) )
status_sec = false;
timer.Simple(0.5, resetSec);
self:GetOwner():ChatPrint(self:GetClass());
end
end
[editline]28th September 2017[/editline]
I changed the sound thing cause it was wrong from me trying things. Sorry I forgot to change it before I posted