Jump to content

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 45
  • Eyes 1
  • Good 10
  • Love 2
  • Love 18

 

Link to comment
https://metin2.dev/topic/18360-chat-pm-system-name-message/
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
  • 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());
			....	
		}

 

 

  • 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 ;)

 

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • 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.