public AFKCheck()
{
new Float:x, Float:y, Float:z, string[128];
for (new i, j = GetPlayerPoolSize(); i <= j; i++)
{
if(!IsPlayerConnected(i)) continue;
if(IsAFK[i] == 1) return 0;
GetPlayerPos(i,x,y,z);
if(IsPlayerInRangeOfPoint(i,2,x,y,z))
{
AFK[i]++;
}
if(AFK[i] == 300)
{
format(string,sizeof(string),"*%s has gone AFK",GetName(i));//Formats the /do cmd output
SendClientMessageToAll(COLOR_WHITE,string);
IsAFK[i] = 1;
}
}
return 1;
}
AFKTime[playerid] = SetTimer("AFKCheck",1000,1);
AFKTime[playerid] = SetTimer("AFKCheck",1000,1);
public OnGamemodeInit()
{
SetTimer("AFKCheck",1000,1);
}
if(IsAFK[i] == 1) return 0;
public AFKCheck()
{
new Float:x, Float:y, Float:z, string[128];
for (new i, j = GetPlayerPoolSize(); i <= j; i++)
{
if(!IsPlayerConnected(i)) continue;
if(IsAFK[i] == 1) continue;
GetPlayerPos(i,x,y,z);
if(IsPlayerInRangeOfPoint(i,2,x,y,z))
{
AFK[i]++;
}
if(AFK[i] == 300)
{
format(string,sizeof(string),"*%s has gone AFK",GetName(i));//Formats the /do cmd output
SendClientMessageToAll(COLOR_WHITE,string);
IsAFK[i] = 1;
}
}
return 1;
}
GetPlayerPos(i,x,y,z);
if(IsPlayerInRangeOfPoint(i,2,x,y,z))
{
AFK[i]++;
}
PHP код:
|
public AFKCheck()
{
static Float:LastPos[MAX_PLAYERS][3];
new Float:x, Float:y, Float:z, string[128];
for(new j = GetPlayerPoolSize(); i > -1; i--)
{
if(!IsPlayerConnected(i) || IsAFK[i]) continue; // add here some !IsPlayerSpawned(i)
GetPlayerPos(i,x,y,z);
if(IsPlayerInRangeOfPoint(i,2.0,LastPos[i][0],LastPos[i][1],LastPos[i][2]))
{
if(IsAFK[i] == 0 && ++AFK[i] >= 300)
{
IsAFK[i] = 1;
format(string,sizeof(string),"*%s has gone AFK",GetName(i));//Formats the /do cmd output
SendClientMessageToAll(COLOR_WHITE,string);
}
}
else
{
if(IsAFK[i] == 1 && AFK[i] >= 300)
{
IsAFK[i] = 0;
AFK[i] = 0;
// player is back
}
LastPos[i][0] = x;
LastPos[i][1] = y;
LastPos[i][2] = z;
}
}
return 1;
}
public AFKCheck()
{
static Float:LastPos[MAX_PLAYERS][3];
new Float:x, Float:y, Float:z, string[128];
for(new i, j = GetPlayerPoolSize(); i > -1; i--)
{
if(!IsPlayerConnected(i) || IsAFK[i]) continue; // add here some !IsPlayerSpawned(i)
GetPlayerPos(i,x,y,z);
if(IsPlayerInRangeOfPoint(i,2.0,LastPos[i][0],LastPos[i][1],LastPos[i][2]))
{
if(IsAFK[i] == 0 && ++AFK[i] >= 300)
{
IsAFK[i] = 1;
format(string,sizeof(string),"*%s has gone AFK",GetName(i));//Formats the /do cmd output
SendClientMessageToAll(COLOR_WHITE,string);
}
}
else
{
if(IsAFK[i] == 1 && AFK[i] >= 300)
{
IsAFK[i] = 0;
AFK[i] = 0;
// player is back
}
LastPos[i][0] = x;
LastPos[i][1] = y;
LastPos[i][2] = z;
}
}
return 1;
}
for(new i = GetPlayerPoolSize(); i > -1; i--)
|| IsAFK[i]
public AFKCheck()
{
static Float:LastPos[MAX_PLAYERS][3];
new Float:x, Float:y, Float:z, string[128];
for(new i = MAX_PLAYERS; i > -1; i--)
{
if(!IsPlayerConnected(i) || !IsPlayerSpawned(i)) continue; // add here some !IsPlayerSpawned(i)
GetPlayerPos(i,x,y,z);
if(IsPlayerInRangeOfPoint(i,2.0,LastPos[i][0],LastPos[i][1],LastPos[i][2]))
{
if(IsAFK[i] == 0 && ++AFK[i] >= 300)
{
IsAFK[i] = 1;
format(string,sizeof(string),"*%s has gone AFK",GetName(i));//Formats the /do cmd output
SendClientMessageToAll(COLOR_WHITE,string);
}
}
else
{
if(IsAFK[i] == 1 && AFK[i] >= 300)
{
IsAFK[i] = 0;
AFK[i] = 0;
// player is back
}
LastPos[i][0] = x;
LastPos[i][1] = y;
LastPos[i][2] = z;
}
}
return 1;
}