#1

So i have been using this code for(new i=0; i<MAX_PLAYERS; i++) as it should have the cool function it loops through all 200 diffrent IDs.
But i have having this problem that it only calls on playerid 0 which is quiet annoying. Im losing trust to this function. Maybe im doing something wrong but heres a good example where it only loops id 0 for me

pawn Код:
dcmd_admins(playerid,params[])
{
    #pragma unused params
    new string[43],name[MAX_PLAYER_NAME];
    SendClientMessage(playerid,COLOUR_BLUE,"Current admins online:");
  for(new i=0; i<MAX_PLAYERS; i++)
    {
      if(IsPlayerConnected(i))
      {
        if(pi[i][Adminlevel] == 1)
        {
          GetPlayerName(i,name,sizeof(name));
          format(string,sizeof(string),"Trial: %s ID: %i",name,i);
                SendClientMessage(playerid,COLOUR_WHITE,string);
                return 1;
                }
        if(pi[i][Adminlevel] == 2)
        {
          GetPlayerName(i,name,sizeof(name));
          format(string,sizeof(string),"Mod: %s ID: %i",name,i);
                SendClientMessage(playerid,COLOUR_WHITE,string);
                return 1;
                }
        if(pi[i][Adminlevel] == 3)
        {
          GetPlayerName(i,name,sizeof(name));
          format(string,sizeof(string),"Admin: %s ID: %i",name,i);
                SendClientMessage(playerid,COLOUR_YELLOW,string);
                return 1;
                }
        if(pi[i][Adminlevel] == 4)
        {
          GetPlayerName(i,name,sizeof(name));
          format(string,sizeof(string),"Lead Admin: %s ID: %i",name,i);
                SendClientMessage(playerid,COLOUR_ORANGE,string);
                return 1;
                }
            }
        }
    return 1;
}
Am i using it wrong or do it have some limits?
Reply
#2

Try this code, just edit it to use your admin name's such as trail, lead admin ect..
Works fine for me.

pawn Код:
dcmd_admins(playerid, params[])
{
  #pragma unused params
    str[0] = 0;
    for (new i=0; i<MAX_PLAYERS; i++)
    {
      if (IsPlayerConnected(i))
      {
            if (pInfo[i][Admin] > 0)
            {
              if( str[0] == 0 )
                SendClientMessage( playerid, COLOR_YELLOW, "Current Admins Online:" );
              format(str, sizeof(str), "%s - (Level %d)", PlayerName(i), pInfo[i][Admin]);
              SendClientMessage(playerid, COLOR_WHITE, str);
            }
        }
    }
    if(str[0] == 0)
    SendClientMessage(playerid, COLOR_GREY, "Currently No Admins Online.");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)