/afklist
#1

hey i made /afk and /back command...now im making /afklist command to check which players are afk
i made that:
PHP код:
COMMAND:afklist(playerid,params[])
{
    new 
Name[24], pName[MAX_PLAYER_NAME];
    {
    if (
PlayerIsAFK[playerid] == 1)
    {
    
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    
format(Namesizeof(Name), "%s\r\n"pName);
    
SendClientMessage(playerid,COLOR_BLUE"AFK LIST:");
    
SendClientMessage(playerid,COLOR_YELLOWName);
    }
    else
    {
    
SendClientMessage(playerid,COLOR_YELLOW"No one is AFK!");
    }
    }
    return 
1;

but that will show only for one player(you), am i right?....how can i fix this?...
Reply
#2

U must use a loop
Like this:
pawn Код:
for(new i; i < sizeof MAX_PLAYERS; i++)
{
    if(isafk[i])

// like that
Reply
#3

pawn Код:
COMMAND:afklist(playerid,params[])
{
    new Name[24], pName[MAX_PLAYER_NAME];
    SendClientMessage(playerid,COLOR_BLUE, "AFK LIST:");
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue:
       
        if (PlayerIsAFK[i] == 1)
        {
            GetPlayerName(i,pName,MAX_PLAYER_NAME);
            format(Name, sizeof(Name), "%s\r\n", pName);
        }
        SendClientMessage(playerid, COLOR_YELLOW, Name);
        return 1;
    }
    else
    {
        SendClientMessage(playerid,COLOR_YELLOW, "No one is AFK!");
    }
    return 1;
}
Reply
#4

pawn Код:
COMMAND:afklist(playerid,params[])
{
    new Name[24], pName[MAX_PLAYER_NAME];
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if (PlayerIsAFK[i] == 1)
        {
            GetPlayerName(i,pName,MAX_PLAYER_NAME);
            format(Name, sizeof(Name), "%s\r\n", pName);
            SendClientMessage(playerid,COLOR_BLUE, "AFK LIST:");
            SendClientMessage(playerid,COLOR_YELLOW, Name);
        }
        else
        {
            SendClientMessage(playerid,COLOR_YELLOW, "No one is AFK!");
        }
    }
    return 1;
}
I've got no idea if this works.

EDIT: late
Reply
#5

Quote:
Originally Posted by AeroBlast
Посмотреть сообщение
pawn Код:
COMMAND:afklist(playerid,params[])
{
    new Name[24], pName[MAX_PLAYER_NAME];
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if (PlayerIsAFK[i] == 1)
        {
            GetPlayerName(i,pName,MAX_PLAYER_NAME);
            format(Name, sizeof(Name), "%s\r\n", pName);
            SendClientMessage(playerid,COLOR_BLUE, "AFK LIST:");
            SendClientMessage(playerid,COLOR_YELLOW, Name);
        }
        else
        {
            SendClientMessage(playerid,COLOR_YELLOW, "No one is AFK!");
        }
    }
    return 1;
}
I've got no idea if this works.

EDIT: late
Doesnt works...and when i type /afklist i get about 50times writen No one is AFK!
Reply
#6

Quote:
Originally Posted by Pinguinn
Посмотреть сообщение
pawn Код:
COMMAND:afklist(playerid,params[])
{
    new Name[24], pName[MAX_PLAYER_NAME];
    SendClientMessage(playerid,COLOR_BLUE, "AFK LIST:");
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue:
       
        if (PlayerIsAFK[i] == 1)
        {
            GetPlayerName(i,pName,MAX_PLAYER_NAME);
            format(Name, sizeof(Name), "%s\r\n", pName);
        }
        SendClientMessage(playerid, COLOR_YELLOW, Name);
        return 1;
    }
    else
    {
        SendClientMessage(playerid,COLOR_YELLOW, "No one is AFK!");
    }
    return 1;
}
PHP код:
C:\Documents and Settings\scry\Desktop\Truck srv\filterscripts\AFKsystemv2.pwn(68) : error 001expected token";"but found ":"
C:\Documents and Settings\scry\Desktop\Truck srv\filterscripts\AFKsystemv2.pwn(68) : error 029invalid expressionassumed zero
C
:\Documents and Settings\scry\Desktop\Truck srv\filterscripts\AFKsystemv2.pwn(68 -- 70) : warning 215expression has no effect
C
:\Documents and Settings\scry\Desktop\Truck srv\filterscripts\AFKsystemv2.pwn(70) : error 001expected token";"but found "if"
C:\Documents and Settings\scry\Desktop\Truck srv\filterscripts\AFKsystemv2.pwn(70) : fatal error 107too many error messages on one line
Compilation aborted
.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
4 Errors

Reply
#7

pawn Код:
COMMAND:afklist(playerid,params[])
{
    new Name[24], pName[MAX_PLAYER_NAME];
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if (PlayerIsAFK[i] == 1)
        {
            GetPlayerName(i,pName,MAX_PLAYER_NAME);
            format(Name, sizeof(Name), "%s\r\n", pName);
            SendClientMessage(playerid,COLOR_BLUE, "AFK LIST:");
            SendClientMessage(playerid,COLOR_YELLOW, Name);
        }
        else
        {
            SendClientMessage(playerid,COLOR_YELLOW, "No one is AFK!");
            return 1;
        }
    }
    return 1;
}
This should stop the No one is AFK! spam, but I think you get spammed with AFK LIST when someone is afk
Reply
#8

Thanks dude, gave you a rep!
Reply
#9

Quote:
Originally Posted by AeroBlast
Посмотреть сообщение
pawn Код:
COMMAND:afklist(playerid,params[])
{
    new Name[24], pName[MAX_PLAYER_NAME];
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if (PlayerIsAFK[i] == 1)
        {
            GetPlayerName(i,pName,MAX_PLAYER_NAME);
            format(Name, sizeof(Name), "%s\r\n", pName);
            SendClientMessage(playerid,COLOR_BLUE, "AFK LIST:");
            SendClientMessage(playerid,COLOR_YELLOW, Name);
        }
        else
        {
            SendClientMessage(playerid,COLOR_YELLOW, "No one is AFK!");
            return 1;
        }
    }
    return 1;
}
This should stop the No one is AFK! spam, but I think you get spammed with AFK LIST when someone is afk
That doesn't spam. That just stops the function from calling once the script find a not-afk player...

Use this instead:
pawn Код:
CMD:afklist(playerid,params[])
{
    new name[MAX_PLAYER_NAME], count;
    SendClientMessage(playerid, COLOR_BLUE, "AFK LIST:");
    for(new i, s = GetMaxPlayers(); i < s; i++) // or if using foreach: foreach(Player, i)
    {
        if(!IsPlayerConnected(i)) continue;
        if(PlayerIsAFK[i] != 1) continue;
        GetPlayerName(i, name, MAX_PLAYER_NAME);
        SendClientMessage(playerid, COLOR_YELLOW, name), count++;
    }
    if(count == 0) return SendClientMessage(playerid,COLOR_YELLOW, "No one is AFK!");
    return 1;
}
Reply
#10

garsino now if my friend and me use /afk i only see him and he only se him also....HELP PLEASE
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)