// 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