OnPlayerText (+Rep)
#1

I tried to make if a player chat then his id should show after his name
for eg:
Quote:

Crazyboobz [1]: Text

After i made it is showing like this


How can i fix this?

OnPlayerText Callback

pawn Code:
public OnPlayerText(playerid, text[]){
    new
    output[128];

    format(output, sizeof(output), "(%d) %s", playerid, text);
    SendPlayerMessageToAll(playerid, output);
    if(IsIp(text))
    {
        new dsname[MAX_PLAYER_NAME];
        new string[256];
        GetPlayerName(playerid, dsname, sizeof(dsname));
        format(string, sizeof(string), "%s has been kicked from the server [Reason : Advertisement]", dsname);
        SendClientMessageToAll(0xFF0000AA, string);
        SendClientMessage(playerid, 0x999999AA, "You may not advertice BITCH!!");
        Kick(playerid);
        return 0;
    }
    new str[256];
    new is1 = 0;
    new r = 0;
    while(strlen(text[is1]))
    {
        if('0'<=text[is1]<='9')
        {
            new is2=is1+1;
            new p=0;
            while(p==0)
            {
                if('0'<=text[is2]<='9'&&strlen(text[is2])) is2++;
                else
                {
                    strmid(str[r],text,is1,is2,255);
                    if(strval(str[r])<255) r++;
                    is1 = is2;
                    p = 1;
                }
            }
        }
        is1++;
    }
    if(r>=4)
    {
        for(new z=0;z<r;z++)
        {
            new pr2;
            while((pr2=strfind(text,str[z],true))!=-1) for(new i=pr2,j=pr2+strlen(str[z]);i<j;i++) text[i]='*';
        }
    }
//------------------------------------------------------------------------------
    if(IsIPInText(text)) {
        SendClientMessage(playerid,RED,"You are not allowed to use IP adresses in your chat!");
        return 1;}
    if(text[0] == '@' && PlayerInfo[playerid][Level] >= 1) {
        new to_others[MAX_CHATBUBBLE_LENGTH+1];
        format(to_others,MAX_CHATBUBBLE_LENGTH,"[%d] Says: %s",text);
        SetPlayerChatBubble(playerid,to_others,MESSAGE_COLOR,35.0,10000);
        return 0;}
    for(new i = 1; i < MAX_CHAT_LINES-1; i++) Chat[i] = Chat[i+1];
    new ChatSTR[128]; GetPlayerName(playerid,ChatSTR,sizeof(ChatSTR)); format(ChatSTR,128,"[lchat]%s: %s",ChatSTR, text[0] );
    Chat[MAX_CHAT_LINES-1] = ChatSTR;
    if(PlayerInfo[playerid][Caps] == 1) UpperToLower(text);
    if(ServerInfo[NoCaps] == 1) UpperToLower(text);
    if(ServerInfo[DisableChat] == 1) {
        SendClientMessage(playerid,red,"Chat has been disabled");
        return 0;}
    if(PlayerInfo[playerid][Muted] == 1){
        PlayerInfo[playerid][MuteWarnings]++;
        new string[128];
        if(PlayerInfo[playerid][MuteWarnings] < ServerInfo[MaxMuteWarnings]) {
            format(string, sizeof(string),"WARNING: You are muted, if you continue to speak you will be kicked. (%d / %d)", PlayerInfo[playerid][MuteWarnings], ServerInfo[MaxMuteWarnings] );
            SendClientMessage(playerid,red,string);
        } else {
            SendClientMessage(playerid,red,"You have been warned ! Now you have been kicked");
            format(string, sizeof(string),"***%s (ID %d) was kicked for exceeding mute warnings", PlayerName2(playerid), playerid);
            SendClientMessageToAll(grey,string);
            SaveToFile("KickLog",string); Kick(playerid);}
        return 0;}
    if(ServerInfo[AntiSpam] == 1 && (PlayerInfo[playerid][Level] == 0 && !IsPlayerAdmin(playerid)) ){
        if(PlayerInfo[playerid][SpamCount] == 0) PlayerInfo[playerid][SpamTime] = TimeStamp();
        PlayerInfo[playerid][SpamCount]++;
        if(TimeStamp() - PlayerInfo[playerid][SpamTime] > SPAM_TIMELIMIT) { // Its OK your messages were far enough apart
            PlayerInfo[playerid][SpamCount] = 0;
            PlayerInfo[playerid][SpamTime] = TimeStamp();}
        else if(PlayerInfo[playerid][SpamCount] == SPAM_MAX_MSGS){
            new string[64]; format(string,sizeof(string),"%s has been kicked (Flood/Spam Protection)", PlayerName2(playerid));
            SendClientMessageToAll(grey,string); print(string);
            SaveToFile("KickLog",string);
            Kick(playerid); }
        else if(PlayerInfo[playerid][SpamCount] == SPAM_MAX_MSGS-1) {
            SendClientMessage(playerid,red,"Anti Spam Warning! Next is a kick.");
            return 0;}}
    if(ServerInfo[AntiSwear] == 1 && PlayerInfo[playerid][Level] < ServerInfo[MaxAdminLevel])
    for(new s = 0; s < ForbiddenWordCount; s++){
        new pos;
        while((pos = strfind(text,ForbiddenWords[s],true)) != -1) for(new i = pos, j = pos + strlen(ForbiddenWords[s]); i < j; i++) text[i] = '*';}
    if (Calling[playerid] > -1 && Answered[playerid] == 1){
        new string[128];
        new sendername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "%s: %s", sendername, text);
        SendClientMessage(Calling[playerid], COLOR_YELLOW, string);
        format(string, sizeof(string), "%s: %s", sendername, text);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
        format(string, sizeof(string), "%s: %s", sendername, text);
        print(string);
        format(string, sizeof(string), "%s: %s", sendername, text);
        print(string);
        return 0;}
    else{
        new to_others[MAX_CHATBUBBLE_LENGTH+1];
        format(to_others,MAX_CHATBUBBLE_LENGTH,"Says: %s",text);
        SetPlayerChatBubble(playerid,to_others,MESSAGE_COLOR,35.0,10000);}
       
        new playname[MAX_PLAYER_NAME], ircMsg[256];
        GetPlayerName(playerid, playname, sizeof(playname));
        format(ircMsg, sizeof(ircMsg), "02[%d] 07%s: %s", playerid, playname, text);
        IRC_GroupSay(gGroupID,IRC_CHANNEL,ircMsg);
        return 1;}
Reply
#2

Use SendClientMessageToAll instead... Example:

pawn Code:
public OnPlayerText(playerid, text[])
{
    new output[128], pname[24];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(output, sizeof(output), "%s (%d): %s", pname, playerid, text);
        SendClientMessageToAll(color, output);
    return 0;
}
And do something to prevent the original text from sending.

EDIT:
Did return 0;
Reply
#3

I dont know how to prevent the orginal text.. thats the problem.
Reply
#4

Fixed ^^
Reply
#5

Thank you +Rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)