• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Feature No advertising from others OTs

i use OTX and this works fine, it's the Virrage's code with the text.lenght parsed to int (it is an unsigned int), that was the error what LucasOlzon said:

[cpp]std::string _text = asLowerCaseString(text);
for(int i=0; i<int(_text.length()); i++)
{
if(_text==' ')
{
_text.erase(i, 1);
i--;
}
}

if(int(_text.find("servegame")) > 0 || int(_text.find("no-ip")) > 0 || int(_text.find(".net")) > 0 || int(_text.find(".com")) > 0 || int(_text.find(".br")) > 0 || int(_text.find(".com.br")) > 0 || int(_text.find(".org")) > 0 || int(_text.find(".pl")) > 0 || int(_text.find(".se")) > 0 || int(_text.find(".tk")) > 0 || int(_text.find(".cl")) > 0)
{
player->sendTextMessage(MSG_STATUS_SMALL, "You can't send this message, forbidden characters.");
return false;
}[/cpp]
 
Working now, added correct credits in main post. Thank you!

- - - Updated - - -

OMG, I've tested now and its not working :S
It's not blocking these messages
 
This one should get rid of most useless characters (leaving only a-z, "-", ".") in case people try to bypass it by adding symbols. Still ugly as fuck, but whatever.
PHP:
std::string _text = asLowerCaseString(text);
	for(uint8_t i = 0; i < _text.length(); i++)
	{
	    char t = _text[i];
		if(t != '-' && t != '.' && !(t >= 'a' && t <= 'z'))
		{
			_text.erase(i, 1);
			i--;
		}
	}

	if(_text.find("servegame") != std::string::npos || _text.find("no-ip") != std::string::npos || _text.find(".net") != std::string::npos || _text.find(".com") != std::string::npos || _text.find(".br") != std::string::npos || _text.find(".com.br") != std::string::npos || _text.find(".org") != std::string::npos || _text.find(".pl") != std::string::npos || _text.find(".se") != std::string::npos || _text.find(".tk") != std::string::npos || _text.find(".cl") != std::string::npos)
	{
		player->sendTextMessage(MSG_STATUS_SMALL, "You can't send this message, forbidden characters."); 
		return false;
	}
 
Well , i dunno if it is a correct way but it think it looks a bit better, also it checks if the word is equal than the forbidden word (LucasOlzon bug), i taken the code what Migxxx fixed to correct the sentence

[cpp]std::string _text = asLowerCaseString(text);
for(uint8_t i = 0; i < _text.length(); i++)
{
char t = _text;
if(t != '-' && t != '.' && !(t >= 'a' && t <= 'z'))
{
_text.erase(i, 1);
i--;
}
}

std::string words []= {".net", "servegame", "no-ip", ".net", ".com", ".com.br", ".org", ".pl", ".net"};
int ii, length;
length = sizeof(words)/sizeof(words[0]);
for(ii=0; ii < int(length); ii++)
{
if (int(_text.find(words[ii])) > 0 || _text == words[ii])
{
player->sendTextMessage(MSG_STATUS_SMALL, "You can't send this message, forbidden characters.");
return false;
break;
}

}[/cpp]
 
error

D:\OpenServers Project\Sources\trunk.r3777.r19\sources\game.cpp||In member function 'bool Game::playerSay(uint32_t, uint16_t, SpeakClasses, const std::string&, const std::string&)':|
D:\OpenServers Project\Sources\trunk.r3777.r19\sources\game.cpp|3965|error: expected '}' before 'else'|
D:\OpenServers Project\Sources\trunk.r3777.r19\sources\game.cpp|3971|error: expected unqualified-id before 'if'|
D:\OpenServers Project\Sources\trunk.r3777.r19\sources\game.cpp|3979|error: expected unqualified-id before 'if'|
D:\OpenServers Project\Sources\trunk.r3777.r19\sources\game.cpp|3983|error: expected unqualified-id before 'if'|
D:\OpenServers Project\Sources\trunk.r3777.r19\sources\game.cpp|3990|error: expected unqualified-id before 'if'|
D:\OpenServers Project\Sources\trunk.r3777.r19\sources\game.cpp|3993|error: expected unqualified-id before 'if'|
D:\OpenServers Project\Sources\trunk.r3777.r19\sources\game.cpp|3996|error: expected unqualified-id before 'switch'|
||=== Build finished: 7 errors, 0 warnings ===|
 
[cpp]bool Game::playerSay(uint32_t playerId, uint16_t channelId, SpeakClasses type, const std::string& receiver, const std::string& text)
{
Player* player = getPlayerByID(playerId);
if(!player || player->isRemoved())
return false;

int32_t muted = 0;
bool mute = player->isMuted(channelId, type, muted);
if(muted && mute)
{
if(muted > 0)
{
char buffer[75];
sprintf(buffer, "You are still muted for %d seconds.", muted);
player->sendTextMessage(MSG_STATUS_SMALL, buffer);
}


//YOUR CODE HERE
std::string _text = asLowerCaseString(text);
for(uint8_t i = 0; i < _text.length(); i++)
{
char t = _text;
if(t != '-' && t != '.' && !(t >= 'a' && t <= 'z'))
{
_text.erase(i, 1);
i--;
}
}

std::string words []= {".net", "servegame", "no-ip", ".net", ".com", ".com.br", ".org", ".pl", ".net"};
int ii, length;
length = sizeof(words)/sizeof(words[0]);
for(ii=0; ii < int(length); ii++)
{
if (int(_text.find(words[ii])) > 0 || _text == words[ii])
{
player->sendTextMessage(MSG_STATUS_SMALL, "You can't send this message, forbidden characters.");
return false;
break;
}

}
//YOUR CODE HERE



else
player->sendTextMessage(MSG_STATUS_SMALL, "You are muted permanently.");

return false;
}

if(player->isAccountManager())
{
if(mute)
player->removeMessageBuffer();

return internalCreatureSay(player, SPEAK_SAY, text, false);
}

if(g_talkActions->onPlayerSay(player, type == SPEAK_SAY ? (unsigned)CHANNEL_DEFAULT : channelId, text, false))
return true;

ReturnValue ret = RET_NOERROR;
if(!muted)
{
ret = g_spells->onPlayerSay(player, text);
if(ret == RET_NOERROR || (ret == RET_NEEDEXCHANGE && !g_config.getBool(ConfigManager::BUFFER_SPELL_FAILURE)))
return true;
}

if(mute)
player->removeMessageBuffer();

if(ret == RET_NEEDEXCHANGE)
return true;

switch(type)
{
case SPEAK_SAY:
return internalCreatureSay(player, SPEAK_SAY, text, false);
case SPEAK_WHISPER:
return playerWhisper(player, text);
case SPEAK_YELL:
return playerYell(player, text);
case SPEAK_PRIVATE:
case SPEAK_PRIVATE_RED:
case SPEAK_RVR_ANSWER:
return playerSpeakTo(player, type, receiver, text);
case SPEAK_CHANNEL_O:
case SPEAK_CHANNEL_Y:
case SPEAK_CHANNEL_RN:
case SPEAK_CHANNEL_RA:
case SPEAK_CHANNEL_W:
{
if(playerTalkToChannel(player, type, text, channelId))
return true;

return playerSay(playerId, 0, SPEAK_SAY, receiver, text);
}
case SPEAK_PRIVATE_PN:
return playerSpeakToNpc(player, text);
case SPEAK_BROADCAST:
return playerBroadcastMessage(player, SPEAK_BROADCAST, text);
case SPEAK_RVR_CHANNEL:
return playerReportRuleViolation(player, text);
case SPEAK_RVR_CONTINUE:
return playerContinueReport(player, text);

default:
break;
}

return false;
}[/cpp]
 
now try:
[cpp]bool Game::playerSay(uint32_t playerId, uint16_t channelId, SpeakClasses type, const std::string& receiver, const std::string& text)
{
Player* player = getPlayerByID(playerId);
if(!player || player->isRemoved())
return false;

int32_t muted = 0;
bool mute = player->isMuted(channelId, type, muted);
if(muted && mute)
{
if(muted > 0)
{
char buffer[75];
sprintf(buffer, "You are still muted for %d seconds.", muted);
player->sendTextMessage(MSG_STATUS_SMALL, buffer);
}

else
player->sendTextMessage(MSG_STATUS_SMALL, "You are muted permanently.");

return false;
}


std::string _text = asLowerCaseString(text);
for(uint8_t i = 0; i < _text.length(); i++)
{
char t = _text;
if(t != '-' && t != '.' && !(t >= 'a' && t <= 'z'))
{
_text.erase(i, 1);
i--;
}
}

std::string words []= {".net", "servegame", "no-ip", ".net", ".com", ".com.br", ".org", ".pl", ".net"};
int ii, length;
length = sizeof(words)/sizeof(words[0]);
for(ii=0; ii < int(length); ii++)
{
if (int(_text.find(words[ii])) > 0 || _text == words[ii])
{
player->sendTextMessage(MSG_STATUS_SMALL, "You can't send this message, forbidden characters.");
return false;
break;
}

}

if(player->isAccountManager())
{
if(mute)
player->removeMessageBuffer();

return internalCreatureSay(player, SPEAK_SAY, text, false);
}

if(g_talkActions->onPlayerSay(player, type == SPEAK_SAY ? (unsigned)CHANNEL_DEFAULT : channelId, text, false))
return true;

ReturnValue ret = RET_NOERROR;
if(!muted)
{
ret = g_spells->onPlayerSay(player, text);
if(ret == RET_NOERROR || (ret == RET_NEEDEXCHANGE && !g_config.getBool(ConfigManager::BUFFER_SPELL_FAILURE)))
return true;
}

if(mute)
player->removeMessageBuffer();

if(ret == RET_NEEDEXCHANGE)
return true;

switch(type)
{
case SPEAK_SAY:
return internalCreatureSay(player, SPEAK_SAY, text, false);
case SPEAK_WHISPER:
return playerWhisper(player, text);
case SPEAK_YELL:
return playerYell(player, text);
case SPEAK_PRIVATE:
case SPEAK_PRIVATE_RED:
case SPEAK_RVR_ANSWER:
return playerSpeakTo(player, type, receiver, text);
case SPEAK_CHANNEL_O:
case SPEAK_CHANNEL_Y:
case SPEAK_CHANNEL_RN:
case SPEAK_CHANNEL_RA:
case SPEAK_CHANNEL_W:
{
if(playerTalkToChannel(player, type, text, channelId))
return true;

return playerSay(playerId, 0, SPEAK_SAY, receiver, text);
}
case SPEAK_PRIVATE_PN:
return playerSpeakToNpc(player, text);
case SPEAK_BROADCAST:
return playerBroadcastMessage(player, SPEAK_BROADCAST, text);
case SPEAK_RVR_CHANNEL:
return playerReportRuleViolation(player, text);
case SPEAK_RVR_CONTINUE:
return playerContinueReport(player, text);

default:
break;
}

return false;
}[/cpp]
 
You should whitelist the server ip from the config.lua, that way people can still give urls from the ots website.
 
Back
Top