Advertisement
HR_Shaft

Death Messages for SAPP

Feb 29th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.91 KB | None | 0 0
  1. -- Death Messages for stock PC/CE maps for SAPP
  2. -- by H® Shaft
  3.  
  4. -- Script will show how players were killed/died: Normal death messages are blocked (no chat spam), examples :
  5. -- "H® Shaft was blasted by sehé°°'s banshee plasma cannon."
  6. -- "H® Shaft was blown-up by sehé°°'s's frag grenade."
  7. -- "H® Shaft was shot by Btcc22's sniper rifle."
  8. -- "H® Shaft was melee'd by Btcc22!"
  9. -- Will tell Killer and Victim if they were killed by Headshot (pistol and sniper only) "BOOM! You were headshot! by H® Shaft"
  10. -- Will show when a player died by: Falling, by Vehicle or Team Change, will not show if killed by the server
  11. -- Will show player their combination kills, and announce to everyone your sprees: "H® Shaft is on a Killing Spree!"
  12. -- Allows server admins to turn fall damage on/off PER map: see LoadDefaults() true, fall damage is on, false it is off (line 382)
  13.  
  14. -- don't edit --
  15. game_started = false
  16. team_play = false
  17. last_damage = {}
  18. head_shot = {}
  19. back_tap = {}
  20. killed_by_nothing = {}
  21. api_version = "1.9.0.0"
  22.  
  23. function OnScriptLoad()
  24.     register_callback(cb['EVENT_GAME_START'], "OnNewGame")
  25.     register_callback(cb['EVENT_PRESPAWN'],"OnPlayerPreSpawn")
  26.     register_callback(cb['EVENT_DAMAGE_APPLICATION'], "OnDamageApplication")
  27.     register_callback(cb['EVENT_DIE'], "OnPlayerDie")
  28.     register_callback(cb['EVENT_KILL'], "OnPlayerKill")
  29.     register_callback(cb['EVENT_TEAM_SWITCH'],"OnTeamSwitch")  
  30.     register_callback(cb['EVENT_GAME_END'],"OnGameEnd")    
  31.     register_callback(cb['EVENT_LEAVE'], "OnPlayerLeave")
  32.     disable_killmsg_addr = sig_scan("8B42348A8C28D500000084C9") + 3
  33.     original_code_1 = read_dword(disable_killmsg_addr)
  34.     safe_write(true)
  35.     write_dword(disable_killmsg_addr, 0x03EB01B1)
  36.     safe_write(false)  
  37.  
  38.     if get_var(0, "$gt") ~= "n/a" then 
  39.         game_started = true
  40.         team_play = getteamplay()
  41.         GetMetaIDs()
  42.         LoadDefaults()
  43.         map_name = get_var(1,"$map")
  44.         for i=1,16 do
  45.             if player_present(i) then
  46.                 last_damage[i] = 0
  47.                 killed_by_nothing[i] = false
  48.                 head_shot[i] = false
  49.                 back_tap[i] = false
  50.             end
  51.         end    
  52.     end    
  53. end
  54.  
  55. function OnScriptUnload()
  56.     safe_write(true)
  57.     write_dword(disable_killmsg_addr, original_code_1)
  58.     safe_write(false)
  59.     killed_by_nothing = {}
  60.     last_damage = {}
  61.     head_shot = {}
  62.     back_tap = {}
  63. end
  64.  
  65. function OnPlayerPreSpawn(PlayerIndex)
  66.     last_damage[PlayerIndex] = 0
  67.     head_shot[PlayerIndex] = false
  68.     back_tap[PlayerIndex] = false
  69. end
  70.  
  71. function OnNewGame()
  72.     game_started = true
  73.     map_name = get_var(1,"$map")
  74.     team_play = getteamplay()
  75.     GetMetaIDs()
  76.     LoadDefaults() 
  77.     for i=1,16 do
  78.         if player_present(i) then  
  79.             last_damage[i] = 0
  80.             killed_by_nothing[i] = false
  81.             head_shot[i] = false
  82.             back_tap[i] = false
  83.         end
  84.     end    
  85. end
  86.  
  87. function OnPlayerLeave(PlayerIndex)
  88.     last_damage[PlayerIndex] = nil
  89.     killed_by_nothing[PlayerIndex] = nil
  90.     head_shot[PlayerIndex] = nil
  91.     back_tap[PlayerIndex] = false  
  92. end
  93.  
  94. function OnGameEnd()
  95.     game_started = false
  96.     for i=1,16 do
  97.         if player_present(i) then      
  98.             last_damage[i] = 0
  99.             killed_by_nothing[i] = false
  100.             head_shot[i] = false
  101.             back_tap[i] = false
  102.         end
  103.     end
  104. end
  105.  
  106. function OnPlayerDie(PlayerIndex, KillerIndex)
  107.     -- Killer Index is: -- falling = -1, server = -1, team-switch = -1, vehicle = 0, other players = 1 or greater
  108.     if (game_started == true) then
  109.         local vname = get_var(PlayerIndex, "$name")
  110.         local vteam = get_var(PlayerIndex, "$team")
  111.         local killer = tonumber(KillerIndex)
  112.  
  113.         if (killer == -1) then
  114.             if last_damage[PlayerIndex] == 0 then
  115.                 killed_by_nothing[PlayerIndex] = true
  116.             elseif last_damage[PlayerIndex] == falling_damage or last_damage[PlayerIndex] == distance_damage then
  117.                 say_all(vname.. " fell and died.")
  118.                 last_damage[PlayerIndex] = 0
  119.                 killed_by_nothing[PlayerIndex] = false             
  120.             end
  121.            
  122.         elseif (killer == 0) then
  123.             if last_damage[PlayerIndex] == veh_damage then
  124.                 say_all(vname.. " was killed by a vehicle.")
  125.                 last_damage[PlayerIndex] = 0           
  126.             end
  127.            
  128.         elseif (killer == nil) then
  129.             if last_damage[PlayerIndex] == 0 then
  130.                 say_all(vname.. " was killed by the guardians.")
  131.             end
  132.            
  133.         elseif (killer > 0) then
  134.             local kname = get_var(KillerIndex, "$name")
  135.             local kteam = get_var(KillerIndex, "$team")
  136.             if PlayerIndex ~= KillerIndex  then
  137.                 if last_damage[PlayerIndex] == veh_damage then
  138.                     if isinvehicle(KillerIndex) then
  139.                         say_all(vname.. " was run over by " .. kname .. ".")
  140.                     else
  141.                         say_all(vname.. " was killed by a vehicle.")
  142.                     end
  143.                 elseif last_damage[PlayerIndex] == banshee_bolt then
  144.                     say_all(vname.. " was shot by " .. kname .. "'s banshee guns. ")
  145.                 elseif last_damage[PlayerIndex] == banshee_explode then
  146.                     say_all(vname.. " was blasted by " .. kname .. "'s banshee plasma cannon. ")
  147.                 elseif last_damage[PlayerIndex] == turret_bolt then
  148.                     say_all(vname.. " was shot by " .. kname .. "'s turret. ")
  149.                 elseif last_damage[PlayerIndex] == ghost_bolt then
  150.                     say_all(vname.. " was shot by " .. kname .. "'s ghost guns. ")
  151.                 elseif last_damage[PlayerIndex] == tank_shell then
  152.                     say_all(vname.. " was blasted by " .. kname .. "'s tank shell. ")  
  153.                 elseif last_damage[PlayerIndex] == tank_bullet then
  154.                     say_all(vname.. " was shot by " .. kname .. "'s tank guns. ")
  155.                 elseif last_damage[PlayerIndex] == chain_bullet then
  156.                     say_all(vname.. " was shot by " .. kname .. "'s chain gun. ")
  157.                 elseif last_damage[PlayerIndex] == assault_bullet then
  158.                     say_all(vname.. " was shot by " .. kname .. "'s assault rifle. ")
  159.                 elseif last_damage[PlayerIndex] == flame_explode then
  160.                     say_all(vname.. " was toasted by " .. kname .. "'s flame-thrower. ")
  161.                 elseif last_damage[PlayerIndex] == frag_explode then
  162.                     say_all(vname.. " was blown-up by " .. kname .. "'s frag grenade. ")
  163.                 elseif last_damage[PlayerIndex] == needle_detonate then
  164.                     say_all(vname.. " was shot by " .. kname .. "'s needler. ")
  165.                 elseif last_damage[PlayerIndex] == needle_explode then
  166.                     say_all(vname.. " was shot by " .. kname .. "'s needler. ")
  167.                 elseif last_damage[PlayerIndex] == needle_impact then
  168.                     say_all(vname.. " was shot by " .. kname .. "'s needler. ")    
  169.                 elseif last_damage[PlayerIndex] == pistol_bullet then
  170.                     say_all(vname.. " was shot by " .. kname .. "'s pistol. ")
  171.                     if head_shot[PlayerIndex] then  -- only the pistol and sniper actually cause headshots
  172.                         say(PlayerIndex, "BOOM! You were headshot! by " .. kname)
  173.                         say(KillerIndex, "BOOM! headshot!")
  174.                         head_shot[PlayerIndex] = false
  175.                     end                
  176.                 elseif last_damage[PlayerIndex] == plasma_attach then
  177.                     say_all(vname.. " was stickied by " .. kname .. "'s plasma grenade! ") 
  178.                 elseif last_damage[PlayerIndex] == plasma_explode then
  179.                     say_all(vname.. " was blown-up by " .. kname .. "'s plasma grenade. ")
  180.                 elseif last_damage[PlayerIndex] == ppistol_bolt then
  181.                     say_all(vname.. " was shot by " .. kname .. "'s plasma pistol. ")
  182.                 elseif last_damage[PlayerIndex] == ppistol_charged then
  183.                     say_all(vname.. " was shot by " .. kname .. "'s plasma pistol. ")
  184.                 elseif last_damage[PlayerIndex] == prifle_bolt then
  185.                     say_all(vname.. " was shot by " .. kname .. "'s plasma rifle. ")
  186.                 elseif last_damage[PlayerIndex] == pcannon_explode then
  187.                     say_all(vname.. " was shot by " .. kname .. "'s plasma cannon. ")
  188.                 elseif last_damage[PlayerIndex] == rocket_explode then
  189.                     if isinvehicle(KillerIndex) then
  190.                         say_all(vname.. " was blown-up by " .. kname .. "'s warthog rocket. ")
  191.                     else   
  192.                         say_all(vname.. " was blown-up by " .. kname .. "'s rocket. ")
  193.                     end
  194.                 elseif last_damage[PlayerIndex] == shotgun_pellet then
  195.                     say_all(vname.. " was shot by " .. kname .. "'s shotgun. ")
  196.                 elseif last_damage[PlayerIndex] == sniper_bullet then
  197.                     say_all(vname.. " was shot by " .. kname .. "'s sniper rifle. ")
  198.                     if head_shot[PlayerIndex] then -- only the pistol and sniper actually cause headshots
  199.                         say(PlayerIndex, "BOOM! You were headshot! by " .. kname)
  200.                         say(KillerIndex, "BOOM! headshot!")
  201.                         head_shot[PlayerIndex] = false
  202.                     end
  203.                 elseif back_tap[PlayerIndex] then
  204.                     say_all(vname.. " was melee'd by " .. kname .. "!")
  205.                     back_tap[PlayerIndex] = false
  206.                 elseif last_damage[PlayerIndex] == 0 then
  207.                     say_all(vname.. " was killed by " .. kname .. ".") 
  208.                 end
  209.                
  210.             elseif PlayerIndex == KillerIndex then
  211.                 say_all(vname.. " committed suicide, derp.")
  212.                 if not team_play then
  213.                     if read_dword(get_player(PlayerIndex) + 0xC0) > 0 then
  214.                         write_dword(get_player(PlayerIndex) + 0xC0, 0)
  215.                     end
  216.                 end
  217.                
  218.             elseif kteam == vteam and PlayerIndex ~= KillerIndex then
  219.                 if team_play then
  220.                     say_all(vname.. " was betrayed by " .. kname .. ".")
  221.                 end
  222.                
  223.             else
  224.                 say_all(vname.. " was killed by the guardians. ")          
  225.             end
  226.         end
  227.         last_damage[PlayerIndex] = 0
  228.         head_shot[PlayerIndex] = false
  229.         back_tap[PlayerIndex] = false
  230.     end
  231. end
  232.  
  233. function OnTeamSwitch(PlayerIndex)
  234.     if (game_started == true) then
  235.         if team_play then
  236.             if (killed_by_nothing[PlayerIndex] == true) then
  237.                 say_all(get_var(PlayerIndex,"$name") .. " switched to the " .. get_var(PlayerIndex,"$team") .. " team.")       
  238.                 killed_by_nothing[PlayerIndex] = false             
  239.             end    
  240.         end
  241.     end
  242. end
  243.  
  244. function OnDamageApplication(PlayerIndex, CauserIndex, MetaID, Damage, HitString, Backtap)
  245.     if (game_started == true) then
  246.         local melee_damage = Damage * 2
  247.         if (HitString == "head") then
  248.             head_shot[PlayerIndex] = true
  249.         end
  250.         if (Backtap == true) then
  251.             back_tap[PlayerIndex] = true
  252.             return true, melee_damage
  253.         end
  254.         if MetaID == falling_damage then
  255.             last_damage[PlayerIndex] = falling_damage
  256.             if not fall_damage[map_name] then
  257.                 return true, 0
  258.             end
  259.         elseif MetaID == distance_damage then
  260.             last_damage[PlayerIndex] = distance_damage
  261.             if not fall_damage[map_name] then
  262.                 return true, 0
  263.             end
  264.         end    
  265.         last_damage[PlayerIndex] = MetaID  
  266.     end
  267. end
  268.  
  269. function GetMetaIDs()
  270.     falling_damage = read_dword(lookup_tag("jpt!", "globals\\falling") + 12)
  271.     distance_damage = read_dword(lookup_tag("jpt!", "globals\\distance") + 12)
  272.     veh_damage = read_dword(lookup_tag("jpt!", "globals\\vehicle_collision") + 12)
  273.     banshee_bolt = read_dword(lookup_tag("jpt!", "vehicles\\banshee\\banshee bolt") + 12)
  274.     banshee_explode = read_dword(lookup_tag("jpt!", "vehicles\\banshee\\mp_fuel rod explosion") + 12)
  275.     turret_bolt = read_dword(lookup_tag("jpt!", "vehicles\\c gun turret\\mp bolt") + 12)
  276.     ghost_bolt = read_dword(lookup_tag("jpt!", "vehicles\\ghost\\ghost bolt") + 12)
  277.     tank_shell = read_dword(lookup_tag("jpt!", "vehicles\\scorpion\\shell explosion") + 12)
  278.     tank_bullet = read_dword(lookup_tag("jpt!", "vehicles\\scorpion\\bullet") + 12)
  279.     chain_bullet = read_dword(lookup_tag("jpt!", "vehicles\\warthog\\bullet") + 12)
  280.     assault_bullet = read_dword(lookup_tag("jpt!", "weapons\\assault rifle\\bullet") + 12)
  281.     assault_melee = read_dword(lookup_tag("jpt!", "weapons\\assault rifle\\melee") + 12)
  282.     ball_melee = read_dword(lookup_tag("jpt!", "weapons\\ball\\melee") + 12)
  283.     flag_melee = read_dword(lookup_tag("jpt!", "weapons\\flag\\melee") + 12)
  284.     flame_explode = read_dword(lookup_tag("jpt!", "weapons\\flamethrower\\explosion") + 12)
  285.     flame_melee = read_dword(lookup_tag("jpt!", "weapons\\flamethrower\\melee") + 12)
  286.     frag_explode = read_dword(lookup_tag("jpt!", "weapons\\frag grenade\\explosion") + 12)
  287.     needle_detonate = read_dword(lookup_tag("jpt!", "weapons\\needler\\detonation damage") + 12)
  288.     needle_explode = read_dword(lookup_tag("jpt!", "weapons\\needler\\explosion") + 12)
  289.     needle_impact = read_dword(lookup_tag("jpt!", "weapons\\needler\\impact damage") + 12)
  290.     needle_melee = read_dword(lookup_tag("jpt!", "weapons\\needler\\melee") + 12)
  291.     pistol_bullet = read_dword(lookup_tag("jpt!", "weapons\\pistol\\bullet") + 12)
  292.     pistol_melee = read_dword(lookup_tag("jpt!", "weapons\\pistol\\melee") + 12)
  293.     plasma_attach = read_dword(lookup_tag("jpt!", "weapons\\plasma grenade\\attached") + 12)
  294.     plasma_explode = read_dword(lookup_tag("jpt!", "weapons\\plasma grenade\\explosion") + 12)
  295.     ppistol_bolt = read_dword(lookup_tag("jpt!", "weapons\\plasma pistol\\bolt") + 12)
  296.     ppistol_charged = read_dword(lookup_tag("jpt!", "weapons\\plasma rifle\\charged bolt") + 12)
  297.     ppistol_melee = read_dword(lookup_tag("jpt!", "weapons\\plasma pistol\\melee") + 12)
  298.     prifle_bolt = read_dword(lookup_tag("jpt!", "weapons\\plasma rifle\\bolt") + 12)
  299.     prifle_melee = read_dword(lookup_tag("jpt!", "weapons\\plasma rifle\\melee") + 12)
  300.     pcannon_explode = read_dword(lookup_tag("jpt!", "weapons\\plasma_cannon\\effects\\plasma_cannon_explosion") + 12)
  301.     pcannon_melee = read_dword(lookup_tag("jpt!", "weapons\\plasma_cannon\\effects\\plasma_cannon_melee") + 12)
  302.     rocket_explode = read_dword(lookup_tag("jpt!", "weapons\\rocket launcher\\explosion") + 12)
  303.     rocket_melee = read_dword(lookup_tag("jpt!", "weapons\\rocket launcher\\melee") + 12)
  304.     shotgun_pellet = read_dword(lookup_tag("jpt!", "weapons\\shotgun\\pellet") + 12)
  305.     shotgun_melee = read_dword(lookup_tag("jpt!", "weapons\\shotgun\\melee") + 12)
  306.     sniper_bullet = read_dword(lookup_tag("jpt!", "weapons\\sniper rifle\\sniper bullet") + 12)
  307.     sniper_melee = read_dword(lookup_tag("jpt!", "weapons\\sniper rifle\\melee") + 12)
  308. end
  309.  
  310. function OnPlayerKill(PlayerIndex, VictimIndex)
  311.     local combo = tonumber(get_var(PlayerIndex, "$combo"))
  312.     local spree = tonumber(get_var(PlayerIndex, "$streak"))
  313.     local Name = get_var(PlayerIndex, "$name")
  314.    
  315.     if combo == 2 then
  316.         rprint(PlayerIndex, "|r" .. "Double Kill!")
  317.     elseif combo == 3 then
  318.         rprint(PlayerIndex, "|r" .. "Triple Kill!")
  319.     elseif combo == 4 then
  320.         rprint(PlayerIndex, "|r" .. "Overkill!")   
  321.     elseif combo == 5 then
  322.         rprint(PlayerIndex, "|r" .. "Killtacular!")
  323.     elseif combo == 6 then
  324.         rprint(PlayerIndex, "|r" .. "Killtrocity!")
  325.     elseif combo == 7 then
  326.         rprint(PlayerIndex, "|r" .. "Killimanjaro!")   
  327.     elseif combo == 8 then
  328.         rprint(PlayerIndex, "|r" .. "Killtastrophe!")  
  329.     elseif combo == 9 then
  330.         rprint(PlayerIndex, "|r" .. "Killpocalypse!")  
  331.     elseif combo == 10 then
  332.         rprint(PlayerIndex, "|r" .. "Killionaire!")
  333.     end
  334.    
  335.     if spree == 5 then
  336.         AnnounceSpree(Name, "is on a Killing Spree!")
  337.     elseif spree == 10 then
  338.         AnnounceSpree(Name, "is in a Killing Frenzy!")
  339.     elseif spree == 15 then
  340.         AnnounceSpree(Name, "just got a Running Riot!")
  341.     elseif spree == 20 then
  342.         AnnounceSpree(Name, "is on a Rampage!")
  343.     elseif spree == 25 then
  344.         AnnounceSpree(Name, "is Untouchable!")
  345.     elseif spree == 30 then
  346.         AnnounceSpree(Name, "is Inconceivable!")
  347.     elseif spree == 35 then
  348.         AnnounceSpree(Name, "is Unfrigginbelievable!")
  349.     elseif spree == 40 then
  350.         AnnounceSpree(Name, "is running AMOK!")
  351.     elseif spree >= 50 then
  352.         AnnounceSpree(Name, "is going BESERK!")    
  353.     end
  354. end
  355.  
  356. function AnnounceSpree(Name, Message)
  357.     for i = 1,16 do
  358.         if player_present(i) then
  359.             rprint(i, "|r" .. "" .. Name .. " " .. Message)
  360.         end
  361.     end
  362. end
  363.  
  364. function isinvehicle(PlayerIndex)  
  365.     local player_object = get_dynamic_player(PlayerIndex)
  366.     local vehicleId = read_dword(player_object + 0x11C)
  367.     if vehicleId == 0xFFFFFFFF then
  368.         return false
  369.     else
  370.         return true
  371.     end
  372. end
  373.  
  374. function getteamplay()
  375.     if get_var(0,"$ffa") == "0" then
  376.         return true
  377.     else
  378.         return false
  379.     end
  380. end
  381.  
  382. function LoadDefaults()
  383.     -- turn fall damage on (true) or off (false) for each map,
  384.     -- note: damnation & gephyrophobia players can get stuck on bottom if it's turned off
  385.     fall_damage = {
  386.         ["beavercreek"] = true,
  387.         ["bloodgulch"] = true,
  388.         ["boardingaction"] = true,
  389.         ["carousel"] = true,
  390.         ["chillout"] = true,
  391.         ["damnation"] = true,
  392.         ["dangercanyon"] = true,
  393.         ["deathisland"] = true,
  394.         ["gephyrophobia"] = true,
  395.         ["hangemhigh"] = true,
  396.         ["icefields"] = true,
  397.         ["infinity"] = true,
  398.         ["longest"] = true,
  399.         ["prisoner"] = true,
  400.         ["putput"] = true,
  401.         ["ratrace"] = true,
  402.         ["sidewinder"] = true,
  403.         ["timberland"] = true,
  404.         ["wizard"] = true
  405.     }
  406. end
  407.  
  408. function OnError(Message)
  409.     print(debug.traceback())
  410. end
  411.  
  412. -- Created by H® Shaft
  413. -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement