LUA 185
V2+ Death Kill Messages 4.0 By xdedeone on 26th February 2019 04:51:51 PM
  1. --[[ ###    Death-Kill Messages V4    ###]]--
  2. --[[ ###   by H® Shaft, AelitePrime   ###]]--
  3. --[[ ###        for Phasor v2         ###]]--
  4.  
  5. -- Updated better code. Added additional string generators for melee kills.
  6.  
  7. last_damage = {}
  8. team_change = {}       
  9.        
  10. function GetRequiredVersion()
  11.         return 200
  12. end
  13.  
  14. function OnScriptLoad(process, game, persistent)
  15.         for i=0,15 do
  16.                 if getplayer(i) then
  17.                         team_change[i] = false
  18.                 end    
  19.         end
  20.         last_damage = {}
  21.         team_change = {}       
  22. end
  23.  
  24. function OnNewGame(map)
  25.         for i=0,15 do
  26.                 if getplayer(i) then
  27.                         team_change[i] = false
  28.                 end    
  29.         end
  30.         last_damage = {}
  31.         team_change = {}
  32. end    
  33.  
  34. function OnGameEnd(stage)
  35.         if stage == 1 then
  36.                 if announce then
  37.                         removetimer(announce)
  38.                         announce = nil
  39.                 end
  40.         end
  41. end    
  42.  
  43. function OnPlayerJoin(player)
  44.         if getplayer(player) then
  45.                 team_change[player] = false
  46.         end    
  47. end
  48.  
  49. function OnDamageApplication(receiving, causing, tagid, hit, backtap)
  50.         if receiving then
  51.                 local r_object = getobject(receiving)
  52.                 if r_object then
  53.                         local receiver = objectaddrtoplayer(r_object)
  54.                         if receiver then
  55.                                 local r_hash = gethash(receiver)
  56.                                 local tagname,tagtype = gettaginfo(tagid)
  57.                                 last_damage[r_hash] = tagname
  58.                         end
  59.                 end
  60.         end
  61. end
  62.  
  63. function OnPlayerSpawnEnd(player, m_objectId)
  64.         if getplayer(player) then
  65.                 local hash = gethash(player)
  66.                 last_damage[hash] = nil
  67.                 team_change[player] = false
  68.         end    
  69. end
  70.  
  71. function OnPlayerKill(killer, victim, mode)
  72.         local response = false
  73.  
  74.         if mode == 0 then -- player was killed by the server
  75.                 response = false
  76.                
  77.                 local killedmsg = generatekilltype(killslang)
  78.                 if getplayer(victim) then
  79.                         say(getname(victim) .. " was killed by the server script or an admin. ")
  80.                 end    
  81.                
  82.         elseif mode == 1 then -- player was killed by falling or team-change
  83.                 response = false
  84.                
  85.                 if getplayer(victim) then
  86.                         local vhash = gethash(victim)
  87.                         if not team_change[victim] then
  88.                                 response = false
  89.                                 if last_damage[vhash] == "globals\\distance" or last_damage[vhash] == "globals\\falling" then
  90.                                         say(getname(victim) .. " fell and died. ")
  91.                                 end    
  92.                         else
  93.                                 response = false
  94.                                 say(getname(victim) .. " changed teams.")
  95.                                 team_change[victim] = false            
  96.                         end    
  97.                 end    
  98.                
  99.         elseif mode == 2 then -- player was killed by the guardians
  100.                 response = false
  101.                
  102.                 if getplayer(victim) then
  103.                         say(getname(victim) .. " was killed by the guardians. ")
  104.                 end    
  105.                
  106.         elseif mode == 3 then -- player was killed by vehicle
  107.                 response = false
  108.                
  109.                 if getplayer(victim) then
  110.                         local vhash = gethash(victim)
  111.                         say(getname(victim) .. " was killed by a vehicle. ")
  112.                 end    
  113.                
  114.         elseif mode == 4 then -- player was killed by another player, killer is not always valid, victim is always valid
  115.                 response = false
  116.                
  117.                 local killedmsg = generatekilltype(killslang)
  118.                 if getplayer(victim) then
  119.                         local vhash = gethash(victim)
  120.                         if last_damage[vhash] then
  121.                                 if getplayer(killer) ~= nil then
  122.                                         if string.find(last_damage[vhash], "melee") then                       
  123.                                                 say(getname(killer) .. " " .. generatehitslang(hit) .. " " .. getname(victim) .. " upside the " .. generateheadslang(head) .. "!")                                     
  124.                                         elseif last_damage[vhash] == "globals\\distance" or last_damage[vhash] == "globals\\falling" then
  125.                                                 say(getname(victim) .. " fell and died. ")
  126.                                         elseif last_damage[vhash] == "globals\\vehicle_collision" then
  127.                                                 say(getname(killer) .. " ran over " .. getname(victim))                                        
  128.                                         elseif string.find(last_damage[vhash], "banshee") then
  129.                                                 say(getname(killer) .. " " .. killedmsg .. " " .. getname(victim) .. " with a banshee. ")
  130.                                         elseif last_damage[vhash] == "vehicles\\c gun turret\\mp bolt" then
  131.                                                 say(getname(killer) .. " " .. killedmsg .. " " .. getname(victim) .. " with the covenant turret. ")
  132.                                         elseif last_damage[vhash] == "vehicles\\ghost\\ghost bolt" then
  133.                                                 say(getname(killer) .. " " .. killedmsg .. " " .. getname(victim) .. " with the ghost plasma guns. ")
  134.                                         elseif last_damage[vhash] == "vehicles\\scorpion\\bullet" then
  135.                                                 say(getname(killer) .. " " .. killedmsg .. " " .. getname(victim) .. " with the scorpion guns. ")
  136.                                         elseif last_damage[vhash] == "vehicles\\scorpion\\shell explosion" then
  137.                                                 say(getname(killer) .. " " .. killedmsg .. " " .. getname(victim) .. " with the scorpion cannon. ")
  138.                                         elseif last_damage[vhash] == "vehicles\\warthog\\bullet" then
  139.                                                 say(getname(killer) .. " " .. killedmsg .. " " .. getname(victim) .. " with a warthog chain-gun. ")
  140.                                         elseif last_damage[vhash] == "weapons\\assault rifle\\bullet" then
  141.                                                 say(getname(killer) .. " " .. killedmsg .. " " .. getname(victim) .. " with an assault rifle. ")                       
  142.                                         elseif last_damage[vhash] == "weapons\\flamethrower\\burning" or last_damage[vhash] == "weapons\\flamethrower\\explosion" or last_damage[vhash] == "weapons\\flamethrower\\impact damage" then
  143.                                                 say(getname(killer) .. " " .. killedmsg .. " " .. getname(victim) .. " with a flame-thrower. ")
  144.                                         elseif last_damage[vhash] == "weapons\\frag grenade\\explosion" then
  145.                                                 say(getname(killer) .. " " .. killedmsg .. " " .. getname(victim) .. " with a frag grenade. ")                                 
  146.                                         elseif last_damage[vhash] == "weapons\\needler\\detonation damage" or last_damage[vhash] == "weapons\\needler\\explosion" or last_damage[vhash] == "weapons\\needler\\impact damage" then
  147.                                                 say(getname(killer) .. " " .. killedmsg .. " " .. getname(victim) .. " with a needler. ")                                      
  148.                                         elseif last_damage[vhash] == "weapons\\pistol\\bullet" then
  149.                                                 say(getname(killer) .. " " .. killedmsg .. " " .. getname(victim) .. " with a pistol. ")       
  150.                                         elseif last_damage[vhash] == "weapons\\plasma grenade\\attached" or last_damage[vhash] == "weapons\\plasma grenade\\explosion" then
  151.                                                 say(getname(killer) .. " " .. killedmsg .. " " .. getname(victim) .. " with a plasma grenade. ")
  152.                                         elseif last_damage[vhash] == "weapons\\plasma pistol\\bolt" or last_damage[vhash] == "weapons\\plasma rifle\\charged bolt" then
  153.                                                 say(getname(killer) .. " " .. killedmsg .. " " .. getname(victim) .. " with a plasma pistol. ")
  154.                                         elseif last_damage[vhash] == "weapons\\plasma rifle\\bolt" then
  155.                                                 say(getname(killer) .. " " .. killedmsg .. " " .. getname(victim) .. " with a plasma rifle. ") 
  156.                                         elseif last_damage[vhash] == "weapons\\plasma_cannon\\effects\\plasma_cannon_explosion" or last_damage[vhash] == "weapons\\plasma_cannon\\impact damage" then
  157.                                                 say(getname(killer) .. " " .. killedmsg .. " " .. getname(victim) .. " with a fuel-rod gun. ") 
  158.                                         elseif last_damage[vhash] == "weapons\\rocket launcher\\explosion" then
  159.                                                 if isinvehicle(killer) then
  160.                                                         say(getname(killer) .. " " .. killedmsg .. " " .. getname(victim) .. " with a warthog rocket. ")
  161.                                                 else
  162.                                                         say(getname(killer) .. " " .. killedmsg .. " " .. getname(victim) .. " with a rocket launcher. ")
  163.                                                 end
  164.                                         elseif last_damage[vhash] == "weapons\\shotgun\\pellet" then
  165.                                                 say(getname(killer) .. " " .. killedmsg .. " " .. getname(victim) .. " with a shotgun. ")      
  166.                                         elseif last_damage[vhash] == "weapons\\sniper rifle\\sniper bullet" then
  167.                                                 say(getname(killer) .. " " .. killedmsg .. " " .. getname(victim) .. " with a sniper rifle. ")
  168.                                         end
  169.                                 end    
  170.                         end
  171.                 end    
  172.                
  173.         elseif mode == 5 then -- player was killed by teammate
  174.                 response = true
  175.                
  176.                 if getplayer(killer) then
  177.                         privatesay(killer, " -- DON'T BETRAY! --")
  178.                 end
  179.                
  180.         elseif mode == 6 then --suicides
  181.                 response = false
  182.                
  183.                 if getplayer(victim) then
  184.                         local vhash = gethash(victim)
  185.                         if last_damage[vhash] then     
  186.                                 if last_damage[vhash] == "weapons\\frag grenade\\explosion"  or last_damage[vhash] == "weapons\\plasma grenade\\attached" or last_damage[vhash] == "weapons\\plasma grenade\\explosion" then
  187.                                         say(getname(victim) .. " desperately attempted to replace the grenade pin. ")  
  188.                                 end
  189.                         end
  190.                         say(getname(victim) .. " committed suicide.")
  191.                 end
  192.                
  193.         end
  194.        
  195.         return response
  196. end    
  197.  
  198. function OnTeamChange(player, old_team, new_team, relevant)
  199.         if getplayer(player) then
  200.                 team_change[player] = true
  201.         end    
  202.         return nil
  203. end
  204.  
  205. function generatekilltype(killslang)
  206.         local killcount = #killtype
  207.         local rand_type = getrandomnumber(1, killcount+1)
  208.         local kill_type = string.format("%s",  killtype[rand_type])
  209.         if kill_type then
  210.                 return kill_type
  211.         else
  212.                 return "killed"
  213.         end
  214. end    
  215.  
  216. function generateheadslang(head)
  217.         local headcount = #headslang
  218.         local rand_type = getrandomnumber(1, headcount+1)
  219.         local head_type = string.format("%s",  headslang[rand_type])
  220.         if head_type then
  221.                 return head_type
  222.         else
  223.                 return "head"
  224.         end
  225. end    
  226.  
  227. function generatehitslang(hit)
  228.         local hitcount = #hitslang
  229.         local rand_type = getrandomnumber(1, hitcount+1)
  230.         local hit_type = string.format("%s",  hitslang[rand_type])
  231.         if hit_type then
  232.                 return hit_type
  233.         else
  234.                 return "hit"
  235.         end
  236. end
  237.  
  238. killtype = {"destroyed", "fubarred", "disemboweled", "violated", "eviscerated", "assassinated", "slaughtered", "exterminated", "murdered", "mutilated",
  239. "eradicated", "executed", "snuffed", "eliminated", "liquidated", "dominated", "castrated", "dirt-napped", "ghosted", "hosed", "smeared", "flatlined", "vaporized", "de-boned"}
  240. headslang = {"noggin", "melon", "head", "dome", "noodle", "brain-pan", "cranium", "skull", "bean"}
  241. hitslang = {"smacked", "punched", "whacked", "clocked", "thumped", "slugged", "cuffed", "walloped", "throttled", "pimp-slapped", "hammered", "bopped", "beat", "slapped"}
  242.  
  243. -- Created by H® Shaft thank you to Oxide, AelitePrime, Nugget & Wizard.
  244. -- Visit http://halorace.org/forum/index.php?topic=514.0 or
  245. -- Visit http://pastebin.com/u/HR_Shaft for more phasor scripts

HaloNet.Net is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.