Problem with: /foradmins [text]
#1

I have a problem with code: /foradmins [text here] . This command need to send message from a player for admins but if player admin and he sent this message to other admins. This message repeats for him 2x times. How i can make what if player is admin and he sent message to other admins he can see only one message not two
2. There is an epic problem if player sent this message for admins, they don't get this message, but simple players which is not and admin gets this message. How i can make what this message can get only admins: There is my code: (I am using zcmd)
Код:
COMMAND:foradmins( playerid, params[ ] )
{
      if(!params[0])
      {
         new zin[256] = "Admins online:";
          new name[MAX_PLAYER_NAME], x;
            for(new i = 0; i <MAX_PLAYERS; i++){
            if(IsPlayerConnected(i) && isPlayerAnAdmin(playerid,2)){
               x++;
               GetPlayerName(i,name,MAX_PLAYER_NAME);
               format(zin,256,"%i. %s.",x,name);
               SendClientMessage(playerid,0xFFFFFFFF,zin);
            }
         }
         return 1;
      }

      new zin[256],name[MAX_PLAYER_NAME];
      GetPlayerName(playerid,name,MAX_PLAYER_NAME);
      format(zin,sizeof(zin),"%s for admins: %s",name,params[0]);

      for(new i = 0; i <MAX_PLAYERS; i++)
      {
         if(IsPlayerConnected(i) && isPlayerAnAdmin(playerid,2))
         {
            SendClientMessage(i,0xFF8000FF,zin);
         }
      }
      SendClientMessage(playerid,0xFF8000FF,zin);
      return 1;
}
Reply
#2

pawn Код:
COMMAND:foradmins( playerid, params[ ] )
{
    if(isnull(params))
    {
    `   SendClientMessage(playerid,-1,"Admins Online:");
        new
            name[MAX_PLAYER_NAME],
            x
        ;
        for(new i = 0; i != MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && isPlayerAnAdmin(playerid,2))
            {
               x++;
               GetPlayerName(i,name,MAX_PLAYER_NAME);
               new String[32];
               format(String,sizeof(String),"%i. %s.",x,name);
               SendClientMessage(playerid,0xFFFFFFFF,String);
            }
        }
    }
    else
    {

        new
            String[128],
            name[MAX_PLAYER_NAME]
        ;
        GetPlayerName(playerid,name,MAX_PLAYER_NAME);
        format(String,sizeof(String),"%s for admins: %s",name,params);

        for(new i = 0; i != MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && isPlayerAnAdmin(playerid,2))
            {
                SendClientMessage(i,0xFF8000FF,String);
            }
        }
        SendClientMessage(playerid,0xFF8000FF,String);
    }
    return 1;
}
Reply
#3

No that shit works like mine and nothing different between your and mine code. Please someone help me!!!
Reply
#4

Try this:
pawn Код:
COMMAND:foradmins( playerid, params[ ] )
{
      if(!params[0])
      {
         new zin[256] = "Admins online:";
          new name[MAX_PLAYER_NAME], x;
            for(new i = 0; i <MAX_PLAYERS; i++){
            if(IsPlayerConnected(i) && isPlayerAnAdmin(playerid,2)){
               x++;
               GetPlayerName(i,name,MAX_PLAYER_NAME);
               format(zin,256,"%i. %s.",x,name);
               SendClientMessage(playerid,0xFFFFFFFF,zin);
            }
         }
         return 1;
      }

      new zin[128],name[MAX_PLAYER_NAME];
      GetPlayerName(playerid,name,MAX_PLAYER_NAME);
      format(zin,sizeof(zin),"%s for admins: %s",name,params[0]);

      for(new i = 0; i < MAX_PLAYERS; i++)
      {
         if(IsPlayerConnected(i) && isPlayerAnAdmin(i, 2))
         {
            SendClientMessage(i, 0xFF8000FF, zin);
         }
      }
      if(!isPlayerAnAdmin(playerid, 2)) SendClientMessage(playerid, 0xFF8000FF, zin);
      return 1;
}
Reply
#5

Thank you very much it works fine
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)