New question, help command
#1

Hello, how to perform this code ? or already is good?

PHP код:
command(admins,playerid
{
    new 
longstring[200],shortstring[30],Count 0,pName[25];
    for(new 
iMAX_PLAYERSi++)
    {
        if(
IsPlayerAdmin(i))
        {
            
Count++;
            
GetPlayerName(i,pName,25);
            
format(shortstring,sizeof(shortstring),"%s (ID:%d) \n",pName,playerid); 
            
strcat(longstring,shortstring);
        }
    }
    
format(shortstring,sizeof(shortstring),"%d admins online",Count);
    
ShowPlayerDialog(playeriddialogidDIALOG_STYLE_MSGBOX,"Online Admins",longstring,"Ok","");
    return 
1;

Reply
#2

pawn Код:
command(admins, playerid)  
{
    new longstring[200], shortstring[30], Count = 0, pName[25];
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerAdmin(i))
        {
            Count ++;
            GetPlayerName(i, pName, 25);
            format(shortstring, sizeof shortstring, "%s (ID:%d) \n", pName, i);  
            strcat(longstring,shortstring);
        }
    }
    format(shortstring, sizeof shortstring, "%d admins online", Count);
    ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, "Online Admins", longstring, "Ok", "");

    return 1;
}
Reply
#3

Why would you change the loop?
Count is supposed to count how many admins are online. This would just ruin it.
It was fine how he had it.

Have a guess what this would return?
pawn Код:
format(shortstring, sizeof shortstring, "%d admins online", Count);
I have no idea either... should have left the loop how it was, if there is an admin online, Count goes up by 1, so it can return the total amount of admins online at the end of the command.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)