viewing paste Unknown #1633 | C

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
// add to pc.h
enum packet_filter_option
{
        P_FILTER_NONE = 0x0,
        P_FILTER_CHAT = 0x1,
        P_FILTER_ITEM = 0x2,
        P_FILTER_HEAL = 0x4,
}
 
// in struct map_session_data.struct state
short packet_filter;
 
 
 
// replace original function with this
ACMD_FUNC(packetfilter)
{
        nullpo_retr(-1,sd);
       
        if( !message || !*message )
        {
                clif_displaymessage(fd, "<<----- Packet Filtering Usage ----->>");
                clif_displaymessage(fd, ".   @packetfilter <options>");
                clif_displaymessage(fd, ".   C : To filter global chat messages.");
                clif_displaymessage(fd, ".   I : To filter item usage.");
                clif_displaymessage(fd, ".   H : To filter heal effect.");
                clif_displaymessage(fd, ".   - Samples");
                clif_displaymessage(fd, ".   @packetfilter CIH : To filter the 3 options.");
                clif_displaymessage(fd, ".   @packetfilter I   : Only filter item usage.");
                clif_displaymessage(fd, ".   @packetfilter off : To turn packet filter off.");
        }
        else if( !strcmpi(message, "off") )
        {
                sd->state.packet_filter = P_FILTER_NONE;
                clif_displaymessage(fd,"<< Packet Filtering Off >>");
        }
        else
        {
                for ( ; *message; ++message) *message = TOLOWER(*message);
               
                if ( strstr(message, "c") )
                        sd->state.packet_filter |= P_FILTER_CHAT;
                if ( strstr(message, "i") )
                        sd->state.packet_filter |= P_FILTER_ITEM;
                if ( strstr(message, "h") )
                        sd->state.packet_filter |= P_FILTER_HEAL;
 
                sprintf(atcmd_output,"<< Packet Filtering | Chat %s | Items %s | Heal %s >>",
                        (sd->state.packet_filter&P_FILTER_CHAT) ? "ON" : "OFF",
                        (sd->state.packet_filter&P_FILTER_ITEM) ? "ON" : "OFF",
                        (sd->state.packet_filter&P_FILTER_HEAL) ? "ON" : "OFF"
                );
                       
                clif_displaymessage(fd,atcmd_output);
        }
 
        return 0;
}
 
 
// in clif_send_sub
        switch(type)
        {
        case AREA:
                if ( RBUFW(buf,0) == 0x1C8 && (map[sd->bl.m].flag.gvg || map[sd->bl.m].flag.battleground) && bl != src_bl && sd->state.packet_filter&P_FILTER_ITEM )
                        return 0; // Ignore other player's item usage
                if ( RBUFW(buf,0) == 0x11A && RBUFW(buf,2) == AL_HEAL && (map[sd->bl.m].flag.gvg || map[sd->bl.m].flag.battleground) && sd->state.packet_filter&P_FILTER_HEAL )
                        return 0; // Ignore heal effect
        break;
        case AREA_WOS:
                if (bl == src_bl)
                        return 0;
        break;
        case AREA_WOC:
                if (sd->chatID || bl == src_bl)
                        return 0;
                if( RBUFW(buf,0) == 0x8D && (map[sd->bl.m].flag.gvg || map[sd->bl.m].flag.battleground) && sd->state.packet_filter&P_FILTER_CHAT )
                        return 0;
        break;
        //... original code continues
Viewed 288 times, submitted by unknown.