Advertisement
miguelspastes

anti-kick

Jan 15th, 2019
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. -- Anti vote-kick by ShadyRetard
  2.  
  3. local kick_command_id = 1;
  4. local kick_potential_votes = 0;
  5. local kick_yes_voters = 0;
  6. local kick_getting_kicked = false;
  7. local kick_last_command_time;
  8. local ANTIKICK_CB = gui.Checkbox(gui.Reference("MISC", "AUTOMATION", "Other"), "ANTIKICK_CB", "Enable Anti Vote-kick", false);
  9. local ANTIKICK_VOTE_THRESHOLD = gui.Slider(gui.Reference("MISC", "AUTOMATION", "Other"), "ANTIKICK_VOTE_THRESHOLD", "Scramble threshold %:", 80, 1, 100);
  10.  
  11. function kickEventHandler(event)
  12. local self_pid = client.GetLocalPlayerIndex();
  13. local self = entities.GetLocalPlayer();
  14.  
  15. local active_map_name = engine.GetMapName();
  16.  
  17. if (ANTIKICK_CB:GetValue() == false or self_pid == nil or self == nil or active_map_name == nil) then
  18. return;
  19. end
  20.  
  21. if (event:GetName() == "game_start") then
  22. kick_last_command_time = nil;
  23. return;
  24. end
  25.  
  26. if (event:GetName() == "vote_changed") then
  27. kick_potential_votes = event:GetInt("potentialVotes");
  28. return;
  29. end
  30.  
  31. if (event:GetName() == "vote_cast") then
  32. local vote_option = event:GetInt("vote_option");
  33. local voter_eid = event:GetInt("entityid");
  34.  
  35. if (self_pid ~= voter_eid and vote_option == 0) then
  36. kick_yes_voters = kick_yes_voters + 1;
  37. end
  38.  
  39. if (self_pid == voter_eid and vote_option == 1) then
  40. kick_getting_kicked = true;
  41.  
  42. -- We're voting NO, which means somebody else already voted yes
  43. kick_yes_voters = 1;
  44. end
  45.  
  46. if (kick_getting_kicked == false) then
  47. return;
  48. end
  49.  
  50. local kick_percentage = ((kick_yes_voters - 1) / (kick_potential_votes / 2) * 100);
  51.  
  52. if (kick_yes_voters > 0 and kick_potential_votes > 0 and kick_percentage >= ANTIKICK_VOTE_THRESHOLD:GetValue() and (kick_last_command_time == nil or globals.CurTime() - kick_last_command_time > 120)) then
  53. if (kick_command_id == 1) then
  54. client.Command("callvote SwapTeams");
  55. kick_command_id = 2;
  56. elseif (kick_command_id == 2) then
  57. client.Command("callvote ScrambleTeams");
  58. kick_command_id = 3;
  59. elseif (kick_command_id == 3) then
  60. client.Command("callvote ChangeLevel " .. active_map_name);
  61. kick_command_id = 1;
  62. end
  63.  
  64. kick_last_command_time = globals.CurTime();
  65. end
  66. end
  67.  
  68. end
  69.  
  70. client.AllowListener("game_start");
  71. client.AllowListener("vote_changed");
  72. client.AllowListener("vote_cast");
  73. callbacks.Register("FireGameEvent", "antikick_event", kickEventHandler);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement