Advertisement
HR_Shaft

Rage Quit Plus for SAPP

May 27th, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.41 KB | None | 0 0
  1. -- Rage Quit Plus for SAPP
  2. -- by H® Shaft
  3.  
  4. -- if a player quits the game within <EXPIRE_TIME> of being killed, it announces the rage quit, example: "H® Shaft RAGE QUIT!"
  5. -- Optionally, for RACE and SLAYER only: if KILLER_BONUS is set to true, the killer player will have a point added to their score, and
  6. -- it will announce to killer: <<BONUS>> Your kill made [RAGE QUITTER NAME] RAGE QUIT! Your score + 1!"
  7.  
  8. -- Killer Bonus:  true = enabled, false = disabled, if true and game is RACE or SLAYER, the the killer who caused the player to rage quit gets +1 score 'killer bonus'
  9. KILLER_BONUS = true
  10.  
  11. -- time in seconds if player leaves before this time expires it will announce they rage quit. Recommended: 15 seconds, or between 10 and 20 seconds
  12. -- if this value is less than 3, not a number or not a positive number, it will likely fail
  13. EXPIRE_TIME = 15  
  14.  
  15.  
  16. -- don't edit --
  17. api_version = "1.10.0.0"
  18. rage_quitter = {}
  19.  
  20. function OnScriptLoad()
  21.     register_callback(cb['EVENT_GAME_START'], "OnGameStart")
  22.     register_callback(cb['EVENT_GAME_END'], "OnGameEnd")
  23.     register_callback(cb['EVENT_JOIN'], "OnPlayerJoin")
  24.     register_callback(cb['EVENT_LEAVE'], "OnPlayerLeave")
  25.     register_callback(cb['EVENT_DIE'], "OnDie")
  26.     if get_var(0, "$gt") ~= "n/a" then
  27.         game_started = true
  28.         for i=1,16 do
  29.             if player_present(i) then
  30.                 rage_quitter[get_var(i,"$hash")] = {}
  31.                 rage_quitter[get_var(i,"$hash")].raging = false
  32.                 rage_quitter[get_var(i,"$hash")].killer = nil
  33.             end    
  34.         end    
  35.     else
  36.         game_started = false
  37.     end    
  38. end
  39.  
  40. function OnGameStart()
  41.     rage_quitter = {}
  42.     game_started = true
  43.     for i=1,16 do
  44.         if player_present(i) then
  45.             rage_quitter[get_var(i,"$hash")] = {}
  46.             rage_quitter[get_var(i,"$hash")].raging = false
  47.             rage_quitter[get_var(i,"$hash")].killer = nil
  48.         end    
  49.     end
  50. end
  51.  
  52. function OnGameEnd()
  53.     rage_quitter = {}
  54.     game_started = false
  55.     for i=1,16 do
  56.         if player_present(i) then
  57.             rage_quitter[get_var(i,"$hash")] = {}
  58.             rage_quitter[get_var(i,"$hash")].raging = false
  59.             rage_quitter[get_var(i,"$hash")].killer = nil
  60.         end    
  61.     end    
  62. end
  63.  
  64. function OnPlayerJoin(PlayerIndex)
  65.     if player_present(PlayerIndex) then
  66.         rage_quitter[get_var(PlayerIndex,"$hash")] = {}
  67.         rage_quitter[get_var(PlayerIndex,"$hash")].raging = false
  68.         rage_quitter[get_var(PlayerIndex,"$hash")].killer = nil    
  69.     end
  70. end
  71.  
  72. function OnPlayerLeave(PlayerIndex)
  73.     local game_type = get_var(0,"$gt")
  74.     if (game_started == true) then
  75.         if (rage_quitter[get_var(PlayerIndex,"$hash")].raging == true) then
  76.             for i=1,16 do
  77.                 if player_present(i) then
  78.                     if (rage_quitter[get_var(PlayerIndex,"$hash")].killer ~= nil) then
  79.                         say(i, "          <<RAGE QUIT!>>  " .. get_var(PlayerIndex,"$name") .. "  <<RAGE QUIT!>>")
  80.                     end
  81.                 end
  82.             end
  83.             if (KILLER_BONUS == true) and (game_type == "race" or game_type == "slayer") then
  84.                 if (rage_quitter[get_var(PlayerIndex,"$hash")].killer ~= nil) then
  85.                     execute_command("score me +1", rage_quitter[get_var(PlayerIndex,"$hash")].killer)
  86.                     say(rage_quitter[get_var(PlayerIndex,"$hash")].killer, "<<BONUS>> Your kill made "  .. get_var(PlayerIndex,"$name") .. " RAGE QUIT! Your score + 1!")
  87.                 end
  88.             end        
  89.         end
  90.     end
  91.     rage_quitter[get_var(PlayerIndex,"$hash")].raging = nil
  92.     rage_quitter[get_var(PlayerIndex,"$hash")].killer = nil
  93. end
  94.  
  95. function OnDie(PlayerIndex, KillerIndex)
  96.     PlayerIndex = tonumber(PlayerIndex)
  97.     KillerIndex = tonumber(KillerIndex)
  98.     if (game_started == true) then
  99.         if (KillerIndex > 0) and (PlayerIndex ~= KillerIndex) and (get_var(PlayerIndex,"$team") ~= get_var(KillerIndex,"$team")) then
  100.             rage_quitter[get_var(PlayerIndex,"$hash")].raging = true
  101.             rage_quitter[get_var(PlayerIndex,"$hash")].killer = KillerIndex
  102.             cool_down = timer((1000 * tonumber(EXPIRE_TIME)), "Cool_Down", PlayerIndex)
  103.         end
  104.     end
  105. end
  106.  
  107. function Cool_Down(PlayerIndex)
  108.     if (game_started == true) then
  109.         if player_present(PlayerIndex) then
  110.             rage_quitter[get_var(PlayerIndex,"$hash")] = {}
  111.             rage_quitter[get_var(PlayerIndex,"$hash")].raging = false
  112.             rage_quitter[get_var(PlayerIndex,"$hash")].killer = nil
  113.         end
  114.     end
  115.     return false           
  116. end
  117.  
  118. function OnError(Message)
  119.     print(debug.traceback())
  120. end
  121.  
  122. -- Created by H® Shaft
  123. -- Visit http://halorace.org/forum/index.php
  124.  
  125. -- The player -db-GoNe/Juhleek - a well spoken liar, cheat.
  126. -- -db- is: "diverging from the believable" - How ironic. A race clan where admins use rcon to favor themselves to win.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement