Advertisement
Frost1

killstreak.lua

Apr 12th, 2015
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. // you can stop using your shitty "KILLSTREAK = 3" scripts now
  2.  
  3. local function contraction(num)
  4. num = tostring(num);
  5. local contract = string.sub(num, string.len(num), string.len(num));
  6. local cont = "";
  7.  
  8. if (string.len(num) > 1) then
  9. if (string.GetChar(num, string.len(num) - 1) == "1") then // 11, 12, 13, 111, 112, ...
  10. return num .. "th";
  11. end
  12. end
  13.  
  14. if contract == "1" then
  15. cont = "st";
  16. elseif contract == "2" then
  17. cont = "nd";
  18. elseif contract == "3" then
  19. cont = "rd";
  20. else // 0 4 5 6 7 8 9
  21. cont = "th";
  22. end
  23.  
  24. return num .. cont;
  25. end
  26.  
  27. local sayings = {
  28. "First Blood!",
  29. "Killing Spree!",
  30. "Killing Frenzy!",
  31. "Running Riot!",
  32. "Rampage!",
  33. "Untouchable!",
  34. "Invincible!"
  35. }
  36.  
  37. local function getmsg(knum)
  38. if (knum <= 1) then
  39. return sayings[1];
  40. elseif (knum <= 10) then
  41. return sayings[2];
  42. elseif (knum <= 15) then
  43. return sayings[3];
  44. elseif (knum <= 20) then
  45. return sayings[4];
  46. elseif (knum <= 25) then
  47. return sayings[5];
  48. elseif (knum <= 30) then
  49. return sayings[6];
  50. else
  51. return sayings[7];
  52. end
  53. end
  54.  
  55. local kills = 0;
  56.  
  57. local function killstreak(data)
  58. local attacker = player.GetByID(data.entindex_attacker);
  59. local victim = player.GetByID(data.entindex_killed);
  60.  
  61. if (!attacker:IsValid() or !victim:IsValid()) then
  62. return;
  63. end
  64.  
  65. if (victim == LocalPlayer()) then // streak over
  66. kills = 0;
  67. return;
  68. end
  69.  
  70. if (attacker == LocalPlayer()) then
  71. kills = kills + 1;
  72. RunConsoleCommand("say", string.format("%s %s was my %s kill!", getmsg(kills), victim:Nick(), contraction(kills)));
  73. end
  74. end
  75. gameevent.Listen("entity_killed");
  76. hook.Add("entity_killed", "killstreak", killstreak);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement