[FilterScript] Highlight player names on chat!
#1

Highlight player names on chat
This is a simple filterscript which highlights online player names on chat if they're found, just like you see on Skype or IRC chats. This filterscript contains configuration which can be done to change the behavior of this filterscript.

Screens

- List of players who are online.



- Chat style



Download

https://github.com/falle3n/Nick_High..._Chat/releases
Raw source : https://raw.githubusercontent.com/fa...pts/fNHLOC.pwn

Configuration (optional, only needed if you want to change the way how this filterscript works)

There's two defines called DEFAULT_HIGHLIGHT_COLOR and SHOW_ID_ONCHAT and both of them are defined by default. If you undefine the first one, the highlighting color will be according to the color of player. You can edit that define to highlight on your custom color, currently it's light blue. The second define means that if the player ID should be shown on chat. If you undefine it, the output of the chat will be like how it's on default SA-MP chat, however player name on chat will be highlighted if found.

(optional notes)
NOTE : This filterscript can run with or without foreach. You can comment out foreach include line if you don't want to use foreach however I prefer using it.

NOTE2 : If you want to build your custom text system using this highlight, comment out SHOW_ID_ONCHAT and get to line near 123. There you can see a function named SendPlayerMessageToAll, remove it out. And then instead of using text parameter, use string array.
Reply
#2

cool
can you upload the code to pastebin.com?
thanks.
Reply
#3

Simple and Nice I like it
Nice Work
Reply
#4

good work
Reply
#5

That's great, good work
Reply
#6

Quote:
Originally Posted by stev212
Посмотреть сообщение
cool
can you upload the code to pastebin.com?
thanks.
Here's the raw format, you would have got it if you went to the homepage of the project. It was located at "/filterscripts".
https://raw.githubusercontent.com/fa...pts/fNHLOC.pwn

Thanks everyone for your appreciation.
Reply
#7

This is nice; however, you need to have a big string in case there are a lot of names included in the text.
Reply
#8

Quote:
Originally Posted by Cell_
Посмотреть сообщение
This is nice; however, you need to have a big string in case there are a lot of names included in the text.
I never thought about that, thanks for noting. I will edit it according to the value of MAX_PLAYERS.
Reply
#9

Nice one dude
Reply
#10

simply as hell but cool idea +
Reply
#11

Great idea and attempt, Love it.
Reply
#12

Good work
Reply
#13

Nice ^^
Reply
#14

please make this on my onplayertext...
Код:
public OnPlayerText(playerid, text[]) 
{
 
        if(Gracz[playerid][Zalogowany] == true)
        {
                if(Gracz[playerid][BlockChat] == 0)
                {
                        new name[MAX_PLAYER_NAME];
                        GetPlayerName(playerid,name,sizeof(name));
                        new wiadomosc[500];
                        new RangaText[100];
                        if(Ranga[playerid] == 0){RangaText = "{AFAFAF}Traucer";}
                        if(Ranga[playerid] == 1){RangaText = "{F6FF00}VIP";}
                        if(Ranga[playerid] == 2){RangaText = "{FF0000}Admin";}
                        if(Ranga[playerid] == 3){RangaText = "{00B2FF}Elite";}
                        format(wiadomosc, sizeof(wiadomosc), "%s{FFFFFF}({F6FF00}%d{FFFFFF})[%s{FFFFFF}]: %s",name,playerid, RangaText,text);
                        if(strlen(wiadomosc) > MAX_CHAT_LENGHT + (8 * 4))
                        {
                                new str[128], str2[128];
                                strmid(str, wiadomosc, 0, MAX_CHAT_LENGHT + (8 * 4));
                                strmid(str2, wiadomosc, MAX_CHAT_LENGHT + (8 * 4) + 0, strlen(wiadomosc));
                                SendClientMessageToAll(GetPlayerColor(playerid), str);
                                SendClientMessageToAll(0xFFFFFFFF, str2);
                        }
                        else
                        {
                                SendClientMessageToAll( GetPlayerColor(playerid) , wiadomosc);
                        }
                        print(wiadomosc);
                }
                else
                {
                        SendClientLangMessage(playerid, C_CZERWONY, "Nie mozesz pisac bedac zablokowanym na chacie!", "You are blocked on chat!");
                        return 0;
                }
        }
        else
        {
                SendClientLangMessage(playerid, C_CZERWONY, "Nie mozesz pisac bedac niezalogowany/a!", "Must been login to send message on chat");
        }
        return 0;
}
Reply
#15

Thank you all I'm glad that most of them likes it.

Quote:
Originally Posted by joevega12
Посмотреть сообщение
please make this on my onplayertext...
Код:
public OnPlayerText(playerid, text[]) 
{
 
        if(Gracz[playerid][Zalogowany] == true)
        {
                if(Gracz[playerid][BlockChat] == 0)
                {
                        new name[MAX_PLAYER_NAME];
                        GetPlayerName(playerid,name,sizeof(name));
                        new wiadomosc[500];
                        new RangaText[100];
                        if(Ranga[playerid] == 0){RangaText = "{AFAFAF}Traucer";}
                        if(Ranga[playerid] == 1){RangaText = "{F6FF00}VIP";}
                        if(Ranga[playerid] == 2){RangaText = "{FF0000}Admin";}
                        if(Ranga[playerid] == 3){RangaText = "{00B2FF}Elite";}
                        format(wiadomosc, sizeof(wiadomosc), "%s{FFFFFF}({F6FF00}%d{FFFFFF})[%s{FFFFFF}]: %s",name,playerid, RangaText,text);
                        if(strlen(wiadomosc) > MAX_CHAT_LENGHT + (8 * 4))
                        {
                                new str[128], str2[128];
                                strmid(str, wiadomosc, 0, MAX_CHAT_LENGHT + (8 * 4));
                                strmid(str2, wiadomosc, MAX_CHAT_LENGHT + (8 * 4) + 0, strlen(wiadomosc));
                                SendClientMessageToAll(GetPlayerColor(playerid), str);
                                SendClientMessageToAll(0xFFFFFFFF, str2);
                        }
                        else
                        {
                                SendClientMessageToAll( GetPlayerColor(playerid) , wiadomosc);
                        }
                        print(wiadomosc);
                }
                else
                {
                        SendClientLangMessage(playerid, C_CZERWONY, "Nie mozesz pisac bedac zablokowanym na chacie!", "You are blocked on chat!");
                        return 0;
                }
        }
        else
        {
                SendClientLangMessage(playerid, C_CZERWONY, "Nie mozesz pisac bedac niezalogowany/a!", "Must been login to send message on chat");
        }
        return 0;
}
Here, you can follow the below codes. I've forwarded a callback named "MyOnPlayerText". Whatever is there under your OnPlayerText can be put under MyOnPlayerText.

pawn Код:
/*

================================================================================
                        Highlight nickname on chat - v1.0
                        By fall3n

This is a simple filterscript which highlights online player's name if it's
typed on chat, just like on Skype calls or IRC chats. The highlight color either
can be a custom color or uses GetPlayerColor to get the player's color. If it
runs by using GetPlayerColor you will need to use SetPlayerColor or else
it might return black. By default, it uses a custom color.

LICENSE:

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

Credits:

fall3n - For the complete filterscript.
****** - For foreach include.
SA-MP Team - For SA-MP!

NOTE : This include can run with or without foreach. I prefer using foreach.

RUN MODES :

If you undefined DEFAULT_HIGHLIGHT_COLOR - It will highlight the player name by
getting the player's color. If it's not set, it will return 0 which is black.

If you undefine SHOW_ID_ONCHAT - It will just highlight the player like on a
normal chat system provided by SA-MP.


Github release link:

https://github.com/falle3n/Nick_Highlight_On_Chat

================================================================================
*/


#define FILTERSCRIPT

#include <a_samp>
#include <foreach>

#define DEFAULT_HIGHLIGHT_COLOR "{c3e4f5}" //By default it's light blue colored.
//#define SHOW_ID_ONCHAT //comment to use sa-mp default chat output system.


new
    g_PlayerName[MAX_PLAYERS][MAX_PLAYER_NAME];

stock strcpy(dest[], const source[], size = sizeof(dest))
{
    return strcat((dest[0] = '\0', dest), source, size);
}

public OnPlayerConnect(playerid)
{
    GetPlayerName(playerid, g_PlayerName[playerid], MAX_PLAYER_NAME);
    return 1;
}

public OnFilterScriptInit()
{
    for(new i, j = GetMaxPlayers(); i< j; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        #if defined _inc_foreach
            CallLocalFunction("OnPlayerConnect", "i", i); //There are some issues with foreach so calling out local OPC.
        #endif
        OnPlayerConnect(i); //script sided opc.
    }
    return 1;
}

public OnPlayerText(playerid, text[])
{
    new
        pos = -1,
        string[200]
        #if !defined DEFAULT_HIGHLIGHT_COLOR
            ,cstr[12]
        #endif
    ;

    strcpy(string, text, sizeof(string));
    #if !defined _inc_foreach
    for(new i, j = GetMaxPlayers(); i< j; i++)
    {
        if(!IsPlayerConnected(i)) continue;
    #else
    foreach(new i : Player)
    {
    #endif
        pos = strfind(string, g_PlayerName[i], false);
        if(pos != -1)
        {
            strins(string, "{FFFFFF}", pos + strlen(g_PlayerName[i]), sizeof(string));
            #if !defined DEFAULT_HIGHLIGHT_COLOR
                format(cstr, sizeof(cstr), "{%06x}", GetPlayerColor(i) >>> 8);
                strins(string, cstr, pos, sizeof(string));
            #else
                strins(string, #DEFAULT_HIGHLIGHT_COLOR, pos, sizeof(string));
            #endif
        }
    }
    #if !defined SHOW_ID_ONCHAT

        return MyOnPlayerText(playerid, string);
    #else
        new
            output[180],
            col = GetPlayerColor(playerid);
        format(output, sizeof(output), "%s (%d):{FFFFFF} %s", g_PlayerName[playerid], playerid, string);
        SendClientMessageToAll(((col == 0) ? 0xFF0000AA : col), output);
    #endif
    return 0;
}

forward MyOnPlayerText(playerid, string[]);

public MyOnPlayerText(playerid, string[])
{
    //Simply paste your OnPlayerText codes here
    return 0; //Return 1 if you don't use a custom chat.
}
I haven't tested it but I'm pretty sure that it might work.
Reply
#16

There had been a small update done based on what Cell_ has suggested about increasing cell size because it can do broken output in case if many names are included on chat. To save memory, I've only set it to 256. Consider increasing it if players tend to input many nick names on chat.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)