11.07.2018, 13:34
PHP код:
// TOP OF SCRIPT
#include <a_samp>
#include <zcmd>
new killtimer[MAX_PLAYERS], bool:IsAfk[MAX_PLAYERS];
//ADD THESE LINES INTO YOUR PUBLICS
public OnPlayerText(playerid, text[])
{
if(IsAfk[playerid] == true)
{
IsAfk[playerid] = false;
new str[180], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(str, sizeof(str), "%s has backed from afk.", pname);
SendClientMessageToAll(-1, str);
TogglePlayerControllable(playerid, 1);
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(IsAfk[playerid] == true)
{
IsAfk[playerid] = false;
new str[180], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(str, sizeof(str), "%s has backed from afk.", pname);
SendClientMessageToAll(-1, str);
TogglePlayerControllable(playerid, 1);
}
return 1;
}
//ADD THOSE LINES AT THE LAST OF YOUR SCRIPT
CMD:back(playerid)
{
if(IsAfk[playerid] == false) return SendClientMessage(playerid, -1, "ERROR:You arn't afk.");
IsAfk[playerid] = false;
new str[180], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(str, sizeof(str), "%s has backed from afk.", pname);
SendClientMessageToAll(-1, str);
TogglePlayerControllable(playerid, 1);
return true;
}
CMD:afk(playerid)
{
if(IsAfk[playerid] == true) return SendClientMessage(playerid, -1, "ERROR:You are already afk.");
if(!IsPlayerAdmin(playerid))
{
killtimer[playerid] = SetTimerEx("IdleKick", 600000, 1, "i", playerid);
}
IsAfk[playerid] = true;
new str[180], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(str, sizeof(str), "%s is afk now.", pname);
SendClientMessageToAll(-1, str);
TogglePlayerControllable(playerid, 0);
return 1;
}
forward IdleKick(playerid);
public IdleKick(playerid)
{
SetTimerEx("KickPlayer", 500, 0, "i", playerid);
SendClientMessage(playerid, -1, " You have been kicked from the server for being AFK over 10 continous minutes");
return 1;
}
forward KickPlayer(playerid);
public KickPlayer(playerid)
{
Kick(playerid);
return 1;
}
Код:
if(!IsPlayerAdmin(playerid))