Restart CMD
#1

So the problem is that this text isn't showing, you just get kicked without seeing the text.

Код:
	// Let everyone know that the server is kicking all players before restarting
	GameTextForAll("~b~Restartan!", 5000, 3);
The whole CMD code

PHP код:
COMMAND:restart(playeridparams[])
{
    
// Check if the player has logged in
    
if (APlayerData[playerid][LoggedIn] == true)
    {
        
// Check if the player's admin-level is at least 7
        
if (APlayerData[playerid][PlayerLevel] >= 7)
        {
            
// Let everyone know that the server will be restarted in 2 minutes
            
GameTextForAll("~b~Restart za ~w~2 minute!"50003);
            
SendClientMessageToAll(0xFF0000AA"[SERVER] Restart za 2 minute!");
            
// Change the hostname of the server and it's password
            
SendRconCommand("hostname [NG] Restart u toku!");
            
SendRconCommand("password Apple");
            
// Start the next timer which warns the players again that server will be restarted in 1 minute
            
SetTimer("Timer_Restart_WarnPlayers"1000 60false);
        }
        else
            return 
0;
    }
    else
        return 
0;
    
// Let the server know that this was a valid command
    
return 1;
}
forward Timer_Restart_WarnPlayers();
public 
Timer_Restart_WarnPlayers()
{
    
// Let everyone know that the server will be restarted in 1 minutes
    
GameTextForAll("~b~Restart za ~w~1 minutu!"50003);
    
SendClientMessageToAll(0xFF0000AA"[SERVER] Restart za 1 minutu!");
    
// Start the next timer
    
SetTimer("Timer_Restart_Kick"1000 60false);
    return 
1;
}
forward Timer_Restart_Kick();
public 
Timer_Restart_Kick()
{
    
// Let everyone know that the server is kicking all players before restarting
    
GameTextForAll("~b~Restartan!"50003);
    
// Kick all players
    
for(new iMAX_PLAYERSi++)
        
Kick(i);
    
// Start the next timer that will restart the server
    
SetTimer("Timer_Restart_Reboot"1000 5false);
    return 
1;
}
forward Timer_Restart_Reboot();
public 
Timer_Restart_Reboot()
{
    new 
HostCommand[128];
    
// Restart the server
    
SendRconCommand("gmx");
    
// Change the hostname and password again
    
format(HostCommand128"hostname %s"GameModeName);
    
SendRconCommand(HostCommand);
    
SendRconCommand("password 0");
    return 
1;

Reply
#2

You've to delay the kick if you're sending something before it here's how you should do it:
PHP код:
forward Timer_Restart_Kick();
public 
Timer_Restart_Kick()
{
    
// Let everyone know that the server is kicking all players before restarting
    
GameTextForAll("~b~Restartan!"50003);
    
// Kick all players
    
SetTimer("KickAllPlayersPlease"1000false);
    
// Start the next timer that will restart the server
    
SetTimer("Timer_Restart_Reboot"1000 5false);
    return 
1;
}
forward public KickAllPlayersPlease();
public 
KickAllPlayersPlease()
{
    for(new 
iMAX_PLAYERSi++)
        
Kick(i);

full code:
PHP код:
COMMAND:restart(playeridparams[])
{
    
// Check if the player has logged in
    
if (APlayerData[playerid][LoggedIn] == true)
    {
        
// Check if the player's admin-level is at least 7
        
if (APlayerData[playerid][PlayerLevel] >= 7)
        {
            
// Let everyone know that the server will be restarted in 2 minutes
            
GameTextForAll("~b~Restart za ~w~2 minute!"50003);
            
SendClientMessageToAll(0xFF0000AA"[SERVER] Restart za 2 minute!");
            
// Change the hostname of the server and it's password
            
SendRconCommand("hostname [NG] Restart u toku!");
            
SendRconCommand("password Apple");
            
// Start the next timer which warns the players again that server will be restarted in 1 minute
            
SetTimer("Timer_Restart_WarnPlayers"1000 60false);
        }
        else
            return 
0;
    }
    else
        return 
0;
    
// Let the server know that this was a valid command
    
return 1;
}
forward Timer_Restart_WarnPlayers();
public 
Timer_Restart_WarnPlayers()
{
    
// Let everyone know that the server will be restarted in 1 minutes
    
GameTextForAll("~b~Restart za ~w~1 minutu!"50003);
    
SendClientMessageToAll(0xFF0000AA"[SERVER] Restart za 1 minutu!");
    
// Start the next timer
    
SetTimer("Timer_Restart_Kick"1000 60false);
    return 
1;
}
forward Timer_Restart_Kick();
public 
Timer_Restart_Kick()
{
    
// Let everyone know that the server is kicking all players before restarting
    
GameTextForAll("~b~Restartan!"50003);
    
// Kick all players
    
SetTimer("KickAllPlayersPlease"1000false);
    
// Start the next timer that will restart the server
    
SetTimer("Timer_Restart_Reboot"1000 5false);
    return 
1;
}
forward public KickAllPlayersPlease();
public 
KickAllPlayersPlease()
{
    for(new 
iMAX_PLAYERSi++)
        
Kick(i);
}
forward Timer_Restart_Reboot();
public 
Timer_Restart_Reboot()
{
    new 
HostCommand[128];
    
// Restart the server
    
SendRconCommand("gmx");
    
// Change the hostname and password again
    
format(HostCommand128"hostname %s"GameModeName);
    
SendRconCommand(HostCommand);
    
SendRconCommand("password 0");
    return 
1;

Reply
#3

You have to add GameTextForAll("~b~Restartan!", 5000, 3); on Timer_Restart_Kick
Reply
#4

Working,much thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)