I got /afk system.
pawn Код:
#include <a_samp>
#if defined FILTERSCRIPT
#endif
new afk[MAX_PLAYERS];
new Float:x;
new Float:y;
new Float:z;
new cage;
new cage1;
new cage2;
new cage3;
new cage4;
new muted[MAX_PLAYERS];
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/afk", cmdtext, true, 10) == 0)
{
if (afk[playerid] == 0)
{
GetPlayerPos(playerid, x, y, z);
muted[playerid] = 1;
SetPlayerHealth(playerid, 100000000000);
new name[MAX_PLAYER_NAME], string[44];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s is AFK.",name);
SendClientMessageToAll(0xFFFF00AA, string);
afk[playerid] = 1;
SetPlayerPos(playerid, 2261.4995, 1398.8009, 30.1234);
new Float:xi = 2261.4995;
new Float:yi = 1398.8009;
new Float:zi = 30.1234;
cage = CreateObject(985, xi, yi+4, zi, 0.0, 0.0, 0.0);
cage2 = CreateObject(985, xi+4, yi, zi, 0.0, 0.0, 90.0);
cage3 = CreateObject(985, xi-4, yi, zi, 0.0, 0.0, 270.0);
cage4 = CreateObject(985, xi, yi-4, zi, 0.0, 0.0, 180.0);
}
else
{
SendClientMessage(playerid, 0xFFFF00AA,"You are already AFK!");
}
return 1;
}
if (strcmp("/back", cmdtext, true, 10) == 0)
{
if (afk[playerid] == 1)
{
SetPlayerHealth(playerid, 100);
new name[MAX_PLAYER_NAME], string[44];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s is BACK.",name);
SendClientMessageToAll(0xFFFF00AA, string);
afk[playerid] = 0;
SetPlayerPos(playerid, x, y, z);
DestroyObject(cage);
DestroyObject(cage1);
DestroyObject(cage2);
DestroyObject(cage3);
DestroyObject(cage4);
muted[playerid] = 0;
}
else
{
SendClientMessage(playerid, 0xFFFF00AA, "You arent AFK!");
}
return 1;
}
return 0;
}
public OnPlayerDeath(playerid, killerid, reason)
{
afk[playerid] = 0;
return 1;
}
public OnPlayerText(playerid, text[])
{
if (muted[playerid] == 1)
{
SendClientMessage(playerid, 0xFFFF00AA, "YOU CANNOT TALK WHILE AFK!");
return 0;
}
return 1;
}
How to add [AFK] in front of players name? Like when they do /afk they will appear in player list/and above them, for example [AFK]ColdIce, and when they do /back the AFK thingy goes away