onplayertext bugged
#1

When i talk it goes like this:
banned(0): hi
banned: hi
pawn Код:
public OnPlayerText(playerid, text[])
{
    if (pmuted[playerid] == 1 )
    {
        SendClientMessage(playerid, green,"You can't talk while you are muted.");
        return 0;
    }
    new string[256];

    if(text[0] == '@')
        {
          if(UserUD[playerid][admin] > 0)
          {
                format(string, sizeof(string), "Admin: %s(%d): %s", UserUD[playerid][accname], playerid, text[1]);

              for(new j = 0; j < MAX_PLAYERS; j++)
                {
                if(IsPlayerConnected(j) && UserUD[j][admin] > 0) SendClientMessage(j, green, string);
                }
          }
          else
          {
            SendClientMessage(playerid,green,"You aren't a admin!");
            return 0;
          }
        }
    new textstring[256], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(textstring, sizeof(textstring), "%s(%d): %s", name, playerid, text);
    SendClientMessageToAll(GetPlayerColor(playerid),textstring);
    return 1;
}
Reply
#2

Quote:

banned(0): hi
banned: hi

Hm, and how do you want it to be?
Reply
#3

banned(0): hi, now it send the message 2 times.. :S
Reply
#4

Try:
pawn Код:
public OnPlayerText(playerid, text[])
{
    if (pmuted[playerid] == 1 )
    {
        SendClientMessage(playerid, green,"You can't talk while you are muted.");
        return 0;
    }
    new string[256];

    if(text[0] == '@')
        {
          if(UserUD[playerid][admin] >> 0)
          {
                format(string, sizeof(string), "Admin: %s(%d): %s", UserUD[playerid][accname], playerid, text[1]);

              for(new j = 0; j < MAX_PLAYERS; j++)
                {
                if(IsPlayerConnected(j) && UserUD[j][admin] >> 0) SendClientMessage(j, green, string);
                }
                return 0;
          }
          else
          {
            SendClientMessage(playerid,green,"You aren't a admin!");
            return 0;
          }
        }
    new textstring[256], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(textstring, sizeof(textstring), "%s(%d): %s", name, playerid, text);
    SendClientMessageToAll(GetPlayerColor(playerid),textstring);
    return 1;
}

(sorry that the indentation is kinda bad as I just edited your text...didn't use pawn or so)
Reply
#5

Quote:
Originally Posted by Seif_
No, just return 0 at the end of OnPlayerText.
if you'd replace the return 1; with a return 0; it would send no message...
Reply
#6

Quote:
Originally Posted by Sascha
Quote:
Originally Posted by Seif_
No, just return 0 at the end of OnPlayerText.
if you'd replace the return 1; with a return 0; it would send no message...
He means
pawn Код:
return 1;
}
return 0;
}
Reply
#7

Thanks Seif_ it worked, now i have a new problem :S Now when typing in admin chat it goes like this:

Admin: banned(0): hi
@banned(0): hi
Reply
#8

nvm, already fixed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)