When you get a frag then...

Is there any way to start a command when you get a frag in a gamemode? Like each time you kill a person a sound starts to play? I couldn’t find any function on the wiki that would fit this description.

Gets called when a player dies. You’re looking for the ‘killer’ argument in specific.

So i could do like killer:Kill(), am i right?

Correct

In my gamemode i do

[lua]
/---------------------------------------------------------
Name: gamemode:DoPlayerDeath( )
Desc: Carries out actions when the player dies
---------------------------------------------------------
/
function GM:DoPlayerDeath( ply, attacker, dmginfo )
if ply:Team() == 1 and attacker:Team() == 2 then
local tabs = {“Because Barrels Are Very Fast.”,“Because Barrels Can Sneek Around Like Ninjas”,“With His Uber Pwntage Skills.”}
attacker:SendLua([[surface.PlaySound("/items/battery_pickup.wav")]])
for k, pl in pairs(player.GetAll()) do
pl:PrintMessage(HUD_PRINTTALK, “A Barrel Named “…attacker:Nick()…” Killed A Human Named “…ply:Nick()…” “…table.Random(tabs)…””)
pl:PrintMessage(HUD_PRINTTALK, " “…ply:Nick()…” Is Now A Barrel")
end
ply:SetFrags( 0 )
attacker:AddFrags( 1 )
ply:AddDeaths( 1 )
attacker:AddDeaths( 1 )
attacker:GiveMoney(500)
end
end
[/lua]

and then alot of other stuff that i am not going to give out. but ill give you a taste of what i would do to check the about of frags some one has then run some code if that amount has been reached.

[lua]
/---------------------------------------------------------
Name: gamemode:DoPlayerDeath( )
Desc: Carries out actions when the player dies
---------------------------------------------------------
/
function GM:DoPlayerDeath( ply, attacker, dmginfo )
if attacker:Team() == 1 and attacker:Frags() == 3 then
attacker:Give(“Super_Barrel_Killer”)
attacker:SendLua([[surface.PlaySound("/items/suitchargeok1.wav")]])
for k, pl in pairs(player.GetAll()) do
pl:PrintMessage(HUD_PRINTTALK, “”…attacker:Nick()…" Earned A Super Barrel Killer For Killing 4 Barrels")
end
end
end
[/lua]
this could check if the attackers frags is == to 4 then give him a reward of a better weapon.

first it would check if what i said in the “if” statment is true
[lua]
if attacker:Team() == 1 and attacker:Frags() == 3 then
[/lua]
if its true then it would give the “attacker” a “Super_Barrel_Killer”
[lua]
attacker:Give(“Super_Barrel_Killer”)
[/lua]

then it plays them a nice soothing charm type noise
[lua]
attacker:SendLua([[surface.PlaySound("/items/suitchargeok1.wav")]])
[/lua]

then it tells everyone that got the weapon
[lua]
for k, pl in pairs(player.GetAll()) do
pl:PrintMessage(HUD_PRINTTALK, “”…attacker:Nick()…" Earned A Super Barrel Killer For Killing 4 Barrels")
end
[/lua]

Hope that helps.

Woah! Thankyou! I understand it fully now.

Your welcome, I was glad to help you.