Jump to content

How to modify this function to send a private message instead of a chat_whisper.


Recommended Posts

Hi could anyone tell me how to modify this function so that it will send a PM (private message) to the name after @ instead of a chat_type_whisper?

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

Thx.!

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

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.