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
- If you find any buggs or have a suggestion for the next version fell free to message me on samp forum, username nickdodd25
- Enjoy :D
- ========================================================================================================================================*/
- #include <a_samp>
- #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
- //--------------------------------------------------------------------------------------------------------------------------------------
- //======================================================================================================================================
- //RESTART CONFIG
- #define TIME 1441 //Edit this for defalt time amount 1441=24 hours. Being in a filterscript the timer is slower so could make it about 900 minutes
- #define ServerName "Your server name" //Define your server name here.
- #define PassWord "changeme" //this locks the server for maintenance mode and before restart so people cant join, 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 "Please Do Not start any missions untill after restart!" //Put your warning message here. If you dont want any chat warning put ""
- // 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
- //Now that you set the config go to the bottom of the script and remove the last 3 lines and enjoy.
- #define Build "V 1.0.5"
- //======================================================================================================================================
- //--------------------------------------------------------------------------------------------------------------------------------------
- //**************************************************************************************************************************************
- new Timer1;
- new Timer2;
- new Timer3;
- new Timer4;
- new Timer5;
- new Timer6;
- new Timer7;
- new Timer8;
- new Timer9;
- 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 script By nickdodd25 ");
- printf(" Date: %d/%d/%d - Time: %d:%d:%d",day,month,year,hour, minute, second);
- 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
- return 1;
- }
- public OnFilterScriptExit()
- {
- 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 OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/rscmds", cmdtext, true, 7) == 0)
- {
- 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 | /donemaintain | ");
- SendClientMessage(playerid,Color_Yellow," By:nickdodd25 build"Build" ");
- SendClientMessage(playerid,Color_Yellow,"Thank you "ServerName" for testing/using this script");
- return 1;
- }
- if (strcmp("/stoprestart", cmdtext, true, 12) == 0)
- {
- 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);
- 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", ServerName);
- SendRconCommand(HostCommand1);
- return 1;
- }
- if (strcmp("/2min", cmdtext, true, 5) == 0)
- {
- 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);
- 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, 5) == 0)
- {
- 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);
- 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, 6) == 0)
- {
- 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);
- 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, 7) == 0)
- {
- 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);
- 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, 9) == 0)
- {
- 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 maintenance mode.", pName);
- SendClientMessageToAll(COLOR_BLUE, string);
- SendClientMessageToAll(COLOR_BLUE, "Kicking all players");
- print(string);
- new HostCommand1[128];
- new HostCommand2[128];
- printf(" %s is now in maintenance mode, type donemaintain to unlock server.",ServerName);
- format(HostCommand1, 128, "hostname %s in maintenance Mode..Please Wait.", ServerName);
- format(HostCommand2, 128, "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, 13)==0)
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Color_Red, "Only admins can use this command");
- new HostCommand1[128];
- new HostCommand2[128];
- printf(" %s is now out of maintenance mode", ServerName);
- format(HostCommand2, 128, "password %s", PassWord2);
- format(HostCommand1, 128, "hostname %s", ServerName);
- SendRconCommand(HostCommand1);
- SendRconCommand(HostCommand2);
- SendClientMessageToAll(COLOR_BLUE, "You have taken server out of maintenance mode.");
- return 1;
- }
- return 0;
- }
- public OnRconCommand(cmd[])
- {
- if(strcmp(cmd, "2min", true)==0)
- {
- printf("You have started 2 minute restart");
- KillTimer(Timer1);
- KillTimer(Timer2);
- KillTimer(Timer3);
- KillTimer(Timer4);
- KillTimer(Timer5);
- KillTimer(Timer6);
- KillTimer(Timer7);
- KillTimer(Timer8);
- KillTimer(Timer9);
- 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);
- 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);
- 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);
- SendClientMessageToAll(COLOR_BLUE, "Owner/Admin has stopped restart!");
- new HostCommand1[128];
- format(HostCommand1, 128, "hostname %s", 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);
- 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 maintenance mode, type donemaintain to unlock server.",ServerName);
- for(new i; i < MAX_PLAYERS; i++)
- Kick(i);
- format(HostCommand1, 128, "hostname %s in maintenance 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 maintenance 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("*** donemaintain **");
- return 1;
- }
- return 0;
- }
- forward Timer_10_MinWarning();
- 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;
- }
- forward Timer_5_MinWarning();
- 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;
- }
- forward Timer_2_MinWarning();
- 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;
- }
- forward Timer_Restart_WarnPlayers();
- 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;
- }
- forward Timer_Restart_Kick();
- public Timer_Restart_Kick()
- {
- // 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);
- // Start the next timer that will restart the server
- SetTimer("Timer_Restart_Reboot", 1000 * 5, false);
- return 1;
- }
- forward Timer_Restart_Reboot();
- public Timer_Restart_Reboot()
- {
- // Restart the server
- SendRconCommand("gmx");
- //=========================================================================
- //SendRconCommand("reloadfs Your_Filterscript_Here");//with this line you may also restart separate Filterscripts");
- //=========================================================================
- 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(" Restarted on: %d/%d/%d - Time: %d:%d:%d",day,month,year,hour, minute, second);
- return 1;
- }
- //remove anything below this once you have read and changed your restart config
- #if !defined Restart_Config
- #error Set your Restart Config before using please then delet the last 3 lines!!!!
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement