21.11.2014, 15:50
Hey, so I got this /restart command, but when I execute it in the server, it won't restart it, it just enters in a loop and shows only the message for the players. Here is the code. Please help me with it.
Код:
COMMAND:restart(playerid, params[]) { // Setup local variables new Msg[128]; // Send the command to all admins so they can see it SendAdminText(playerid, "/restart", params); // Check if the player has logged in if (APlayerData[playerid][LoggedIn] == true) { // Check if the player's admin-level is at least 5 if (APlayerData[playerid][PlayerLevel] >= 5) { // Let everyone know that the server will be restarted in "RestartTime" minutes (provided by the admin) SendClientMessageToAll(-1, "* The server will be going down for Scheduled Maintenance, Estimated Downtime: 1-3 Minutes."); SendClientMessageToAll(-1, "We will be going down to do some maintenance on the server/script, we will be back online shortly."); format(Msg, 128, "Server restart in 30 seconds!", RestartTime); GameTextForAll(Msg, 5000, 3); SendClientMessageToAll(0xA0A0A0, Msg); // Start the next timer which warns the players again every minute SetTimer("Timer_Restart", 30000, false); } else return 0; } else return 0; // Let the server know that this was a valid command return 1; } forward Timer_Restart(); public Timer_Restart() { // Setup local variables new Msg[128]; // Decrease the RestartTime by one minute RestartTime--; // Let everyone know that the server will be restarted in 2 minutes format(Msg, 128, "Server restart in 30 seconds!", RestartTime); GameTextForAll(Msg, 5000, 3); SendClientMessageToAll(0xA0A0A0, Msg); // Do different things based on the remaining time switch (RestartTime) { case 1: // One minute left { // Change the hostname of the server and change the RCON-password to something weird SendRconCommand("hostname Pending Restart"); SendRconCommand("password loafkagakggoagka"); } case 0: { // Let everyone know that the server is kicking all players before restarting GameTextForAll("Server restarting:Kicking all players!", 5000, 3); // Start the next timer that will restart the server SetTimer("Timer_Restart_Reboot", 30000, false); } } } forward Timer_Restart_Reboot(); public Timer_Restart_Reboot() { new HostCommand[128]; // Restart the server SendRconCommand("gmx"); // Change the hostname and password again format(HostCommand, 128, "hostname %s", GameModeName); SendRconCommand(HostCommand); SendRconCommand("password 0"); return 1; }