Here is how I made the whisper button using the block by name function, exactly how it works from the messenger window when you type the name yourself.
uiwhisper.py
Search:
self.minimizeButton = GetObject("minimizebutton")
Add below:
self.blockPlayer = GetObject("blockplayer")
Search:
self.chatLine.SetEscapeEvent(ui.__mem_func__(self.Minimize))
Add below:
self.blockPlayer.SetEvent(ui.__mem_func__(self.BlockPlayer))
Search:
self.minimizeButton = None
Add below:
self.blockPlayer = None
Search:
Under def OpenWithTarget(self, targetName): function
self.minimizeButton.Show()
Add below:
if app.ENABLE_MESSENGER_BLOCK:
if not messenger.IsBlockByName(self.targetName):
self.blockPlayer.Show()
else:
self.blockPlayer.Hide()
Search:
Under def OpenWithoutTarget(self, event): function
self.minimizeButton.Hide()
Add below:
if app.ENABLE_MESSENGER_BLOCK:
if not messenger.IsBlockByName(self.targetName):
self.blockPlayer.Show()
else:
self.blockPlayer.Hide()
Search:
def ReportViolentWhisper(self):
Add before:
def BlockPlayer(self):
net.SendMessengerAddBlockByNamePacket(self.targetName)
uiscript/whisperdialog.py
Search:
{
"name" : "reportviolentwhisperbutton",
"type" : "button",
"x" : 145,
"y" : 10,
"text" : uiScriptLocale.WHISPER_REPORT,
"default_image" : "d:/ymir work/ui/public/large_button_01.sub",
"over_image" : "d:/ymir work/ui/public/large_button_02.sub",
"down_image" : "d:/ymir work/ui/public/large_button_03.sub",
},
Add below:
{
"name" : "blockplayer",
"type" : "button",
"x" : 145,
"y" : 10,
"text" : uiScriptLocale.WHISPER_BLOCK,
"default_image" : "d:/ymir work/ui/public/small_thin_button_01.sub",
"over_image" : "d:/ymir work/ui/public/small_thin_button_02.sub",
"down_image" : "d:/ymir work/ui/public/small_thin_button_03.sub",
},
You may need to play with the button in the whisper window because I got more buttons and It might be arranged differently.
Edit: Also this version of the system is not full, you might wanna try and take it from some serverfiles which fixed most things for it. The only problem I am having now is cross core, it does not block the players if they are on different cores.
Edit 2: Cross core fix
After I made this "fix", I totally removed the system from my sources. Fixing one problem gets you to 100 more.
You might need to change MESSENGER_BLOCK with yours as I changed the functions and made more checks.
Fixing this problem will get you to another core problem, when on different cores if the blocker removes the blocked, the blocked one is being disconnected and the blocker gets some errors and needs to relog in order to do anything.
I know some servers that were using this system and removed it later on, but if properly fixed it might get your job done.
Search:
if (test_server)
sys_log(0, "Whisper to %s from %s (Channel %d Mapindex %d)", "Null", ch->GetName(), pkCCI->bChannel, pkCCI->lMapIndex);
Add below:
#ifdef __MESSENGER_BLOCK_SYSTEM__
if (MessengerManager::instance().CheckMessengerList(ch->GetName(), pkCCI->szName, MESSENGER_BLOCK))
{
if (ch->GetDesc())
{
TPacketGCWhisper pack;
char msg[CHAT_MAX_LEN + 1];
snprintf(msg, sizeof(msg), LC_TEXT("Unblock %s to continue."), pkCCI->szName);
int len = MIN(CHAT_MAX_LEN, strlen(msg) + 1);
pack.bHeader = HEADER_GC_WHISPER;
pack.wSize = sizeof(TPacketGCWhisper) + len;
pack.bType = WHISPER_TYPE_SYSTEM;
strlcpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom));
TEMP_BUFFER buf;
buf.write(&pack, sizeof(TPacketGCWhisper));
buf.write(msg, len);
ch->GetDesc()->Packet(buf.read_peek(), buf.size());
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Unblock %s to continue."), pkCCI->szName);
}
return iExtraLen;
}
else if (MessengerManager::instance().CheckMessengerList(pkCCI->szName, ch->GetName(), MESSENGER_BLOCK))
{
if (ch->GetDesc())
{
TPacketGCWhisper pack;
char msg[CHAT_MAX_LEN + 1];
snprintf(msg, sizeof(msg), LC_TEXT("%s has blocked you."), pkCCI->szName);
int len = MIN(CHAT_MAX_LEN, strlen(msg) + 1);
pack.bHeader = HEADER_GC_WHISPER;
pack.wSize = sizeof(TPacketGCWhisper) + len;
pack.bType = WHISPER_TYPE_SYSTEM;
strlcpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom));
TEMP_BUFFER buf;
buf.write(&pack, sizeof(TPacketGCWhisper));
buf.write(msg, len);
ch->GetDesc()->Packet(buf.read_peek(), buf.size());
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s has blocked you."), pkCCI->szName);
}
return iExtraLen;
}
#endif