In my C++ MUD game i want to be able to eliminate the player from being able to enter curse words. You all know what they are, no need for examples. So i tried something like this:
vector<string> vulger = { "You know what goes in here");
void Player::SendString(const std::string& p_string)
{
for (vector<string>::iterator it = vulger.begin(); it != vulger.end(); ++it)
{
if (!p_string.compare(*it) || !p_string.find(*it))
{
//Testing what words are been neglected by the if statement.
//cout << *it;
Conn()->Protocol().SendString(*Conn(), p_string + newline);
}
}
}
But all this does is loop through strings that are sent to the network. Including announcments.
Can anyone see what im doing wrong or suggest anything maybe ?
Change the
||
in yourif
statement to&&
: