[SOLVED] /admins problem - writes about 10-15 lines
#1

heres the cmd: http://pastebin.com/f5f3e12cc
the problem is: I do it IG and Instead getting this:
Код:
____________Admins____________

AdminRank Admin_Name

______________________________
I get this:
Код:
AdminRank Admin_Name

AdminRank Admin_Name

AdminRank Admin_Name

AdminRank Admin_Name

AdminRank Admin_Name

______________________________
Wheres is the problem?
Reply
#2

Your loop checks player's admin level.
Reply
#3

Ok, so how can I make it to check only once and display only the Rank name instead number?
Reply
#4

pawn Код:
if(strcmp( cmd, "/admins", true ) == 0)
{
    SendClientMessage( playerid, COLOR_GREEN, "_______________Admins_______________" );
    for( new targetid=0; targetid<MAX_PLAYERS; targetid++ )
    {
     if( IsPlayerConnected(targetid) && PlayerInfo[targetid][pAdmin] >0 )
        {
            if( PlayerInfo[targetid][pAdmin] == 1 ){ format( string, sizeof(string), "* %s %s: (ID:%d)", AdminRank1, GetPlayerNameEx(targetid), targetid ); }
            else if( PlayerInfo[targetid][pAdmin] == 2 ){ format( string, sizeof( string ), "* %s %s: (ID:%d)", AdminRank2, GetPlayerNameEx(targetid), targetid ); }
            else if( PlayerInfo[targetid][pAdmin] == 3 ){ format( string, sizeof( string ), "* %s %s: (ID:%d)", AdminRank3, GetPlayerNameEx(targetid), targetid ); }
            else if( PlayerInfo[targetid][pAdmin] == 4 ){ format( string, sizeof( string ), "* %s %s: (ID:%d)", AdminRank4, GetPlayerNameEx(targetid), targetid ); }
            else if( PlayerInfo[targetid][pAdmin] == 5 ){ format( string, sizeof( string ), "* %s %s: (ID:%d)", AdminRank5, GetPlayerNameEx(targetid), targetid ); }
            else if( PlayerInfo[targetid][pAdmin] == 6 ){ format( string, sizeof( string ), "* %s %s: (ID:%d)", AdminRank6, GetPlayerNameEx(targetid), targetid ); }
            else if( PlayerInfo[targetid][pAdmin] == 7 ){ format( string, sizeof( string ), "* %s %s: (ID:%d)", AdminRank7, GetPlayerNameEx(targetid), targetid ); }
            else if( PlayerInfo[targetid][pAdmin] == 1337 ){ format( string, sizeof( string ), "* %s %s: (ID:%d)", AdminRank8, GetPlayerNameEx(targetid), targetid ); }
            SendClientMessage( playerid, COLOR_GRAD1, string );
        }
    }
    SendClientMessage( playerid, COLOR_GREEN, "_____________________________________" );
    return 1;
}
Reply
#5

Or just take your code and change what ever is inside the loop to 'i' instead of 'playerid', exept who you want the message to be sent to (probably playerid)
Reply
#6

I got to this CMD with your help:
pawn Код:
if(strcmp(cmd, "/admins", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
        for(new i=0; i<MAX_PLAYERS; i++)
        {
          if(IsPlayerConnected(i))
          {
            SendClientMessage(playerid, COLOR_GREEN, "_______________Admins_______________");
            SendClientMessage(playerid, COLOR_GRAD1, " ");
                if(PlayerInfo[i][pAdmin] == 1){ format(string, sizeof(string), "(%d) %s %s", i, AdminRank1, GetPlayerNameEx(i)); }
                    else if(PlayerInfo[i][pAdmin] == 2){ format(string, sizeof(string), "(%d) %s %s", i, AdminRank2, GetPlayerNameEx(i)); }
                    else if(PlayerInfo[i][pAdmin] == 3){ format(string, sizeof(string), "(%d) %s %s", i, AdminRank3, GetPlayerNameEx(i)); }
                    else if(PlayerInfo[i][pAdmin] == 4){ format(string, sizeof(string), "(%d) %s %s", i, AdminRank4, GetPlayerNameEx(i)); }
                    else if(PlayerInfo[i][pAdmin] == 5){ format(string, sizeof(string), "(%d) %s %s", i, AdminRank5, GetPlayerNameEx(i)); }
                    else if(PlayerInfo[i][pAdmin] == 6){ format(string, sizeof(string), "(%d) %s %s", i, AdminRank6, GetPlayerNameEx(i)); }
                    else if(PlayerInfo[i][pAdmin] == 7){ format(string, sizeof(string), "(%d) %s %s", i, AdminRank7, GetPlayerNameEx(i)); }
                    else if(PlayerInfo[i][pAdmin] == 1337){ format(string, sizeof(string), "(%d) %s %s", i, AdminRank8, GetPlayerNameEx(i)); }
                    SendClientMessage(playerid, COLOR_GRAD1, string);
                    SendClientMessage(playerid, COLOR_GRAD1, " ");
                    SendClientMessage(playerid, COLOR_GREEN, "_____________________________________");
                    return 1;
                }
                else if(!IsPlayerConnected(i)){ SendClientMessage(playerid, COLOR_GRAD1, "Unfortunatly there are no admins online"); return 1; }
            }
        }
        return 1;
    }
but this happanes:
I'm an admin all works fine
I'm not admin server crashes
Reply
#7

pawn Код:
#define AdminRank[1]          "Server Moderator"
#define AdminRank[2]          "Roleplay Administrator"
#define AdminRank[3]          "Game Administrator"
#define AdminRank[4]          "Senior Game Admin"
#define AdminRank[5]          "RP/Forum Supervisor"
#define AdminRank[6]          "Admin Supervisor"
#define AdminRank[7]          "Server Supervisor"
#define AdminRank[8]          "Server Owner"

if(strcmp(cmd, "/admins", true) == 0)
{
  new adminsOnline;
  if(IsPlayerConnected(playerid))
  {
    SendClientMessage(playerid, COLOR_GREEN, "_______________Admins_______________");
    SendClientMessage(playerid, COLOR_GRAD1, " ");
    for(new i=0; i<MAX_PLAYERS; i++)
    {
      if(IsPlayerConnected(i))
      {
        if(PlayerInfo[i][pAdmin != 0)
        {
         format(string, sizeof(string), "(%d) %s %s", i, AdminRank[PlayerInfo[i][pAdmin]], GetPlayerNameEx(i));
          SendClientMessage(playerid, COLOR_GRAD1, string);
          adminsOnline++;
        }
        return 1;
      }
    }
    if(adminsOnline == 0)
    {
      SendClientMessage(playerid, COLOR_GRAD1,"Unfortunatly there are no admins online");
    }
    SendClientMessage(playerid, COLOR_GRAD1, " ");
    SendClientMessage(playerid, COLOR_GREEN, "_____________________________________");
  }
  return 1;
}
Look at what your code is actually doing next time, In summary it was sending 200+ messages to the client regardless of weather there were any admins online or not and attempting to send a message to every client, again regardless of weather they are online or not.
Reply
#8

I get this Errors & Warnings:
Код:
C:\Documents and Settings\User\Desktop\SAMP GameMode\gamemodes\GM.pwn(83) : warning 201: redefinition of constant/macro (symbol "AdminRank[2]")
C:\Documents and Settings\User\Desktop\SAMP GameMode\gamemodes\GM.pwn(84) : warning 201: redefinition of constant/macro (symbol "AdminRank[3]")
C:\Documents and Settings\User\Desktop\SAMP GameMode\gamemodes\GM.pwn(85) : warning 201: redefinition of constant/macro (symbol "AdminRank[4]")
C:\Documents and Settings\User\Desktop\SAMP GameMode\gamemodes\GM.pwn(86) : warning 201: redefinition of constant/macro (symbol "AdminRank[5]")
C:\Documents and Settings\User\Desktop\SAMP GameMode\gamemodes\GM.pwn(87) : warning 201: redefinition of constant/macro (symbol "AdminRank[6]")
C:\Documents and Settings\User\Desktop\SAMP GameMode\gamemodes\GM.pwn(88) : warning 201: redefinition of constant/macro (symbol "AdminRank[7]")
C:\Documents and Settings\User\Desktop\SAMP GameMode\gamemodes\GM.pwn(89) : warning 201: redefinition of constant/macro (symbol "AdminRank[1337]")
C:\Documents and Settings\User\Desktop\SAMP GameMode\gamemodes\GM.pwn(10806) : error 017: undefined symbol "AdminRank"
C:\Documents and Settings\User\Desktop\SAMP GameMode\gamemodes\GM.pwn(10806) : warning 215: expression has no effect
C:\Documents and Settings\User\Desktop\SAMP GameMode\gamemodes\GM.pwn(10806) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\User\Desktop\SAMP GameMode\gamemodes\GM.pwn(10806) : error 029: invalid expression, assumed zero
C:\Documents and Settings\User\Desktop\SAMP GameMode\gamemodes\GM.pwn(10806) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
the error of line 10806 belongs to this line:
pawn Код:
format(string, sizeof(string), "[ID:%d] %s %s", i, AdminRank[PlayerInfo[i][pAdmin]], GetPlayerNameEx(i));
whats the problem!?
Reply
#9

pawn Код:
if(!strcmp(cmd,"/admins",true))
{ // forgot to add something
  for(new i=0;i<MAX_PLAYERS;i++)
  {
    if(IsPlayerConnected(i)&&PlayerInfo[i][pAdmin])
    {
      switch(PlayerInfo[i][pAdmin])
      {
        case 1: format(string,sizeof(string),"Server Moderator");
        case 2: format(string,sizeof(string),"Roleplay Administrator");
        case 3: format(string,sizeof(string),"Game Administrator");
        case 4: format(string,sizeof(string),"Senior Game Admin");
        case 5: format(string,sizeof(string),"RP/Forum Supervisor");
        case 6: format(string,sizeof(string),"Admin Supervisor");
        case 1337: format(string,sizeof(string),"Server Supervisor");
        case 1338: format(string,sizeof(string),"Server Owner");
        default: format(string,sizeof(string),"Server Moderator");
      }
      format(string,sizeof(string),"%s %s(ID:%d)",string,name(i),i); // just change name to what ever you use as name variable.
      SendClientMessage(playerid,COLOR_GREY,string);
    }
  }
  return 1;
}
One more question -
GetPlayerNameEx = my name function to remove _ between names?
Reply
#10

Quote:
Originally Posted by MenaceX^
pawn Код:
if(!strcmp(cmd,"/admins",true))
{ // forgot to add something
  for(new i=0;i<MAX_PLAYERS;i++)
  {
    if(IsPlayerConnected(i)&&PlayerInfo[i][pAdmin])
    {
      switch(PlayerInfo[i][pAdmin])
      {
        case 1: format(string,sizeof(string),"Server Moderator");
        case 2: format(string,sizeof(string),"Roleplay Administrator");
        case 3: format(string,sizeof(string),"Game Administrator");
        case 4: format(string,sizeof(string),"Senior Game Admin");
        case 5: format(string,sizeof(string),"RP/Forum Supervisor");
        case 6: format(string,sizeof(string),"Admin Supervisor");
        case 1337: format(string,sizeof(string),"Server Supervisor");
        case 1338: format(string,sizeof(string),"Server Owner");
        default: format(string,sizeof(string),"Server Moderator");
      }
      format(string,sizeof(string),"%s %s(ID:%d)",string,name(i),i); // just change name to what ever you use as name variable.
      SendClientMessage(playerid,COLOR_GREY,string);
    }
  }
  return 1;
}
One more question -
GetPlayerNameEx = my name function to remove _ between names?
I'm using Carlito's RolePlay Script... I dunno if the function is yours or not.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)