SA-MP Forums Archive
AFk list code - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: AFk list code (/showthread.php?tid=286871)



AFk list code - [GOD]Dragonster82 - 01.10.2011

Код:
COMMAND:afklist(playerid,params[])
{
    #pragma unused params
        new count = 0;
        new string[128];
        new IsAfkPlayer[MAX_PLAYER_NAME];
  		SendClientMessage(playerid, COLOR_GREEN, " ");
        SendClientMessage(playerid, COLOR_GREEN, "___________ |- Online Admins -| ___________");
		SendClientMessage(playerid, COLOR_GREEN, " ");
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
	 		if (IsPlayerConnected(i))
 			{
				if(IsAfk[playerid] == 1)
				{
				    GetPlayerName(IsAfk[playerid],IsAfkPlayer,sizeof(IsAfkPlayer));
					format(string, "AFK: %s",IsAfkPlayer);
					SendClientMessage(playerid, COLOR_WHITE, string);
					count++;
				}
			}
		}
		if (count == 0)
		SendClientMessage(playerid,COLOR_BRIGHTRED,"No one is AFK here buddy.");
		SendClientMessage(playerid, COLOR_GREEN, " _______________________________________");
		return 1;
}
May i know why is there a argument mismatch?

Idk :S


Re: AFk list code - grand.Theft.Otto - 01.10.2011

Which line has the ' argument type mismatch ' warning ?


Re: AFk list code - [GOD]Dragonster82 - 01.10.2011

Код:
format(string, "AFK: %s",IsAfkPlayer);
This has the argument type mismatch.


Re: AFk list code - Pharrel - 01.10.2011

format(string, 30, "AFK: %s", IsAfkPlayer);


Re: AFk list code - [GOD]Dragonster82 - 01.10.2011

Thank you so much!


Re: AFk list code - grand.Theft.Otto - 01.10.2011

Try this:

pawn Код:
// top of script:

new IsAfkPlayer[MAX_PLAYER_NAME];

// in your /afk command

IsAfkPlayer[playerid] = 1;

// command:

COMMAND:afklist(playerid,params[])
{
    #pragma unused params
    new count = 0;
    new string[128];

    SendClientMessage(playerid, COLOR_GREEN, " ");
    SendClientMessage(playerid, COLOR_GREEN, "___________ |- Online Admins -| ___________");
    SendClientMessage(playerid, COLOR_GREEN, " ");
   
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsAfkPlayer[playerid] == 1)
            {
                count++;
                new name[24];
                GetPlayerName(playerid,name,24);
                format(string, "AFK PLAYERS: %s",name);
                SendClientMessage(playerid, COLOR_WHITE, string);
            }
        }
    }
    if(count == 0)
    {
        SendClientMessage(playerid,COLOR_BRIGHTRED,"No one is AFK here buddy.");
        SendClientMessage(playerid, COLOR_GREEN, " _______________________________________");
    }
    return 1;
}



Re: AFk list code - Pharrel - 01.10.2011

the problem is here -> format(string, "AFK PLAYERS: %s",name); and was already solved.


Re: AFk list code - Yamoo - 01.10.2011

Also Grand Theft -
pawn Код:
SendClientMessage(playerid, COLOR_GREEN, "___________ |- Online Admins -| ___________");
I'm giving you a rep just for that epic fail (not being sarcastic).


Re: AFk list code - grand.Theft.Otto - 01.10.2011

Quote:
Originally Posted by Pharrel
Посмотреть сообщение
the problem is here -> format(string, "AFK PLAYERS: %s",name); and was already solved.
Dragonster is in my server, and said he still had a problem with it, so I replied again.

Quote:
Originally Posted by Yamoo
Посмотреть сообщение
Also Grand Theft -
pawn Код:
SendClientMessage(playerid, COLOR_GREEN, "___________ |- Online Admins -| ___________");
I'm giving you a rep just for that epic fail (not being sarcastic).
If you read carefully on Dragons post, it already says that line in HIS code, not only mine. Don't go around implying that people ' fail ' when you should learn to read.

Quote:
Originally Posted by Pharrel
Посмотреть сообщение
kkkkkkkkkkkkkkkk pwned!
Useless post, spammer.


Re: AFk list code - cessil - 01.10.2011

I'd like to point out that this line is incorrect as it'd only get player id 1's name
pawn Код:
GetPlayerName(IsAfk[playerid],IsAfkPlayer,sizeof(IsAfkPlayer));
it should be

pawn Код:
GetPlayerName( i ,IsAfkPlayer,sizeof(IsAfkPlayer));
also this line is also wrong

pawn Код:
if(IsAfk[playerid] == 1)
should be
pawn Код:
if(IsAfk[i] == 1)