Advertisement
JaQQeri

SA-MP Restart

Nov 21st, 2012
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.02 KB | None | 0 0
  1. //Restart server via RCON exit, without forcing the players to reconnect
  2.  
  3. #include <a_samp>
  4. #include <zcmd>
  5.  
  6. forward Exec();
  7.  
  8. new PIP[MAX_PLAYERS][16];
  9. new RestartTimer;
  10.  
  11. public OnFilterScriptInit()
  12. {
  13.  
  14.     return 1;
  15. }
  16.  
  17. public OnFilterScriptExit()
  18. {
  19.     return 1;
  20. }
  21.  
  22. public Exec()
  23. {
  24.     new cmd[64];
  25.     for (new i=0;i<MAX_PLAYERS;i++)
  26.     {
  27.         if (strlen(PIP[i]))
  28.         {
  29.             format(cmd,sizeof(cmd),"unbanip %s", PIP[i]);
  30.             SendRconCommand(cmd);
  31.         }
  32.     }
  33.     SendRconCommand("exit");
  34. }
  35.  
  36. CMD:restart(playerid)
  37. {
  38.     RestartServer();
  39.     return 1;
  40. }
  41.  
  42. stock RestartServer()
  43. {
  44.    for (new i=0;i<MAX_PLAYERS;i++)
  45.    {
  46.        if (IsPlayerConnected(i))
  47.        {
  48.            new PlayerIP[16], cmd[64];
  49.            GetPlayerIp(i, PlayerIP, sizeof(PlayerIP));
  50.            format(cmd,sizeof(cmd),"banip %s", PlayerIP);
  51.            SendRconCommand(cmd);
  52.            PIP[i] = PlayerIP;
  53.            RestartTimer = SetTimer("Exec", 3000,0); // Server will unban the IPs in 3 seconds and then kill the server
  54.        }
  55.     }
  56.      
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement