SA-MP Forums Archive
Problem with: /foradmins [text] - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem with: /foradmins [text] (/showthread.php?tid=256608)



Problem with: /foradmins [text] - Vvolk - 21.05.2011

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;
}



Re: Problem with: /foradmins [text] - Raimis_R - 21.05.2011

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;
}



Re: Problem with: /foradmins [text] - Vvolk - 21.05.2011

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


Re: Problem with: /foradmins [text] - Steve M. - 21.05.2011

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;
}



Re: Problem with: /foradmins [text] - Vvolk - 22.05.2011

Thank you very much it works fine