Issue with loop
#2

PHP код:
AFKTime[playerid] = SetTimer("AFKCheck",1000,1); 
this only has to be under OnGameModeInit / OnFilterScriptinit Once as long as you looping through all players by it
PHP код:
public OnGamemodeInit()
{
    
SetTimer("AFKCheck",1000,1); 

PHP код:
if(IsAFK[i] == 1) return 0
you had to use continue here for ex if id 0 is afk it won't check if others players will be afk or no....

PHP код:
public AFKCheck() 

    new 
Float:xFloat:yFloat:zstring[128]; 
    for (new 
iGetPlayerPoolSize(); <= ji++) 
    { 
        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

Reply


Messages In This Thread
Issue with loop - by Tass007 - 28.08.2016, 09:43
Re: Issue with loop - by jlalt - 28.08.2016, 09:50
Re: Issue with loop - by Threshold - 28.08.2016, 13:21
Re: Issue with loop - by Tass007 - 29.08.2016, 01:26
Re: Issue with loop - by Jefff - 29.08.2016, 01:57
Re: Issue with loop - by Threshold - 29.08.2016, 02:28
Re: Issue with loop - by Tass007 - 29.08.2016, 03:05
Re: Issue with loop - by Threshold - 29.08.2016, 06:33
Re: Issue with loop - by Jefff - 29.08.2016, 14:52
Re: Issue with loop - by Tass007 - 01.09.2016, 11:47

Forum Jump:


Users browsing this thread: 4 Guest(s)