Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.19 KB | None | 0 0
  1. function ENT:OnTakeDamage(dmg)
  2.     local pl = self:GetOwner()
  3.     local attacker = dmg:GetAttacker()
  4.     local inflictor = dmg:GetInflictor()
  5.  
  6.     -- Health
  7.     if pl && pl:IsValid() && pl:Alive() && pl:IsPlayer() && attacker:IsPlayer() && dmg:GetDamage() > 0 then
  8.         self.health = self.health - dmg:GetDamage()
  9.         pl:SetHealth(self.health)
  10.        
  11.         if self.health <= 0 then
  12.             pl:Kill() ----- Changed from KillSilent() to Kill() for the XP system to work properly
  13.            
  14.             if inflictor && inflictor == attacker && inflictor:IsPlayer() then
  15.                 inflictor = inflictor:GetActiveWeapon()
  16.                 if !inflictor || inflictor == NULL then inflictor = attacker end
  17.             end
  18.            
  19.             net.Start( "PlayerKilledByPlayer" )
  20.        
  21.             net.WriteEntity( pl )
  22.             net.WriteString( inflictor:GetClass() )
  23.             net.WriteEntity( attacker )
  24.        
  25.             net.Broadcast()
  26.  
  27.             SimpleXPTrackKills(pl,inflictor,attacker) -- Added for XP system to work properly
  28.             MsgAll( attacker:Nick() .. " killed " .. pl:Nick() .. " using " .. inflictor:GetClass() .. "\n" )
  29.            
  30.             attacker:AddFrags(1)
  31.             pl:AddDeaths(1)
  32.             attacker:SetHealth(math.Clamp(attacker:Health() + GetConVar("HUNTER_KILL_BONUS"):GetInt(), 1, 100))
  33.            
  34.             pl:RemoveProp()
  35.         end
  36.     end
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement