You can’t use variables that aren’t defined. The variables defined in the function are victim and killer. The victim would be the same as the target, and the killer would be the same as the attacker. But the code won’t know this itself, you have to instruct it to do so. Note that this hook gets ran every time someone gets hurt, not killed. If you want it to get called only when you would die, you would have to add a check that checks wether or not the player will die if he gets hurt. (Basically check if the health is 1 or something)
[lua]function GM:PlayerShouldTakeDamage( victim, killer )
if victim:Team() == killer:Team() then
print("[GMWarfare] ERROR: " … victim … " tried to hurt " … killer )
print("[GMWarfare] ERROR: " … victim … " and " … killer … " are on the same team!")
print("[GMWarfare]" … killer:Nick() … “hurted” … victim:Nick() … “”)
Also, you made a post some days ago regarding a smooth health regeneration, and you locked the thread before I was able to reply. I made a lot better thing for you to use for regeneration.
[lua]local meta = FindMetaTable(“Player”)
function meta:Regenerate( amount, rate)
if (not (IsValid(self) and self:IsPlayer())) then return end
if self:Health() < amount then
timer.Create(“regenerate_”… self:SteamID(), 0.1 * rate, 0, function()
self:SetHealth( self:Health() + 1 )
if self:Health() == amount then
You use it by doing ply:Regenerate( 100, 0.5 ), which regenerates the players health to 100 with a speed of 0.5, which I found to be a decent speed. I suggest you try out different ones, though.