Код:
#include <a_samp>
#include <foreach>
#include <sscanf2>
#include <YSI\y_commands>
#define COLOR_WHITE 0xFFFFFFFF
#define WHITE "{FFFFFF}"
#define LBLUE "{347CCF}"
forward AFK_Seconds(playerid);
new Text3D:AFK_Label[MAX_PLAYERS];
new IsPlayerAFK[MAX_PLAYERS];
new AFK_Timer[MAX_PLAYERS];
new AFK_Reason[MAX_PLAYERS];
main()
{
print("\n----------------------------------");
print(" Afk system ");
print("----------------------------------\n");
}
public OnPlayerConnect(playerid)
{
IsPlayerAFK[playerid] = 0;
return 1;
}
YCMD:afk(playerid, params[], help)
{
new reason[64], strtext[64];
if(IsPlayerAFK[playerid] == 1) return SendClientMessage(playerid, COLOR_WHITE, "You are alredy AFK.");
if(sscanf(params,"s[64]", reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /afk [reason]");
IsPlayerAFK[playerid] = 1;
TogglePlayerControllable(playerid, false);
new string[64], plname[MAX_PLAYER_NAME];
GetPlayerName(playerid, plname, MAX_PLAYER_NAME);
format(string, sizeof(string), ""WHITE"%s "LBLUE"is now AFK", plname);
SendClientMessageToAll(COLOR_WHITE, string);
format(AFK_Reason[playerid],64,"%s", reason);
format(strtext, sizeof(strtext), ""LBLUE"Player is AFK\n"WHITE"Reason: %s\nTime: 0", reason);
AFK_Label[playerid] = Create3DTextLabel(strtext,COLOR_WHITE,30.0,40.0,50.0,40.0,0);
Attach3DTextLabelToPlayer(AFK_Label[playerid], playerid, 0.0, 0.0, 0.3);
SendClientMessage(playerid, COLOR_WHITE, "You are now AFK,tyre "LBLUE"/back "WHITE"when you come back.");
SetTimer("AFK_Seconds", 1000, true);
return 1;
}
YCMD:back(playerid, params[], help)
{
if(IsPlayerAFK[playerid] == 0) return SendClientMessage(playerid, COLOR_WHITE, "You are not AFK.");
IsPlayerAFK[playerid] = 0;
TogglePlayerControllable(playerid, true);
new string[64], plname[MAX_PLAYER_NAME];
GetPlayerName(playerid, plname, MAX_PLAYER_NAME);
format(string, sizeof(string), ""WHITE"%s "LBLUE"is no longer AFK", plname);
SendClientMessageToAll(COLOR_WHITE, string);
Delete3DTextLabel(Text3D:AFK_Label[playerid]);
SendClientMessage(playerid, COLOR_WHITE, "You are no longer AFK.");
return 1;
}
public AFK_Seconds(playerid)
{
foreach (Player, i)
{
AFK_Timer[i] += 1;
new string[64];
format(string, sizeof(string), ""LBLUE"Player is AFK\n"WHITE"Reason: %s\nTime: %d", AFK_Reason[playerid], AFK_Timer[i]);
Update3DTextLabelText(AFK_Label[i], COLOR_WHITE, string);
}
}
And I get this when I compile: