Jump to content

Chat PM System (@name message)


Recommended Posts

  • Honorable Member

M2 Download Center

This is the hidden content, please
( Internal )

This is the hidden content, please
( GitHub )

Spoiler

232846nO69ZB.jpg

 

Usage: @name message

  • Metin2 Dev 39
  • Eyes 1
  • Good 8
  • Love 2
  • Love 10

 

Link to comment
Share on other sites

  • Premium
#ifdef CHAT_PM
	std::string findstr(buf);
	if (findstr.at(0) == '@') 
	{
		findstr = findstr.substr(1);
		int pos = findstr.find(" ");
		std::string message = findstr.substr(pos + 1), chname = findstr.substr(0, pos);

		LPCHARACTER stch = CHARACTER_MANAGER::instance().FindPC(chname.c_str());
		if (stch)
		{
			if (message.size() - chname.size() <= 1 )
			{
				ch->ChatPacket(CHAT_TYPE_INFO, "You haven't written a message or it is too short.");
				return (iExtraLen);
			}
          
			if (ch->GetLastPMPulse() < thecore_pulse())
					ch->ClearPMCounter();
		  
			if (ch->GetPMCounter() > 3 && ch->GetLastPMPulse() > thecore_pulse())
			{
					ch->GetDesc()->SetPhase(PHASE_CLOSE);
					return -1;
			}
			if (stch == ch)
			{
				ch->ChatPacket(CHAT_TYPE_INFO, "You can't send message to yourself.");
				return (iExtraLen);
			}
          
			stch->ChatPacket(CHAT_TYPE_WHISPER, "%s: %s", ch->GetName(), message.c_str());
			ch->ChatPacket(CHAT_TYPE_WHISPER, "To %s: %s", stch->GetName(), message.c_str());
			ch->IncreasePMCounter();
			ch->SetLastPMPulse();			
		}
		else
			ch->ChatPacket(CHAT_TYPE_INFO, "The player doesn't exist or is not online.");
		return (iExtraLen);
	}
#endif

I've made some improvements

  • Love 1
Link to comment
Share on other sites

  • Honorable Member

Thanks bro but this part is wrong

if (stch)
		{
			.....
			....
			stch->ChatPacket(CHAT_TYPE_WHISPER, "%s: %s", ch->GetName(), message.c_str());
			ch->ChatPacket(CHAT_TYPE_WHISPER, "To %s: %s", stch->GetName(), message.c_str());
			....	
		}
		else if (stch == ch)

You can use this:

		if (stch)
		{
			if (stch == ch)
				bla bla
			.....
			....
			stch->ChatPacket(CHAT_TYPE_WHISPER, "%s: %s", ch->GetName(), message.c_str());
			ch->ChatPacket(CHAT_TYPE_WHISPER, "To %s: %s", stch->GetName(), message.c_str());
			....	
		}

 

 

Link to comment
Share on other sites

  • Honorable Member
1 minute ago, Dobrescu Sebastian said:

Yep, I noticed and corrected. I tested. It works ok. There would still be ok if we make a check for 0 message length.

Okey okay ok I will add but now I'm going to sleep ;)

 

Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.