Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*************************************************************************************************************
- ==============================================================================================================
- Nicks Auto server restart with maintenance mode
- This only restarts your server on a regular time that you define
- Or when you do the commands to change.
- This script does not restart your server if it crashes.
- This is my first full Filterscript.
- To edit the defalt time (in Minuets) edit #define TIME (time you want)
- 1441 is defalt minuets time roughly for 24 hours..
- Please do not re-release without my permission or say you made it....being my first fs its not that pretty anyways lol
- Read Everything closely to see how to change the warning time and set the config
- If you find any buggs or have a suggestion for the next version fell free to message me on samp forum, username nickdodd25
- ==================================================================================================================*/
- #include <a_samp>
- #include <sscanf2>
- #tryinclude <timerfix>// If you dont have the timer fix include I recommend it cause the timers will be more accurate.
- #define FILTERSCRIPT
- #if defined FILTERSCRIPT
- #define Color_Red 0xFF0000FF
- #define COLOR_BLUE 0x00FFFFFF
- #define Color_Yellow 0xFFFF00FF
- #define COL_LIGHTBLUE "{00CED1}"
- #define COL_WHITE "{FFFFFF}"
- #define COL_GREEN "{00FF22}"
- #define COL_RED "{F81414}"
- //======================================================================================================================================
- //RESTART CONFIG
- #define TIME 1441 //Edit this for defalt time amount 1441=24 hours.
- #define ServerName "changeme" //Define your server name here.
- #define PassWord "changeme" //to make your own put "Your_Pass_Here"
- #define PassWord2 "0" //"0" means password is getting removed, keep 0 unless your server has a password all the time then put "yourserverpass"
- #define WarningMessage "Restaring My Peeps" //Put your warning message here. If you dont want any chat warning put ""
- #define EnableWelcome true //put to false if you dont want a message on player connect
- //=====================================================================================================================================
- //set to false to disable dialogs if you have other filterscripts using dialogs or the scripts will interfear
- #define EnableDialog true
- //if set to false only commands will work if set to true only dialogs will work
- //=====================================================================================================================================
- // Here Choose what warning limit you want!! Enable/Disable warning time. Only have one true or you will have multiple timers going at once.
- #define Enable10Min true
- #define Enable5Min false
- #define Enable2Min false
- //======================================================================================================================================
- //dialog ids note if you have other filterscripts that use dialogs then set dialogs to false cause the two scripts will interfere
- #define DIALOG_RSP 3000
- #define DIALOG_COMMANDS 3001
- #define DIALOG_RESTART 3002
- //======================================================================================================================================
- //Now that you set the config go to the bottom of the script and remove the last 3 lines and enjoy.
- #define Build "V 2.0"
- //======================================================================================================================================
- //forwards for the timers
- forward Timer_10_MinWarning();
- forward Timer_5_MinWarning();
- forward Timer_2_MinWarning();
- forward Timer_Restart_Kick(playerid);
- forward Timer_Restart_WarnPlayers();
- forward Timer_Restart_Reboot();
- new Timer1;
- new Timer2;
- new Timer3;
- new Timer4;
- new Timer5;
- new Timer6;
- new Timer7;
- new Timer8;
- new Timer9;
- new Timer10;
- //**************************************************************************************************************************************
- public OnFilterScriptInit()
- {
- new year,month,day;
- getdate(year, month, day);
- new hour,minute,second;
- gettime(hour,minute,second);
- print("\n ___________________________________________________");
- print(" -----------------------------------------------------");
- printf(" Auto Restart %s ",Build);
- print(" ------------------ ");
- print(" Nicks Auto Restart/Maintain Mode ");
- printf(" Timer is set for %d minutes. ",TIME);
- print(" ******Simple auto restart***** ");
- print(" First simple script By nickdodd25 ");
- print("------------------------------------------------------");
- print(" ___________________________________________________\n");
- print(" -> Loading...");
- #if Enable10Min == true
- Timer1 = SetTimer("Timer_10_MinWarning", 1000 * 60* TIME, true);
- #endif
- #if Enable5Min == true
- Timer1 = SetTimer("Timer_5_MinWarning", 1000 * 60* TIME, true);
- #endif
- #if Enable2Min == true
- Timer1 = SetTimer("Timer_2_MinWarning", 1000 * 60* TIME, true);
- #endif
- printf(" Date: %d/%d/%d - Time: %d:%d:%d",day,month,year,hour, minute, second);
- return 1;
- }
- public OnFilterScriptExit()
- {
- KillTimer(Timer1);
- KillTimer(Timer2);
- KillTimer(Timer3);
- KillTimer(Timer4);
- KillTimer(Timer5);
- KillTimer(Timer6);
- KillTimer(Timer7);
- KillTimer(Timer8);
- KillTimer(Timer9);
- KillTimer(Timer10);
- new HostCommand1[128];
- new HostCommand2[128];
- format(HostCommand1, 128, "hostname %s", ServerName);
- format(HostCommand2, 128, "password %s", PassWord2);
- SendRconCommand(HostCommand1);
- SendRconCommand(HostCommand2);
- return 1;
- }
- #else
- main()
- {
- print("\n----------------------------------");
- print(" ******Simple auto restart*****");
- print(" First simple script By nickdodd25");
- print("----------------------------------\n");
- }
- #endif
- public OnPlayerConnect(playerid)
- {
- #if EnableWelcome == true
- SendClientMessage(playerid,Color_Yellow, ""ServerName" is using 24hour auto restart "Build" By nickdod25");
- #endif
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- #if EnableDialog == true
- if (!strcmp("/rsp", cmdtext, true))
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Color_Red,"Only admins can use this command");
- ShowPlayerDialog(playerid, DIALOG_RSP, DIALOG_STYLE_LIST,""COL_WHITE"Restart Pannel "COL_LIGHTBLUE"By: nickdodd25",""COL_LIGHTBLUE"Restart Commands\n"COL_LIGHTBLUE"Stop Restart\n"COL_LIGHTBLUE"2 minute restart\n"COL_LIGHTBLUE"5 minute restart\n"COL_LIGHTBLUE"10 minuterestart\n"COL_LIGHTBLUE"24 hour restart\n"COL_LIGHTBLUE"Start maintain mode\n"COL_LIGHTBLUE"Stop maintain mode\n"COL_LIGHTBLUE"Restart","Ok","Cancel");
- return 1;
- }
- #endif
- #if EnableDialog == false
- if (!strcmp("/rscmds", cmdtext, true))
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Color_Red,"Only admins can use this command");
- SendClientMessage(playerid,Color_Yellow,"=====******Rcon admins restart cmds cfg*******===");
- SendClientMessage(playerid,Color_Yellow,"| /2min | /5min | /10min | /stoprestart | /24hour |");
- SendClientMessage(playerid,Color_Yellow,"==***| /maintain | /maintaindone | /restart |***==");
- return 1;
- }
- if (!strcmp("/stoprestart", cmdtext, true))
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Color_Red,"Only admins can use this command");
- KillTimer(Timer1);
- KillTimer(Timer2);
- KillTimer(Timer3);
- KillTimer(Timer4);
- KillTimer(Timer5);
- KillTimer(Timer6);
- KillTimer(Timer7);
- KillTimer(Timer8);
- KillTimer(Timer9);
- KillTimer(Timer10);
- new pName[MAX_PLAYER_NAME], string[56];
- GetPlayerName(playerid, pName, sizeof(pName));
- format(string, sizeof(string), "Admin %s has stop auto restart", pName);
- SendClientMessageToAll(COLOR_BLUE, string);
- print(string);
- new HostCommand1[128];
- format(HostCommand1, 128, "hostname %s Testing restart.", ServerName);
- SendRconCommand(HostCommand1);
- return 1;
- }
- if (!strcmp("/2min", cmdtext, true))
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Color_Red, "Only admins can use this command");
- KillTimer(Timer1);
- KillTimer(Timer2);
- KillTimer(Timer3);
- KillTimer(Timer4);
- KillTimer(Timer5);
- KillTimer(Timer6);
- KillTimer(Timer7);
- KillTimer(Timer8);
- KillTimer(Timer9);
- KillTimer(Timer10);
- Timer5 = SetTimer("Timer_2_MinWarning", 1000, false);
- new pName[MAX_PLAYER_NAME], string[56];
- GetPlayerName(playerid, pName, sizeof(pName));
- format(string, sizeof(string), "Admin %s has started 2 minute restart!", pName);
- SendClientMessageToAll(COLOR_BLUE, string);
- print(string);
- return 1;
- }
- if (!strcmp("/5min", cmdtext, true))
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Color_Red, "Only admins can use this command");
- KillTimer(Timer1);
- KillTimer(Timer2);
- KillTimer(Timer3);
- KillTimer(Timer4);
- KillTimer(Timer5);
- KillTimer(Timer6);
- KillTimer(Timer7);
- KillTimer(Timer8);
- KillTimer(Timer9);
- KillTimer(Timer10);
- Timer6 = SetTimer("Timer_5_MinWarning", 1000, false);
- new pName[MAX_PLAYER_NAME], string[56];
- GetPlayerName(playerid, pName, sizeof(pName));
- format(string, sizeof(string), "Admin %s has started 5 minute restart!", pName);
- SendClientMessageToAll(COLOR_BLUE, string);
- print(string);
- return 1;
- }
- if (!strcmp("/10min", cmdtext, true))
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Color_Red, "Only admins can use this command");
- KillTimer(Timer1);
- KillTimer(Timer2);
- KillTimer(Timer3);
- KillTimer(Timer4);
- KillTimer(Timer5);
- KillTimer(Timer6);
- KillTimer(Timer7);
- KillTimer(Timer8);
- KillTimer(Timer9);
- KillTimer(Timer10);
- Timer7 = SetTimer("Timer_10_MinWarning", 1000, false);
- new pName[MAX_PLAYER_NAME], string[56];
- GetPlayerName(playerid, pName, sizeof(pName));
- format(string, sizeof(string), "Admin %s has started 10 minute restart!", pName);
- SendClientMessageToAll(COLOR_BLUE, string);
- print(string);
- return 1;
- }
- if (!strcmp("/24hour", cmdtext, true))
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Color_Red, "Only admins can use this command");
- KillTimer(Timer1);
- KillTimer(Timer2);
- KillTimer(Timer3);
- KillTimer(Timer4);
- KillTimer(Timer5);
- KillTimer(Timer6);
- KillTimer(Timer7);
- KillTimer(Timer8);
- KillTimer(Timer9);
- KillTimer(Timer10);
- Timer8 = SetTimer("Timer_10_MinWarning", 1000 * 60* TIME, false);
- new pName[MAX_PLAYER_NAME], string[56];
- GetPlayerName(playerid, pName, sizeof(pName));
- format(string, sizeof(string), "Admin %s has started %d minute restart!", pName, TIME);
- SendClientMessageToAll(COLOR_BLUE, string);
- print(string);
- return 1;
- }
- if (!strcmp("/maintain", cmdtext, true))
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Color_Red, "Only admins can use this command");
- new pName[MAX_PLAYER_NAME], string[56];
- GetPlayerName(playerid, pName, sizeof(pName));
- format(string, sizeof(string), "Admin %s has has put server in maintanence mode.", pName);
- SendClientMessageToAll(COLOR_BLUE, string);
- SendClientMessageToAll(COLOR_BLUE, "Kicking all players");
- print(string);
- new HostCommand1[128];
- new HostCommand2[50];
- printf(" %s is now in maintainece mode, type donemaintain to unlock server.",ServerName);
- format(HostCommand1, 128, "hostname %s in Mantainence Mode..Please Wait.", ServerName);
- format(HostCommand2, 50, "password %s", PassWord);
- for(new i; i < MAX_PLAYERS; i++)
- if(!IsPlayerAdmin(playerid))
- {
- Kick(i);
- }
- SendRconCommand(HostCommand1);
- SendRconCommand(HostCommand2);
- return 1;
- }
- if(!strcmp("/donemaintain", cmdtext, true))
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Color_Red, "Only admins can use this command");
- new HostCommand1[128];
- new HostCommand2[50];
- printf(" %s is now out of maintainece mode", ServerName);
- format(HostCommand1, 128, "hostname %s", ServerName);
- format(HostCommand2, 50, "password %s", PassWord2);
- SendRconCommand(HostCommand1);
- SendRconCommand(HostCommand2);
- SendClientMessageToAll(COLOR_BLUE, "You have taken server out of maintainence mode.");
- return 1;
- }
- if(!strcmp(cmdtext,"/restart", true, 8))
- {
- KillTimer(Timer1);
- KillTimer(Timer2);
- KillTimer(Timer3);
- KillTimer(Timer4);
- KillTimer(Timer5);
- KillTimer(Timer6);
- KillTimer(Timer7);
- KillTimer(Timer8);
- KillTimer(Timer9);
- KillTimer(Timer10);
- new rsdelay, string[128];
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Color_Red, "Only admins can use this command");
- if(sscanf(cmdtext[9],"d",rsdelay)) return SendClientMessage(playerid,Color_Red, "USAGE: /restart <time in minutes>");
- if(rsdelay == 0) return SendClientMessage(playerid,Color_Red,"Time must be more than 1 minute.");
- {
- Timer10 = SetTimer("Timer_Restart_Kick", rsdelay*1000*60,false);
- format(string,sizeof(string),"The server will restart in %d minutes.",rsdelay);
- SendClientMessageToAll(COLOR_BLUE,string);
- GameTextForAll(string, 5000, 3);
- }
- return 1;
- }
- #endif
- return 0;
- }
- public OnRconCommand(cmd[])
- {
- if(strcmp(cmd, "2min", true)==0)
- {
- printf(" You have started 2 minutet restart");
- KillTimer(Timer1);
- KillTimer(Timer2);
- KillTimer(Timer3);
- KillTimer(Timer4);
- KillTimer(Timer5);
- KillTimer(Timer6);
- KillTimer(Timer7);
- KillTimer(Timer8);
- KillTimer(Timer9);
- KillTimer(Timer10);
- Timer5 = SetTimer("Timer_2_MinWarning", 100, false);
- SendClientMessageToAll(COLOR_BLUE, "Owner/Admin has started 2 minute restart!");
- return 1;
- }
- if(strcmp(cmd, "5min", true)==0)
- {
- printf(" You have started 5 minutet restart");
- KillTimer(Timer1);
- KillTimer(Timer2);
- KillTimer(Timer3);
- KillTimer(Timer4);
- KillTimer(Timer5);
- KillTimer(Timer6);
- KillTimer(Timer7);
- KillTimer(Timer8);
- KillTimer(Timer9);
- KillTimer(Timer10);
- Timer5 = SetTimer("Timer_5_MinWarning", 100, false);
- SendClientMessageToAll(COLOR_BLUE, "Owner/Admin has started 5 minute restart!");
- }
- if(strcmp(cmd, "10min", true)==0)
- {
- printf(" You have started 10 minutet restart");
- KillTimer(Timer1);
- KillTimer(Timer2);
- KillTimer(Timer3);
- KillTimer(Timer4);
- KillTimer(Timer5);
- KillTimer(Timer6);
- KillTimer(Timer7);
- KillTimer(Timer8);
- KillTimer(Timer9);
- KillTimer(Timer10);
- Timer5 = SetTimer("Timer_10_MinWarning", 100, false);
- SendClientMessageToAll(COLOR_BLUE, "Owner/Admin has started 10 minute restart!");
- return 1;
- }
- if(strcmp(cmd, "stoprestart", true)==0)
- {
- printf("You have stopped restart");
- KillTimer(Timer1);
- KillTimer(Timer2);
- KillTimer(Timer3);
- KillTimer(Timer4);
- KillTimer(Timer5);
- KillTimer(Timer6);
- KillTimer(Timer7);
- KillTimer(Timer8);
- KillTimer(Timer9);
- KillTimer(Timer10);
- SendClientMessageToAll(COLOR_BLUE, "Owner/Admin has stopped restart!");
- new HostCommand1[128];
- format(HostCommand1, 128, "hostname %s Testing restart.", ServerName);
- SendRconCommand(HostCommand1);
- return 1;
- }
- if(strcmp(cmd, "24hour", true)==0)
- {
- printf("You have started 24 hour auto restart");
- KillTimer(Timer1);
- KillTimer(Timer2);
- KillTimer(Timer3);
- KillTimer(Timer4);
- KillTimer(Timer5);
- KillTimer(Timer6);
- KillTimer(Timer7);
- KillTimer(Timer8);
- KillTimer(Timer9);
- KillTimer(Timer10);
- Timer8 = SetTimer("Timer_10_MinWarning", 1000 * 60* TIME, false);
- new string[56];
- format(string, sizeof(string), "Owner/Admin has started %d minute restart!", TIME);
- SendClientMessageToAll(COLOR_BLUE, string);
- return 1;
- }
- if(strcmp(cmd, "maintain", true)==0)
- {
- new HostCommand1[128];
- new HostCommand2[128];
- printf("%s is now in maintainece mode, type donemaintain to unlock server.",ServerName);
- for(new i; i < MAX_PLAYERS; i++)
- Kick(i);
- format(HostCommand1, 128, "hostname %s in Mantainence Mode..Please Wait.", ServerName);
- format(HostCommand2, 128, "password %s", PassWord);
- SendRconCommand(HostCommand1);//Puts "in Maintainence Mode..Please Wait after your server name.
- SendRconCommand(HostCommand2);//locks the server with the pass you defined on PassWord
- return 1;
- }
- if(strcmp(cmd, "donemaintain", true)==0)
- {
- new HostCommand1[128];
- new HostCommand2[128];
- printf("%s is now out of maintainece mode", ServerName);
- format(HostCommand1, 128, "hostname %s", ServerName);
- format(HostCommand2, 128, "password %s", PassWord2);
- SendRconCommand(HostCommand1);//Sets your server name back to normal
- SendRconCommand(HostCommand2);//this sets pass to 0 unlock the server unless you change PassWord2 define
- return 1;
- }
- if(strcmp(cmd, "rscmds", true)==0)
- {
- print("*** stoprestart ***");
- print("****** 10min ******");
- print("****** 5min *******");
- print("****** 2min *******");
- print("****** 24hour *****");
- print("***** maintain ****");
- print("*** maintaindone **");
- return 1;
- }
- return 0;
- }
- public Timer_10_MinWarning()// 10 minute restart timer
- {
- print("\n====================================");
- printf(" %d minutes are up Server Now restarting.",TIME);
- print("******10 Minute Restart warning*******");
- print("======================================\n");
- GameTextForAll("Server Restart in 10 minutes!", 5000, 3);
- SendClientMessageToAll(COLOR_BLUE, WarningMessage);
- Timer2 = SetTimer("Timer_5_MinWarning", 1000 * 60* 5, false);
- return 1;
- }
- public Timer_5_MinWarning()// 5 minute restart timer
- {
- print("\n======================================");
- printf(" %d minutes are up Server Now restarting.",TIME);
- print("********5 Minute Restart Warning********");
- print("=========================================\n");
- GameTextForAll("Server Restart in 5 minutes!", 5000, 3);
- SendClientMessageToAll(COLOR_BLUE, WarningMessage);
- Timer3 = SetTimer("Timer_2_MinWarning", 1000 * 60* 3, false);
- return;
- }
- public Timer_2_MinWarning()// 2 minute restart timer
- {
- print("\n===================================");
- printf(" %d minutes are up Server Now restarting.",TIME);
- print(" ********AUTO SERVER RESTART********");
- print("=====================================\n");
- GameTextForAll("Server restart in 2 minutes!", 5000, 3);
- SendClientMessageToAll(COLOR_BLUE, WarningMessage);
- SendClientMessageToAll(COLOR_BLUE, "Server restart in 2 minutes!");
- Timer4 = SetTimer("Timer_Restart_WarnPlayers", 1000 * 60, false);
- return 1;
- }
- public Timer_Restart_WarnPlayers()
- {
- print("\n===================================");
- print(" *********1 Minute Warning***********");
- print("=====================================\n");
- new HostCommand1[128];
- new HostCommand2[128];
- GameTextForAll("Server restart in 1 minute!", 5000, 3);
- SendClientMessageToAll(COLOR_BLUE, "Server restart in 1 minutes!");
- SendClientMessageToAll(COLOR_BLUE, WarningMessage);
- SetTimer("Timer_Restart_Kick", 1000 * 60, false);
- // Change the hostname of the server and it's password
- format(HostCommand1, 128, "hostname %s Pending restart......", ServerName);
- SendRconCommand(HostCommand1);
- format(HostCommand2, 128, "password %s", PassWord);//this locks the server so new people cant join during restart.
- SendRconCommand(HostCommand2);
- return 1;
- }
- public Timer_Restart_Kick(playerid)
- {
- // Let everyone know that the server is kicking all players before restarting
- GameTextForAll("Server restarting:Kicking all players!", 5000, 3);
- // Kick all players
- /*for(new i; i < MAX_PLAYERS; i++)
- Kick(i);*/
- for(new i; i < MAX_PLAYERS; i++)
- if(!IsPlayerAdmin(playerid))
- {
- Kick(i);
- }
- // Start the next timer that will restart the server
- SetTimer("Timer_Restart_Reboot", 1000 * 5, false);
- return 1;
- }
- public Timer_Restart_Reboot()
- {
- // Restart the server
- SendRconCommand("gmx");
- //=========================================================================
- //SendRconCommand("reloadfs Your_Filterscript_Here");//with this line you may also restart separate Filterscripts
- SendRconCommand("reloadfs shipfail3");
- //=========================================================================
- print("\n===================================");
- print(" ******Server Auto Restarting********");
- print("=====================================\n");
- new HostCommand2[128];
- format(HostCommand2, 128, "password %s", PassWord2);
- SendRconCommand(HostCommand2);
- new year,month,day;
- getdate(year, month, day);
- new hour,minute,second;
- gettime(hour,minute,second);
- printf(" Date: %d/%d/%d - Time: %d:%d:%d",day,month,year,hour, minute, second);
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch( dialogid )
- {
- case DIALOG_RSP:
- {
- if(!response) return SendClientMessage(playerid,Color_Yellow,"You closed the Rsp panel");
- if(response)
- {
- if (listitem == 0)
- {
- new pDialog[550];
- strcat(pDialog, ""COL_WHITE" =====******Rcon admins restart cmds cfg*******===\n", sizeof(pDialog));
- strcat(pDialog, ""COL_LIGHTBLUE"/rsp opens the Restart Pannel\n", sizeof(pDialog));
- strcat(pDialog, "/rscmds Shows commands for restarting\n", sizeof(pDialog));
- strcat(pDialog, "/2min Restarts the server in 2 minutes\n", sizeof(pDialog));
- strcat(pDialog, "/5min Restarts the server in 5 minutes\n", sizeof(pDialog));
- strcat(pDialog, "/10min Restarts the server in 10 minutes\n", sizeof(pDialog));
- strcat(pDialog, "/24hour Starts 24 hour (defalt is 1441 minutes or what ever it has been set to) restart\n", sizeof(pDialog));
- strcat(pDialog, "/maintain Starts maintainence mode\n", sizeof(pDialog));
- strcat(pDialog, "/donemaintain Stops maintainence mode\n", sizeof(pDialog));
- strcat(pDialog, "/restart Restarts the server at the time you input(NOTE: will not call the warning timers)\n", sizeof(pDialog));
- ShowPlayerDialog(playerid, DIALOG_COMMANDS, DIALOG_STYLE_MSGBOX,""COL_WHITE"Restart Commands",pDialog,"Ok","");
- }
- if (listitem == 1)
- {
- KillTimer(Timer1);
- KillTimer(Timer2);
- KillTimer(Timer3);
- KillTimer(Timer4);
- KillTimer(Timer5);
- KillTimer(Timer6);
- KillTimer(Timer7);
- KillTimer(Timer8);
- KillTimer(Timer9);
- KillTimer(Timer10);
- new pName[MAX_PLAYER_NAME], string[56];
- GetPlayerName(playerid, pName, sizeof(pName));
- format(string, sizeof(string), "Admin %s has stop auto restart", pName);
- SendClientMessageToAll(COLOR_BLUE, string);
- print(string);
- new HostCommand1[128];
- format(HostCommand1, 128, "hostname %s Testing restart.", ServerName);
- SendRconCommand(HostCommand1);
- }
- if (listitem == 2)
- {
- KillTimer(Timer1);
- KillTimer(Timer2);
- KillTimer(Timer3);
- KillTimer(Timer4);
- KillTimer(Timer5);
- KillTimer(Timer6);
- KillTimer(Timer7);
- KillTimer(Timer8);
- KillTimer(Timer9);
- KillTimer(Timer10);
- Timer5 = SetTimer("Timer_2_MinWarning", 1000, false);
- new pName[MAX_PLAYER_NAME], string[56];
- GetPlayerName(playerid, pName, sizeof(pName));
- format(string, sizeof(string), "Admin %s has started 2 minute restart!", pName);
- SendClientMessageToAll(COLOR_BLUE, string);
- print(string);
- }
- if (listitem == 3)
- {
- KillTimer(Timer1);
- KillTimer(Timer2);
- KillTimer(Timer3);
- KillTimer(Timer4);
- KillTimer(Timer5);
- KillTimer(Timer6);
- KillTimer(Timer7);
- KillTimer(Timer8);
- KillTimer(Timer9);
- KillTimer(Timer10);
- Timer6 = SetTimer("Timer_5_MinWarning", 1000, false);
- new pName[MAX_PLAYER_NAME], string[56];
- GetPlayerName(playerid, pName, sizeof(pName));
- format(string, sizeof(string), "Admin %s has started 5 minute restart!", pName);
- SendClientMessageToAll(COLOR_BLUE, string);
- print(string);
- }
- if (listitem == 4)
- {
- KillTimer(Timer1);
- KillTimer(Timer2);
- KillTimer(Timer3);
- KillTimer(Timer4);
- KillTimer(Timer5);
- KillTimer(Timer6);
- KillTimer(Timer7);
- KillTimer(Timer8);
- KillTimer(Timer9);
- KillTimer(Timer10);
- Timer7 = SetTimer("Timer_10_MinWarning", 1000, false);
- new pName[MAX_PLAYER_NAME], string[56];
- GetPlayerName(playerid, pName, sizeof(pName));
- format(string, sizeof(string), "Admin %s has started 10 minute restart!", pName);
- SendClientMessageToAll(COLOR_BLUE, string);
- print(string);
- }
- if (listitem == 5)
- {
- KillTimer(Timer1);
- KillTimer(Timer2);
- KillTimer(Timer3);
- KillTimer(Timer4);
- KillTimer(Timer5);
- KillTimer(Timer6);
- KillTimer(Timer7);
- KillTimer(Timer8);
- KillTimer(Timer9);
- KillTimer(Timer10);
- Timer8 = SetTimer("Timer_10_MinWarning", 1000 * 60* TIME, false);
- new pName[MAX_PLAYER_NAME], string[56];
- GetPlayerName(playerid, pName, sizeof(pName));
- format(string, sizeof(string), "Admin %s has started %d minute restart!", pName, TIME);
- SendClientMessageToAll(COLOR_BLUE, string);
- print(string);
- }
- if (listitem == 6)
- {
- new pName[MAX_PLAYER_NAME], string[56];
- GetPlayerName(playerid, pName, sizeof(pName));
- format(string, sizeof(string), "Admin %s has has put server in maintanence mode.", pName);
- SendClientMessageToAll(COLOR_BLUE, string);
- SendClientMessageToAll(COLOR_BLUE, "Kicking all players");
- print(string);
- new HostCommand1[128];
- new HostCommand2[50];
- printf("%s is now in maintainece mode, type donemaintain to unlock server.",ServerName);
- format(HostCommand1, 128, "hostname %s in Mantainence Mode..Please Wait.", ServerName);
- format(HostCommand2, 50, "password %s", PassWord);
- for(new i; i < MAX_PLAYERS; i++)
- if(!IsPlayerAdmin(playerid))
- {
- Kick(i);
- }
- SendRconCommand(HostCommand1);
- SendRconCommand(HostCommand2);
- }
- if (listitem == 7)
- {
- new HostCommand1[128];
- new HostCommand2[50];
- printf("%s is now out of maintainece mode", ServerName);
- format(HostCommand1, 128, "hostname %s", ServerName);
- format(HostCommand2, 50, "password %s", PassWord2);
- SendRconCommand(HostCommand1);
- SendRconCommand(HostCommand2);
- SendClientMessageToAll(COLOR_BLUE, "You have taken server out of maintainence mode.");
- }
- if (listitem == 8)
- {
- ShowPlayerDialog(playerid, DIALOG_RESTART, DIALOG_STYLE_INPUT,""COL_WHITE"Restart","USAGE: Restart <in minutes>\nNOTE: will not call the warning timers.","Ok","");
- }
- }
- }
- case DIALOG_RESTART:
- {
- if( !response ) return SendClientMessage(playerid,Color_Red,"You Closed the Restart dialog!");
- if( response )
- {
- if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_RESTART, DIALOG_STYLE_INPUT, ""COL_WHITE"Restart...",""COL_RED"You have entered an invalid or no Time limit.\n"COL_WHITE"Make sure your time is in minutes!","Ok","Cancel");
- KillTimer(Timer1);
- KillTimer(Timer2);
- KillTimer(Timer3);
- KillTimer(Timer4);
- KillTimer(Timer5);
- KillTimer(Timer6);
- KillTimer(Timer7);
- KillTimer(Timer8);
- KillTimer(Timer9);
- KillTimer(Timer10);
- new rsdelay, string[128];
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Color_Red, "Only admins can use this command");
- if(sscanf(inputtext,"d",rsdelay)) return ShowPlayerDialog(playerid, DIALOG_RESTART, DIALOG_STYLE_INPUT, ""COL_WHITE"Restart...",""COL_RED"You have entered an invalid or no Time limit.\n"COL_WHITE"Make sure your time is in minutes!","Ok","Cancel");
- if(rsdelay == 0) return SendClientMessage(playerid,Color_Red,"Time must be more than 1 minute.");
- {
- Timer10 = SetTimer("Timer_Restart_Kick", rsdelay*1000*60,false);
- format(string,sizeof(string),"The server will restart in %d minutes.",rsdelay);
- SendClientMessageToAll(COLOR_BLUE,string);
- GameTextForAll(string, 5000, 3);
- }
- }
- }
- }
- return 1;
- }
- #if !defined Restart_Config
- #error Set your Restart Config before using please!!!!
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement