/afklist bug -
ProPoint - 18.02.2013
Please help me with this :
pawn Код:
CMD:afklist(playerid, params[])
{
new Count = 0;
for(new i = 0; i< MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && IsPlayerAFK[playerid] == 1) Count++;
if(Count == 0)
{
SendClientMessage(playerid, COLOR_GRAD2,"ERROR : No One is AFK Now !");
}
format(str, 128, "List AFK - There Are %d AFK Players", Count);
SendClientMessage(playerid, COLOR_WHITE, str);
if(IsPlayerConnected(i) && IsPlayerAFK[playerid] == 1)
{
format(str, 128, "- %s (%d) is AFK", PlayerName(i), i);
SendClientMessage(playerid, COLOR_GREEN, str);
}
}
return 1;
}
It's good when I compile that.
But when I tried that in game, it's said "No One is AFK Now!", although my friend was AFK ! I tried the opposite (i was AFK and he tried the cmd) , it's same !
But, when I was AFK and I used that command, it's showing us (me and my friend), although only me afk at that time.
Please help me to fix it and Sorry for my bad English
Re: /afklist bug -
RajatPawar - 18.02.2013
pawn Код:
CMD:afklist(playerid, params[])
{
new Count = 0;
for(new i = 0; i< MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && IsPlayerAFK[playerid] == 1)
{
format(str, 128, "- %s (%d) is AFK", PlayerName(i), i);
Count++;
SendClientMessage(playerid, COLOR_GREEN, str);
}
}
if(Count == 0) return SendClientMessage(playerid, COLOR_GRAD2,"ERROR : No One is AFK Now !");
else
{
format(str, 128, "List AFK - There Are %d AFK Players", Count);
SendClientMessage(playerid, COLOR_WHITE, str);
}
return 1;
}
Re: /afklist bug -
]Rafaellos[ - 18.02.2013
@Rajat: I think your script will have error.
@ProPoint: Try this, not tested, im not sure about the "List AFK - There Are %d AFK Players" if will work properly.
pawn Код:
CMD:afklist(playerid, params[])
{
new Count = 0;
new string[128];
for(new i = 0; i< MAX_PLAYERS; i++)
{
format(string, sizeof(string)), "List AFK - There Are %d AFK Players", Count);
SendClientMessage(playerid, COLOR_WHITE, string);
if(IsPlayerConnected(i) && IsPlayerAFK[i] == 1)
{
format(str, 128, "- %s (%d) is AFK", PlayerName(i), i);
SendClientMessage(playerid, COLOR_GREEN, str);
Count++;
}
if(Count == 0)
{
SendClientMessage(playerid, COLOR_GRAD2,"ERROR : No One is AFK Now !");
}
}
return 1;
}
EDIT: @ProPoint: in your code you must change "IsPlayerAFK[playerid]" to "IsPlayerAFK[i]"
Re: /afklist bug -
Falcon. - 18.02.2013
pawn Код:
CMD:afklist(playerid)
{
static count, string[41];count = 0;
for(new xx, ii = GetMaxPlayers(); xx != ii; xx++)
{
if(!IsPlayerConnected(xx) || !IsPlayerAFK[xx]) continue;
count ++;
}
if(count == 0) return SendClientMessage(playerid, COLOR_GRAD2, "ERROR : No One is AFK Now !");
format(string, 39, "List AFK - There Are %02i AFK Players", count);
SendClientMessage(playerid, COLOR_WHITE, string);
for(new xx, ii = GetMaxPlayers(); xx != ii; xx++)
{
if(!IsPlayerConnected(xx) || !IsPlayerAFK[xx]) continue;
format(string, 41, "- %s (%d) is AFK", PlayerName(xx), xx);
SendClientMessage(playerid, COLOR_GREEN, str);
}
return 0x01;
}
Re: /afklist bug -
ProPoint - 18.02.2013
@Rajat : Your script have an error
@Rafael : It's Work !! But.. if no one is AFK, the Message will show too much T_T it's spamming.
Re: /afklist bug -
]Rafaellos[ - 18.02.2013
This will be fine i think.
pawn Код:
CMD:afklist(playerid, params[])
{
new Count = 0;
new string[128];
for(new i = 0; i< MAX_PLAYERS; i++)
{
format(string, sizeof(string)), "List AFK - There Are %d AFK Players", Count);
SendClientMessage(playerid, COLOR_WHITE, string);
if(IsPlayerConnected(i) && IsPlayerAFK[i] == 1)
{
format(str, 128, "- %s (%d) is AFK", PlayerName(i), i);
Count++;
}
SendClientMessage(playerid, COLOR_GREEN, str);
}
if(Count == 0)
{
SendClientMessage(playerid, COLOR_GRAD2,"ERROR : No One is AFK Now !");
}
return 1;
}
Re: /afklist bug -
ProPoint - 18.02.2013
@Falcon : Your script works fine, but the name at the second and subsequent list was not changed.
@Rafael : That still bug T_T
C'mon guys, i need this script for my first FS T_T
EDIT : @Falcon : The reason was not changed too
Re: /afklist bug -
RajatPawar - 18.02.2013
pawn Код:
CMD:afklist(playerid)
{
new count = 0,
string[50];
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i)
{
if(IsPlayerAFK[i]==1)
{
count++;
format(string, 50, "- %s (%d) is AFK!", PlayerName(i), i);
SendClientMessageToAll(-1, string);
}
}
}
if(count == 0)
{
SendClientMessage(playerid, -1, "No players AFK!");
}
else
{
format(string, 50, "There are %d players AFK.",count);
SendClientMessage(playerid, -1, string);
}
return 1;
}
Made this in PAWN myself, check it out.
Re: /afklist bug -
Falcon. - 18.02.2013
lol sorry, i failed...
pawn Код:
new IsPlayerAFK[20];
CMD:afklist(playerid)
{
static count, string[41];count = 0;
for(new xx, ii = GetMaxPlayers(); xx != ii; xx++)
{
if(!IsPlayerConnected(xx) || !IsPlayerAFK[xx]) continue;
count ++;
}
if(count == 0) return SendClientMessage(playerid, COLOR_GRAD2, "ERROR : No One is AFK Now !");
format(string, 39, "List AFK - There Are %02i AFK Players", count);
SendClientMessage(playerid, COLOR_WHITE, string);
for(new xx, ii = GetMaxPlayers(); xx != ii; xx++)
{
if(!IsPlayerConnected(xx) || !IsPlayerAFK[xx]) continue;
format(string, 41, "- %s (%d) is AFK", PlayerName(xx), xx);
SendClientMessage(playerid, COLOR_GREEN, string);
}
return 0x01;
}
Re: /afklist bug -
Misiur - 18.02.2013
pawn Код:
CMD:afklist(playerid, params[])
{
new Count = 0, bool:msg = false;
for(new i = 0; i< MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && IsPlayerAFK[playerid] == 1)
{
Count++;
if(!msg) {
SendClientMessage(playerid, COLOR_WHITE, "List AFK");
msg = true;
}
format(str, sizeof str, "- %s (%d) is AFK", PlayerName(i), i);
SendClientMessage(playerid, COLOR_GREEN, str);
}
}
if(Count == 0)
{
SendClientMessage(playerid, COLOR_GRAD2,"ERROR : No One is AFK Now !");
}
else {
format(string, sizeof string, "Total %d AFK Players", Count);
SendClientMessage(playerid, COLOR_WHITE, string);
}
return 1;
}