Advertisement
EnzoMetlc

[FS] Anti-Flood + Guardado.

Dec 26th, 2013
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.39 KB | None | 0 0
  1. #include <a_samp>
  2.     #undef MAX_PLAYERS
  3.     #define MAX_PLAYERS 100 // Cámbia a la cantidad de slot's que usas en tu Servidor.
  4. #include <dini>
  5.  
  6.  
  7. #define DIRECCION "CarpetaUsuarios/%s.ini" // Cambia a la dirección en donde guardas los datos de tus usuarios.
  8.  
  9.  
  10. stock Timer:operator = (var) return Timer:var;
  11.  
  12.  
  13. stock bool:TimerHasHappened(Timer:timer)
  14. {
  15.     return (ObtainTimer(_:timer) <= 0) ? (true) : (false);
  16. }
  17.  
  18.  
  19.  
  20. static Timer[MAX_PLAYERS];
  21. static Timer:TimerFlood[MAX_PLAYERS];
  22. static AntiFlood[MAX_PLAYERS];
  23. static TimerSaved[MAX_PLAYERS];
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30. public OnPlayerText(playerid, text[])
  31. {
  32.     AntiFlood[playerid] ++;
  33.     Timer[playerid] = SetTimerEx("FloodPublic", 5000, false, "d", playerid);
  34.  
  35.     if(AntiFlood[playerid] == 3)
  36.     {
  37.         AntiFlood[playerid] = 4;
  38.         KillTimer(Timer[playerid]);
  39.         StartTimer(TimerFlood[playerid], (5*60)); // (5*60) = 5 minutos, cámbialo a tu gusto.
  40.         return SendClientMessage(playerid, -1, "* No hagas Flood."), false;
  41.     }
  42.    
  43.     if(TimerHasHappened(TimerFlood[playerid]) == false)
  44.     {
  45.         new string[144];
  46.         format(string, sizeof(string), "[AntiFlood] Has sido Muteado por hacer Flood por %i Segundos.", ObtainTimer(TimerFlood[playerid]));
  47.         return SendClientMessage(playerid, -1, string), false;
  48.     }
  49.     return 1;
  50. }
  51.  
  52. forward FloodPublic(playerid);
  53. public FloodPublic(playerid)
  54. {
  55.     AntiFlood[playerid] = 0;
  56.     return 1;
  57. }
  58.  
  59.  
  60.  
  61. public OnPlayerConnect(playerid)
  62. {
  63.     new string[100];
  64.     format(string, sizeof(string), DIRECCION, GetName(playerid));
  65.     if(!fexist(string)) return dini_Create(string);
  66.     else
  67.     {
  68.         TimerSaved[playerid] = dini_Int(string, "SecondsMuted");
  69.         if(TimerSaved[playerid] != 0)
  70.         {
  71.             AntiFlood[playerid] = 4;
  72.             StartTimer(TimerFlood[playerid], TimerSaved[playerid]);
  73.         }
  74.     }
  75.     return 1;
  76. }
  77.  
  78. public OnPlayerDisconnect(playerid, reason)
  79. {
  80.     new string[100];
  81.     format(string, sizeof(string), DIRECCION, GetName(playerid));
  82.     dini_IntSet(string, "SecondsMuted", ObtainTimer(TimerFlood[playerid]));
  83.     return 1;
  84. }
  85.  
  86.  
  87.  
  88. stock GetName(playerid)
  89. {
  90.     new Nick[MAX_PLAYER_NAME];
  91.     GetPlayerName(playerid, Nick, sizeof(Nick));
  92.     return Nick;
  93. }
  94.  
  95.  
  96. /* .: By DesingMyCry :. */
  97.  
  98. stock StartTimer(&Timer:timer, const TimerTime)
  99. {
  100.     timer = ((gettime())+(TimerTime));
  101.     return 1;
  102. }
  103.  
  104.  
  105. stock ObtainTimer(Timer:timer)
  106. {
  107.     new CurrentTime = gettime();
  108.     return (_:timer-CurrentTime  <= 0) ? (0) : (_:timer-CurrentTime);
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement