Server Restart - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Server Restart (
/showthread.php?tid=279385)
Server Restart -
Trucker[UK] - 26.08.2011
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;
}
Re: Server Restart -
HotPlayer - 26.08.2011
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!
Re: Server Restart -
Gagi_Corleone - 26.08.2011
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;
}
Re: Server Restart -
Wyu - 26.08.2011
pawn Код:
new restart_time = strval(params);
....
SetTimer("Timer_Restart_WarnPlayers", restart_time * 1000 * 60, false); // restart in restart_time minutes
...
Re: Server Restart -
Kaperstone - 26.08.2011
best option
i 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
Re: Server Restart -
Trucker[UK] - 26.08.2011
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.
Re: Server Restart -
MP2 - 26.08.2011
Try indenting properly.