toribio

toribio

Jul 2nd, 2009
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. SetTimer("RemoteKickTimer", 10000, 1); //10 segundos, MySQL constante iria lagar MUITO o server
  2.  
  3. public RemoteKickTimer()
  4. {
  5.     for(new i; i < MAX_PLAYERS; i++)
  6.     {
  7.         if(samp_mysql_ping() != 0) break;
  8.         if(!IsPlayerConnected(i)) continue;
  9.  
  10.         new query[256], nome[MAX_PLAYER_NAME];
  11.  
  12.         GetPlayerName(i, nome, sizeof nome);
  13.  
  14.         format(query, sizeof query, "SELECT `kick` FROM `users` WHERE `nick` = '%s'", nome);
  15.  
  16.         samp_mysql_query(query);
  17.         samp_mysql_store_result();
  18.  
  19.         if(samp_mysql_num_rows() == 1)
  20.         {
  21.             new kick[4], reason[64], string[128];
  22.  
  23.             samp_mysql_fetch_row(kick);
  24.    
  25.             if(strval(kick))
  26.             {
  27.                 format(query, sizeof query, "SELECT `kickreason` FROM `users` WHERE `nick` = '%s'", nome);
  28.  
  29.                 samp_mysql_query(query);
  30.                 samp_mysql_store_result();
  31.  
  32.                 if(samp_mysql_num_rows() == 1)
  33.                 {
  34.                     samp_mysql_fetch_row(reason);
  35.                     format(string, sizeof string, "%s foi kickado remotamente. Razão: %s", nome, reason);
  36.                     SendClientMessageToAll(0xFF0000AA, string);
  37.                 }
  38.                 format(query, sizeof query, "UPDATE `users` SET `kick` = 0, `kickreason` = NULL WHERE `nick` = '%s'", nome);
  39.                 samp_mysql_query(query);
  40.                 Kick(i);
  41.             }
  42.         }
  43.     }
  44. }
Add Comment
Please, Sign In to add comment