AFK system
#1

I'm trying to make a AFK system but it wont count the seconds a player is afk it only creates the chat bubble above the persons head.

PHP код:

public OnPlayerPause(playerid)
{
    foreach(new 
Player)
    {
        new 
iAFK[75];
        
format(iAFKsizeof(iAFK), "%s(%d) [Paused: %s secs]"ReturnPlayerName(i), inumber_format(playerData[i][pAFK]));
        
SetPlayerChatBubble(iiAFKCOLOR_SERVER50.010000);
          
CountAFK(i);
    }
    return 
1;
}
forward CountAFK(playerid);
public 
CountAFK(playerid)
{
//    for (new i = 0; i <= MAX_PLAYERS; i++)
//    {
          
if (IsPlayerInGame(playerid) || playerData[playerid][pd_IsLoggedIn])
        {
            if(!
playerData[playerid][pd_IsOnDuty])
            {
                
playerData[playerid][pAFK]++;
            }
         }
    
//}
    
return 1;
}
stock bool:IsPlayerAFK(playerid)
{
    if(
playerData[playerid][pAFK] >= 5) return true;
    return 
false;
}
stock number_formatnum )
{
    new 
stri[16], stro[16], ivpdlnum 0;
    
formatstrisizeofstri ), "%d"num * ( ? -) );
    
strlenstri ) - 1;
    
= ( - ( ) ) / 3;
    
1;
    
d;
    
l;
    while ( 
>= )
    {
        
i;
        if ( 
&& !( ) ) stro[n] = ',';
        else 
stro[n] = stri[p--];
         
i--;
    }
    
stro[0] = '-' stro[0];
    return 
stro;

Reply
#2

PHP код:
public OnPlayerPause(playerid

    foreach(new 
Player
    { 
        new 
iAFK[75]; 
        
format(iAFKsizeof(iAFK), "%s(%d) [Paused: %s secs]"ReturnPlayerName(i), inumber_format(playerData[i][pAFK])); 
        
SetPlayerChatBubble(iiAFKCOLOR_SERVER50.010000); 
          
CountAFK(i); 
    } 
    return 
1

But... Why?

If a player pauses, you loop through every other player and set their bubble for being AFK? How's that make sense to you?
Reply
#3

You need do this part in your CountAFK timer:
PHP код:
new iAFK[75];  
format(iAFKsizeof(iAFK), "%s(%d) [Paused: %s secs]"ReturnPlayerName(i), inumber_format(playerData[i][pAFK]));  
SetPlayerChatBubble(iiAFKCOLOR_SERVER50.010000); 
And remove the loop, you just need to declare a timer using SetTimerEx inside OnPlayerPause.
Reply
#4

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
PHP код:
public OnPlayerPause(playerid

    foreach(new 
Player
    { 
        new 
iAFK[75]; 
        
format(iAFKsizeof(iAFK), "%s(%d) [Paused: %s secs]"ReturnPlayerName(i), inumber_format(playerData[i][pAFK])); 
        
SetPlayerChatBubble(iiAFKCOLOR_SERVER50.010000); 
          
CountAFK(i); 
    } 
    return 
1

But... Why?

If a player pauses, you loop through every other player and set their bubble for being AFK? How's that make sense to you?
I reviewed the whole code and made it a better way.

Quote:
Originally Posted by Gammix
Посмотреть сообщение
You need do this part in your CountAFK timer:
PHP код:
new iAFK[75];  
format(iAFKsizeof(iAFK), "%s(%d) [Paused: %s secs]"ReturnPlayerName(i), inumber_format(playerData[i][pAFK]));  
SetPlayerChatBubble(iiAFKCOLOR_SERVER50.010000); 
And remove the loop, you just need to declare a timer using SetTimerEx inside OnPlayerPause.
Yes thats exactly what i did , i just forgot to update this thread.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)