Server Restart
#1

Hello

Does anyone know how to change this into a time that u have to put in e.g "/restart [time]" please help

Код:
COMMAND:restart(playerid, params[])
{
	// 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 2 minutes
			GameTextForAll("Server restart in 2 minutes!", 5000, 3);
			SendClientMessageToAll(0xA0A0A0, "Server restart in 2 minutes!");
			// Start the next timer which warns the players again that server will be restarted in 1 minute
			SetTimer("Timer_Restart_WarnPlayers", 1000 * 60, false);
		}
		else
		    return 0;
	}
	else
	    return 0;

	// Let the server know that this was a valid command
	return 1;
}
Reply
#2

Try this
Код:
COMMAND:restart(playerid, params[])
{
	// 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 2 minutes
			GameTextForAll("Server restart in 2 minutes!", 5000, 3);
			SendClientMessageToAll(0xA0A0A0, "Server restart in 2 minutes!");
			// Start the next timer which warns the players again that server will be restarted in 1 minute
			SetTimer("Timer_Restart_WarnPlayers", 15000 * 60, false);//server will restart at 15 seconds if need more seconds use  20000 and more
		}
		else
		    return 0;
	}
	else
	    return 0;

	// Let the server know that this was a valid command
	return 1;
}
Sory for my bad english!
Reply
#3

You can use SSCANF then try this:
Код:
COMMAND:restart(playerid, params[])
{
		new time,string[128];
	    if(!sscanf(params, "i", time)) return SendClientMessage(playerid, -1, "Usage: /restart [time]");  
	// 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 2 minutes
			format(string,sizeof(string),"Server restart in %i minutes!",time);
			GameTextForAll(string, 5000, 3);
			SendClientMessageToAll(0xA0A0A0, "Server restart in 2 minutes!");
			// Start the next timer which warns the players again that server will be restarted in 1 minute
			SetTimer("Timer_Restart_WarnPlayers", time, false);
		}
		else
		    return 0;
	}
	else
	    return 0;

	// Let the server know that this was a valid command
	return 1;
}
Reply
#4

pawn Код:
new restart_time = strval(params);
....
SetTimer("Timer_Restart_WarnPlayers", restart_time * 1000 * 60, false); // restart in restart_time minutes
...
Reply
#5

best optioni think :P)
pawn Код:
CMD:restart(playerid, params[])
{                                                 //1 open
    new time,string[128];
    if(!sscanf(params, "i", time)) return SendClientMessage(playerid, -1, "Usage: /restart [time]");

    if (APlayerData[playerid][LoggedIn] == true) {
                                                  //2 open
        if (APlayerData[playerid][PlayerLevel] >= 5) {
                                                  //3 open
            format(string,sizeof(string),"%i time left till the server will restart!",time);
            GameTextForAll(string, 5000, 3);
            format(string,sizeof(string),"%i time left till the server will restart!",time);
            SendClientMessage(playerid,0xA0A0A0,,string)
                SendClientMessageToAll(0xA0A0A0, "%i time left till the server i will restart!");
            SetTimer("Timer_Restart_WarnPlayers", time, false);
            SendAdminText(playerid, "/restart", params);
        }
        else {
            return 0;
        }                                         //3 close
    }
    else {
        return 0;
    }                                             //2 close
    return 1;
}                                                 //1 close
Reply
#6

Get this now when i compile my gamemode

Код:
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\SAMP\SA-MP\pawno\include\PPC_PlayerCommands.inc(2841) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
Reply
#7

Try indenting properly.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)