This is using
sscanf2.5. This tool is especially useful for commands such as this.
pawn Код:
if(!strcmp(cmdtext,"/reload",true))
{
if(!IsPlayerAdmin(playerid)) // If they are not Admin then it sends the message
{
return SendClientMessage(playerid,-1,"You are not authorised to use this command.");
}
new gmxdelay; // A new variable that the player will type after typing "/reload"
// This is the line that checks if they didn't type the command correctly.
if(sscanf(params,"d",gmxdelay))
{
// So if they didn't type it correctly then tell them how to use it.
return SendClientMessage(playerid,-1,"Syntax: /reload <minutes>");
}
if(gmxdelay == 0) // If they typed 0
{
return SendClientMessage(playerid,-1,"It must be at least one minute.");
}
else
{
// The "gmxdelay*1000*60" is what converts it to minutes.
// gmxdelay is multiplied by 1000, which is one second
// that product is then multiplied by 60 to equal a minute
SetTimer("gmxtimer",gmxdelay*1000*60,false);
new
string[128]; // A new optional string to format
format(string,sizeof(string),"The server will restart in %d minute.",gmxdelay);
SendClientMessageToAll(-1,string);
}
return 1;
}
forward gmxtimer();
public gmxtimer() // So once the timer is up, then it....
{
// sends the gmx command to RCON
SendRconCommand("gmx");
}
Here is the same example with
ZCMD.
pawn Код:
CMD:reload(playerid,params[])
{
if(!IsPlayerAdmin(playerid)) // If they are not Admin then it sends the message
{
return SendClientMessage(playerid,-1,"You are not authorised to use this command.");
}
new gmxdelay; // A new variable that the player will type after typing "/reload"
// This is the line that checks if they didn't type the command correctly.
if(sscanf(params,"d",gmxdelay))
{
// So if they didn't type it correctly then tell them how to use it.
return SendClientMessage(playerid,-1,"Syntax: /reload <minutes>");
}
if(gmxdelay == 0) // If they typed 0
{
return SendClientMessage(playerid,-1,"It must be at least one minute.");
}
else
{
// The "gmxdelay*1000*60" is what converts it to minutes.
// gmxdelay is multiplied by 1000, which is one second
// that product is then multiplied by 60 to equal a minute
SetTimer("gmxtimer",gmxdelay*1000*60,false);
new
string[128]; // A new optional string to format
format(string,sizeof(string),"The server will restart in %d minute.",gmxdelay);
SendClientMessageToAll(-1,string);
}
return 1;
}
forward gmxtimer();
public gmxtimer() // So once the timer is up, then it....
{
// sends the gmx command to RCON
SendRconCommand("gmx");
}
Hope I was of any help.