Advertisement
Guest User

Untitled

a guest
Nov 10th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.15 KB | None | 0 0
  1. #include <a_samp>
  2. #include <izcmd>
  3. #include <sscanf2>
  4.  
  5. new Timer_Restart;
  6.  
  7. new Counter_Restart;
  8. new bool:IsRestartStarted;
  9.  
  10. new Text:TD_Title;
  11. new Text:TD_Reason;
  12. new Text:TD_Countdown;
  13.  
  14. public OnFilterScriptInit()
  15. {
  16.     TD_Title = TextDrawCreate(264.000000, 367.000000, "Server restart");
  17.     TextDrawAlignment(TD_Title, 0);
  18.     TextDrawBackgroundColor(TD_Title, 0x000000ff);
  19.     TextDrawFont(TD_Title, 1);
  20.     TextDrawLetterSize(TD_Title, 0.399999, 1.300000);
  21.     TextDrawColor(TD_Title, 0xFF0000FF);
  22.     TextDrawSetOutline(TD_Title, 1);
  23.     TextDrawSetProportional(TD_Title, 1);
  24.     TextDrawSetShadow(TD_Title, 1);
  25.    
  26.     TD_Reason = TextDrawCreate(264.000000, 377.000000, "Reason:");
  27.     TextDrawAlignment(TD_Reason, 0);
  28.     TextDrawBackgroundColor(TD_Reason, 0x000000ff);
  29.     TextDrawFont(TD_Reason, 1);
  30.     TextDrawLetterSize(TD_Reason, 0.399999, 1.300000);
  31.     TextDrawColor(TD_Reason, 0xffffffff);
  32.     TextDrawSetOutline(TD_Reason, 1);
  33.     TextDrawSetProportional(TD_Reason, 1);
  34.     TextDrawSetShadow(TD_Reason, 1);
  35.  
  36.     TD_Countdown = TextDrawCreate(264.000000, 387.000000, "Countdown:");
  37.     TextDrawAlignment(TD_Countdown, 0);
  38.     TextDrawBackgroundColor(TD_Countdown, 0x000000ff);
  39.     TextDrawFont(TD_Countdown, 1);
  40.     TextDrawLetterSize(TD_Countdown, 0.399999, 1.300000);
  41.     TextDrawColor(TD_Countdown, 0xffffffff);
  42.     TextDrawSetOutline(TD_Countdown, 1);
  43.     TextDrawSetProportional(TD_Countdown, 1);
  44.     TextDrawSetShadow(TD_Countdown, 1);
  45.    
  46.     return 1;
  47. }
  48.  
  49. public OnPlayerConnect(playerid)
  50. {
  51.     return 1;
  52. }
  53.  
  54. public OnPlayerDisconnect(playerid, reason)
  55. {
  56.     return 1;
  57. }
  58.  
  59. public OnFilterScriptExit()
  60. {
  61.     TextDrawDestroy(TD_Title);
  62.     TextDrawDestroy(TD_Countdown);
  63.     TextDrawDestroy(TD_Reason);
  64.    
  65.     return 1;
  66. }
  67.  
  68. public OnPlayerCommandReceived(playerid,cmdtext[])
  69. {
  70.     return 1;
  71. }
  72.  
  73. public OnPlayerCommandPerformed(playerid,cmdtext[], success)
  74. {
  75.     if(!success) return SendClientMessage(playerid, -1, "That command doesn't exist. Type /commands for the list of all commands.");
  76.  
  77.     return success;
  78. }
  79.  
  80. COMMAND:rr(playerid, params[])
  81. {
  82.     if(!IsPlayerAdmin(playerid))
  83.     return 0;
  84.  
  85.     new timer, reason;
  86.     if(sscanf(params, "is[128]", timer, reason)) return SendClientMessage(playerid, -1, "[USAGE] /rr [Time] [Reason]");
  87.    
  88.     if(IsRestartStarted) return SendClientMessage(playerid, -1, "Countdown has been started already.");
  89.    
  90.     new string[256];
  91.    
  92.     format(string, sizeof(string), "Reason: %s", reason);
  93.     TextDrawSetString(TD_Reason, string);
  94.    
  95.     format(string, sizeof(string), "Countdown: %d", timer);
  96.     TextDrawSetString(TD_Countdown, string);
  97.    
  98.     TextDrawShowForAll(TD_Title);
  99.     TextDrawShowForAll(TD_Reason);
  100.     TextDrawShowForAll(TD_Countdown);
  101.  
  102.     Counter_Restart = timer;
  103.     Timer_Restart = SetTimer("OnTimerUpdate", 1000, true);
  104.     IsRestartStarted = true;
  105.    
  106.     return 1;
  107. }
  108.  
  109. forward OnTimerUpdate();
  110. public OnTimerUpdate()
  111. {
  112.     new string[64];
  113.     format(string, sizeof(string), "Countdown: %d", Counter_Restart);
  114.     TextDrawSetString(TD_Countdown, string);
  115.  
  116.     switch(Counter_Restart)
  117.     {
  118.         case 10:
  119.         {
  120.             SendClientMessageToAll(-1, "Kicking players");
  121.         }
  122.        
  123.         case 0:
  124.         {
  125.             KillTimer(Timer_Restart);
  126.             IsRestartStarted = false;
  127.         }
  128.     }
  129.    
  130.     Counter_Restart--;
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement