Advertisement
dEcooR

Simple Rcon Restart

Jun 30th, 2013
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.08 KB | None | 0 0
  1. /*
  2.     Simple Rcon Restart by dEcooR ©
  3. */
  4.  
  5. #include <a_samp>
  6. #include <zcmd>
  7. #include <sscanf2>
  8.  
  9. #define FILE "restarts.log"
  10. #define MAX_SECONDS 600 // 10 minutes
  11.  
  12. #define CO_ORANGE 0xFF9900AA
  13. #define CO_RED 0xF81414AA
  14. #define W "{FFFFFF}"
  15.  
  16. new count = -1,restart,started = 0;
  17.  
  18. CMD:restart(playerid, params[])
  19. {
  20.     new secs;
  21.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,CO_ORANGE,"You are not the admin !");
  22.     else if(sscanf(params, "d", secs)) return SendClientMessage(playerid, CO_ORANGE, "Type: "W"/restart [ Seconds ]");
  23.     else if(started == 1) return SendClientMessage(playerid, CO_ORANGE, "One timer for the restart is already started wait please!");
  24.     else if(secs > MAX_SECONDS) return SendClientMessage(playerid, CO_ORANGE, "Maximum of seconds is 10 minutes!");
  25.     else
  26.     {
  27.         new string[100],string2[100],rstring[100],Name[MAX_PLAYER_NAME],
  28.             year,month,day,hour,minute,second;
  29.            
  30.         getdate(year, month, day);
  31.         gettime(hour,minute,second);
  32.            
  33.         GetPlayerName(playerid,Name,24);
  34.         format(string2,100,"Administrator %s has started timer to restart the server for %d seconds.",Name,secs);
  35.         format(string,100,"~r~WARNING ] ~g~Server restart in %d seconds.",secs);
  36.         GameTextForAll(string, 3800, 4);
  37.         SendClientMessageToAll(CO_RED,string2);
  38.        
  39.         format(rstring, sizeof(rstring), "Name: %s - Time: %d:%d:%d - Date: %d/%d/%d\n", Name,hour, minute, second,day,month,year);
  40.  
  41.         new File:restarts = fopen(FILE, io_write);
  42.         fwrite(restarts, rstring);
  43.         fclose(restarts);
  44.        
  45.         count = secs;
  46.         restart = SetTimerEx("RestartGM",1000,true,"i",playerid);
  47.         started = 1;
  48.     }
  49.     return 1;
  50. }
  51.  
  52. forward RestartGM();
  53. public RestartGM()
  54. {
  55.     new counts[100];
  56.    
  57.     count--;
  58.     format(counts,1000,"~n~~n~~n~~n~~n~~n~~n~~n~       ~y~Server restart in: ~g~%d",count);
  59.     GameTextForAll(counts,1000,3);
  60.  
  61.     if(count == 0)
  62.     {
  63.         for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) SendRconCommand("gmx");
  64.  
  65.         GameTextForAll("~w~]~r~Restaring Server..~n~~y~wait please",5000,3);
  66.         KillTimer(restart);
  67.         count = 0;
  68.         started = 0;
  69.     }
  70.     return 1;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement