STRCMP
pawn Код:
new PlayerAFK[MAX_PLAYERS]; //At the top of your script
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/afk", true) == 0)
{
if(PlayerAFK[playerid] == 1) return SendClientMessage(playerid, 0xFF0000FF, "You Are Already AFK, Use {00FF00}/BACK {FF0000}To Return To The Game.");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
new string[60];
format(string,sizeof(string),"Player %s Is Now AFK.",name);
SendClientMessageToAll(0x00FF00FF, string);
PlayerAFK[playerid] = 1;
return 1;
}
if(strcmp(cmdtext, "/back", true) == 0)
{
if(PlayerAFK[playerid] == 0) return SendClientMessage(playerid, 0xFF0000FF, "You Are Not AFK. Use {00FF00}/AFK {FF0000}.");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
new string[60];
format(string,sizeof(string),"Player %s Has Returned To The Game.",name);
SendClientMessageToAll(0x00FF00FF, string);
PlayerAFK[playerid] = 0;
return 1;
}
return 0;
}
public OnPlayerText(playerid, text[])
{
if(PlayerAFK[playerid] == 1)
{
SendClientMessage(playerid, 0xFF0000FF, "You Are AFK And Cannot Speak. Use {00FF00}/BACK{FF0000} To Return To The Game.");
return 0;
}
return 1;
}
ZCMD
pawn Код:
new PlayerAFK[MAX_PLAYERS]; //Top of your script
CMD:afk(playerid,params[])
{
if(PlayerAFK[playerid] == 1) return SendClientMessage(playerid, 0xFF0000FF, "You Are Already AFK, Use {00FF00}/BACK {FF0000}To Return To The Game.");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
new string[60];
format(string,sizeof(string),"Player %s Is Now AFK.",name);
SendClientMessageToAll(0x00FF00FF, string);
PlayerAFK[playerid] = 1;
return 1;
}
CMD:back(playerid,params[])
{
if(PlayerAFK[playerid] == 0) return SendClientMessage(playerid, 0xFF0000FF, "You Are Not AFK. Use {00FF00}/AFK {FF0000}.");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
new string[60];
format(string,sizeof(string),"Player %s Has Returned To The Game.",name);
SendClientMessageToAll(0x00FF00FF, string);
PlayerAFK[playerid] = 0;
return 1;
}
public OnPlayerText(playerid, text[])
{
if(PlayerAFK[playerid] == 1)
{
SendClientMessage(playerid, 0xFF0000FF, "You Are AFK And Cannot Speak. Use {00FF00}/BACK{FF0000} To Return To The Game.");
return 0;
}
return 1;
}