Advertisement
Guest User

Untitled

a guest
Jan 14th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.52 KB | None | 0 0
  1.     -- function for transferring the damage done to the corpse onto the player
  2.     local function transferDamage(ent, dmginfo)
  3.         if ent.sid then -- check for nil value
  4.             local ply = player.GetBySteamID(ent.sid)
  5.             if IsValid(ply) and (ent == ply.fake_corpse) then
  6.                 if (dmginfo:GetDamage() < 0) then
  7.                     dmginfo:ScaleDamage(-1)
  8.                 end
  9.                 if (dmginfo:GetDamage() < 150) then -- if this blow is not lethal
  10.                     dmginfo:SetDamage(0) -- make sure it don't hurt
  11.                     end
  12.                 if (dmginfo:GetDamage() > 150) then -- if this blow is going to be lethal
  13.                     dmginfo:SetDamage(1000) -- make sure it actually kills him, weird things can happen
  14.                     ply:SetPos(ent:LocalToWorld(ent:OBBCenter()) + vector_up / 2) -- move the player back to the corpse
  15.                     ply:TakeDamageInfo(dmginfo)
  16.                     ply:SetNWBool("death_faked", false)
  17.                     ent:Remove() -- remove the fake corpse
  18.                     timer.Simple(0, function() -- make sure its really the next tick
  19.                         if ply:IsTerror() then
  20.                             ply:Kill() -- leaves an ugly death message but this is our last resort
  21.                         end
  22.                     end)
  23.                 else
  24.                     ply:TakeDamageInfo(dmginfo)
  25.                 end
  26.             end
  27.         end
  28.     end
  29.    
  30.     hook.Add("EntityTakeDamage", "ttt-deathfaker-corpsedmgcheck", transferDamage)
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement