The @ and # don't work for Admin Chat feature, why?
#1

Hello AGAIN! I have this, (credits to Raven's Role Play)

pawn Код:
if(strcmp(cmd, "//", true) == 0 || strcmp(cmd, "/admin", true) == 0 || strcmp(cmd, "@", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[128];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "Usage: // [chat message], @ [chat message] or /admin [chat message]");
                return 1;
            }

            new arank[64];
            if(PlayerInfo[playerid][pAdmin] == 1) { arank = "Junior Mod"; } //By: Nick Piccoli
            else if(PlayerInfo[playerid][pAdmin] == 2) { arank = "Moderator"; } //By: Nick Piccoli
            else if(PlayerInfo[playerid][pAdmin] == 3) { arank = "Senior Mod"; } //By: Nick Piccoli
            else if(PlayerInfo[playerid][pAdmin] == 4) { arank = "Junior Admin"; } //By: Nick Piccoli
            else if(PlayerInfo[playerid][pAdmin] == 5) { arank = "Admin"; } //By: Nick Piccoli
            else if(PlayerInfo[playerid][pAdmin] == 6) { arank = "Senior Admin"; } //By: Nick Piccoli
            else if(PlayerInfo[playerid][pAdmin] == 1337) { arank = "Co-Owner"; } //By: Nick Piccoli
            else if(PlayerInfo[playerid][pAdmin] == 1338) { arank = "Owner"; } //By: Nick Piccoli
            else { arank = "Unknown"; }

            format(string, sizeof(string), " [%s] %s (%d): %s", arank, sendername, playerid, result);
            if (PlayerInfo[playerid][pAdmin] >= 1)
            {
                SendAdminMessage(COLOR_LIGHTRED, string);
            }
            printf("Admin %s: %s", sendername, result);
            new y, m, d;
            new h,mi,s;
            getdate(y,m,d);
            gettime(h,mi,s);
            format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] Admin %s: %s",d,m,y,h,mi,s,sendername, result);
            AdminChatLog(string);
        }
        return 1;
    }
    if(strcmp(cmd, "///", true) == 0 || strcmp(cmd, "/tester", true) == 0 || strcmp(cmd, "#", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
            if (PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pTester] >= 1 )
            {
                new length = strlen(cmdtext);
                while ((idx < length) && (cmdtext[idx] <= ' '))
                {
                    idx++;
                }
                new offset = idx;
                new result[128];
                while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                {
                    result[idx - offset] = cmdtext[idx];
                    idx++;
                }
                result[idx - offset] = EOS;
                if(!strlen(result))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "Usage: /// [chat message], # [chat message] or /tester [chat message]");
                    return 1;
                }

                new arank[64];
                if(PlayerInfo[playerid][pAdmin] == 1) { arank = "Junior Mod"; } //By: Nick Piccoli
                else if(PlayerInfo[playerid][pAdmin] == 2) { arank = "Moderator"; } //By: Nick Piccoli
                else if(PlayerInfo[playerid][pAdmin] == 3) { arank = "Senior Mod"; } //By: Nick Piccoli
                else if(PlayerInfo[playerid][pAdmin] == 4) { arank = "Junior Admin"; } //By: Nick Piccoli
                else if(PlayerInfo[playerid][pAdmin] == 5) { arank = "Admin"; } //By: Nick Piccoli
                else if(PlayerInfo[playerid][pAdmin] == 6) { arank = "Senior Admin"; } //By: Nick Piccoli
                else if(PlayerInfo[playerid][pAdmin] == 1337) { arank = "Co-Owner"; } //By: Nick Piccoli
                else if(PlayerInfo[playerid][pAdmin] == 1338) { arank = "Owner"; } //By: Nick Piccoli
          else if(PlayerInfo[playerid][pTester] == 3) { arank = "Lead Tester"; }
                else if(PlayerInfo[playerid][pTester] == 2) { arank = "Tester"; }
                else if(PlayerInfo[playerid][pTester] == 1) { arank = "Junior Tester"; }
                else { arank = "Unknown"; }
                format(string, sizeof(string), " [%s] %s (%d): %s", arank, sendername, playerid, result);
                SendTesterAdminMessage(COLOR_YELLOW, string);
                printf("Tester %s: %s", sendername, result);
                new y, m, d;
                new h,mi,s;
                getdate(y,m,d);
                gettime(h,mi,s);
                format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] Tester %s: %s",d,m,y,h,mi,s,sendername, result);
                AdminChatLog(string);
            }
        }
        return 1;
    }
but every time I type

pawn Код:
@[message] or #[message]
and I am an Admin, it doesn't work... Why not?

Thanks again!

*Again: Credits to GodFather and Raven's Role Play*
Reply
#2

Because commands require a '/' in front of them, and if you only type @ or # then clearly you're not typing a command... think about it.
Reply
#3

Quote:
Originally Posted by Joe Staff
Because commands require a '/' in front of them, and if you only type @ or # then clearly you're not typing a command... think about it.
Ah, okay. Well how come I have seen this done on other servers, did they edit the a_samp.cfg file perhaps?
Reply
#4

No, they use OnPlayerText then check "if (text[0] == '@' || text[0] == '#')"
Reply
#5

nevermind..i just looked at the Gm that uses the "//" for admin chat and yet i have no problems with it, try reverting back to the orginal admin message you had and go from there
Reply
#6

Quote:
Originally Posted by Simon
No, they use OnPlayerText then check "if (text[0] == '@' || text[0] == '#')"
Ah, okay. What would be the command I would need to use in order to make this with whats above?
Reply
#7

bump
Reply
#8

pawn Код:
//Admin Chat
if((text[0] == '#' || text[0] == '@') && admin_check && strlen(text) > 1)
{
  format(string,sizeof(string),"[ADMIN] %s (%i): %s",pName[playerid],playerid,text[1]);
  for(new i = 0; i < MAX_PLAY; i++)
  {
    if(admin_check) SendClientMessageToPlayer(i,COLOR_PINK,string);
  }
  return 0;
}
Put that under OnPlayerText, and replace the 2 admin_check's with your 'IsPlayerAdmin(playerid)' or whatever you use.
Reply
#9

Quote:
Originally Posted by Mikep.
pawn Код:
//Admin Chat
if((text[0] == '#' || text[0] == '@') && admin_check && strlen(text) > 1)
{
  format(string,sizeof(string),"[ADMIN] %s (%i): %s",pName[playerid],playerid,text[1]);
  for(new i = 0; i < MAX_PLAY; i++)
  {
    if(admin_check) SendClientMessageToPlayer(i,COLOR_PINK,string);
  }
  return 0;
}
Put that under OnPlayerText, and replace the 2 admin_check's with your 'IsPlayerAdmin(playerid)' or whatever you use.
Ah, thanks Mike!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)