Advertisement
Guest User

MaVe

a guest
Oct 31st, 2008
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.99 KB | None | 0 0
  1. /*
  2.  
  3.  _______________________
  4. [                       ]
  5. [ AntiKill Filterscript ]
  6. [      Version 1.1      ]
  7. [  [2008] (C) by MaVe   ]
  8. [_______________________]
  9.  
  10.  
  11. Don't take my scripts and call them your's!
  12.  
  13.  
  14. ==> Go to line 37 to define your own exceptions for AntiKill.
  15.  
  16.  
  17. */
  18.  
  19. #include <a_samp>
  20.  
  21. new bool:KillFreezed[MAX_PLAYERS];
  22. new RestSeconds[MAX_PLAYERS];
  23.  
  24. #define NOKILLING_STR "~r~No Killing here!~n~~n~~b~You are freezed~n~~n~~g~%d ~w~secs left"
  25. #define GAMETEXT_STYLE 5
  26.  
  27. forward GameTextUpdate(playerid);
  28.  
  29. public OnPlayerDisconnect(playerid, reason)
  30. {
  31.     KillFreezed[playerid] = false;
  32.     RestSeconds[playerid] = 0;
  33.     return 1;
  34. }
  35.  
  36. // Define your own exceptions, e.g. DM-check
  37. stock Exception(playerid)
  38. {
  39.     if (IsPlayerInAnyVehicle(playerid)) return 1; // Don't check for killings if the player is in a vehicle.
  40.     return 0;
  41. }
  42.  
  43. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  44. {
  45.     if (newkeys & KEY_FIRE && !KillFreezed[playerid] && !Exception(playerid))
  46.     {
  47.         KillFreezed[playerid] = true;
  48.         TogglePlayerControllable(playerid, false);
  49.         RestSeconds[playerid] = 5;
  50.         new str[128];
  51.         format(str, sizeof(str), NOKILLING_STR, RestSeconds[playerid]);
  52.         GameTextForPlayer(playerid, str, 1000, GAMETEXT_STYLE);
  53.         SetTimerEx("GameTextUpdate", 1000, 0, "i", playerid);
  54.     }
  55.     return 1;
  56. }
  57.  
  58. public GameTextUpdate(playerid)
  59. {
  60.     if (RestSeconds[playerid] != 0)
  61.     {
  62.         RestSeconds[playerid]--;
  63.         new str[128];
  64.         format(str, sizeof(str), NOKILLING_STR, RestSeconds[playerid]);
  65.         GameTextForPlayer(playerid, str, 1000, GAMETEXT_STYLE);
  66.         SetTimerEx("GameTextUpdate", 1000, 0, "i", playerid);
  67.     }
  68.     else
  69.     {
  70.         GameTextForPlayer(playerid, "~r~No Killing again!", 1000, GAMETEXT_STYLE);
  71.         KillFreezed[playerid] = false;
  72.         TogglePlayerControllable(playerid, true);
  73.     }
  74. }
  75.  
  76. public OnFilterScriptExit()
  77. {
  78.     for (new i=0; i<MAX_PLAYERS; i++)
  79.     {
  80.         if (KillFreezed[i])
  81.         {
  82.             TogglePlayerControllable(i, true);
  83.             KillFreezed[i] = false;
  84.         }
  85.     }
  86.     return 1;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement