• 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

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,858
Reaction score
96
Location
Brazil
Credits:
Made by VirrageS and fix by Jetro and Migxxx

In game.cpp, search:

[cpp] 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;
} [/cpp]


Under, paste it:

[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]
 
Last edited:
it won't work with sentences like this:
Code:
w w w. s e r v e r . c o m
WWW.SERVER.COM
The sentence must be changed to lowercase and merged (to solve the space problem)
 
Under, paste it:

Code:
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]
std::string _text = asLowerCaseString(text);
for(int i=0; i<_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]
 
[cpp]
std::string _text = asLowerCaseString(text);
for(int i=0; i<_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]


I replaced my code with yours and its not compiling
 
after:
Code:
   		if(muted > 0)
		{
			char buffer[75];
			sprintf(buffer, "You are still muted for %d seconds.", muted);
			player->sendTextMessage(MSG_STATUS_SMALL, buffer);
		}
I've added
Code:
	std::string _text = asLowerCaseString(text);
	for(int i=0; i<_text.length(); i++)
	{
		if(_text[i]==' ')
		{
			_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;
	}

Errors:
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|3803|error: comparison between signed and unsigned integer expressions|
||=== Build finished: 1 errors, 0 warnings ===|
 
I tried with both 3777 & 3884 and it compiled just fine. Nothing wrong with VirrageS code.
 
replace this

Code:
        if(muted > 0)        
        {
            char buffer[75];
            sprintf(buffer, "You are still muted for %d seconds.", muted);
            player->sendTextMessage(MSG_STATUS_SMALL, buffer);
        }

with this

Code:
        if(muted && mute)        
        {
                char buffer[75];
                sprintf(buffer, "You are still muted for %d seconds.", muted);
                player->sendTextMessage(MSG_STATUS_SMALL, buffer);
                return false;
        }
 
Then it will be

Code:
if(muted && mute)
{
char buffer[75];
sprintf(buffer, "You are still muted for %d seconds.", muted);
                player->sendTextMessage(MSG_STATUS_SMALL, buffer);
returnfalse;
}
	std::string _text = asLowerCaseString(text);
	for(int i=0; i<_text.length(); i++)
	{
		if(_text[i]==' ')
		{
			_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;
	}

right?
 
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|3803|error: 'returnfalse' was not declared in this scope|
d:\openservers project\sources\trunk.r3777.r19\sources\game.cpp|3806|error: Comparison between signed and unsigned integer expressions|
||=== build finished: 2 errors, 0 warnings ===|
 
Paste your bool Game: PlayerSay here.
 
Code:
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;
	}

	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;
}
 
Code:
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;


    uint32_t muted = 0;
    bool mute = player->isMuted(channelId, type, muted);
    if(muted && mute)
    {
        char buffer[75];
        sprintf(buffer, "You are still muted for %d seconds.", muted);
        player->sendTextMessage(MSG_STATUS_SMALL, buffer);
        return false;
    }
    
    std::string _text = asLowerCaseString(text);
    for(int i=0; i<_text.length(); i++)
    {
        if(_text[i]==' ')
        {
            _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;
    }


    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;
}
 
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|3796|error: no matching function for call to 'Player::isMuted(uint16_t&, SpeakClasses&, uint32_t&)'|
D:\OpenServers Project\Sources\trunk.r3777.r19\sources\player.h|324|note: candidates are: bool Player::isMuted(uint16_t, SpeakClasses, int32_t&)|
D:\OpenServers Project\Sources\trunk.r3777.r19\sources\game.cpp|3806|error: comparison between signed and unsigned integer expressions|
||=== Build finished: 2 errors, 0 warnings ===|
 
Change from uint32_t muted = 0; to int32_t muted = 0;

I compared between r15 & r19 and that were the difference. Should work.
 
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|3939|error: Comparison between signed and unsigned integer expressions|
||=== build finished: 3 errors, 0 warnings ===|
 
But what if you want to redirect them to your own website? The thread title says it is only blocking other people advertising, but I don't see anything where you can whitelist your own.
 
Back
Top