• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

[Request] c++ 2 messages each/min in help channel each player

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
7,037
Solutions
256
Reaction score
2,138
Location
Norway
GitHub
Znote
AS the topic says, is it possible to modify the TFS 0,2 sources to allow only 2 messages each minute from a player in the help channel?

Or is there an easier way to do this?
 
Could need like an alternative mute system only for the help channel then :p
 
Well... in chat.cpp you can find:

Code:
if(!fromPlayer->hasFlag(PlayerFlag_CannotBeMuted) && (m_id == 0x05 || m_id == 0x06))
	{
		Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_TRADETICKS, 120000, 0);
		fromPlayer->addCondition(condition);
	}

I guess if you change to this one:
Code:
if(!fromPlayer->hasFlag(PlayerFlag_CannotBeMuted) && (m_id == 0x05 || m_id == 0x06 || m_id == 0x08))
	{
		Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_TRADETICKS, 120000, 0);
		fromPlayer->addCondition(condition);
	}
It will work, allowing the player to 1 message each 2 minutes, but you will not be able to post on Trade Channel since it uses the same condiditon so... ^^
Actually, not many people use trade on OTServers...

Also need to edit this one:
Code:
		if(player->hasCondition(CONDITION_TRADETICKS) && (channelId == 0x05 || channelId == 0x06))
		{
			player->sendCancel("You may only place one offer in two minutes.");
			return false;
		}

To:
Code:
		if(player->hasCondition(CONDITION_TRADETICKS) && (channelId == 0x05 || channelId == 0x06 || channelId == 0x08))
		{
			player->sendCancel("You may only send one message in two minutes.");
			return false;
		}

Another edit...

You can try adding new condition (CONDITION_HELPTICKS) to condition.cpp, but you will also have to edit game.cpp, probably player.cpp and perhaps even more... I dont know anything about C++. :(
 
Last edited:
Ahh, thanks!

I'll use the trade condition, since as you say, Trade is not much in use. :)
 
Here i made it custom with everything you need

Chat.cpp

Under:
Code:
if(player->hasCondition(CONDITION_TRADETICKS) && (channelId == 0x05 || channelId == 0x06))
		{
			player->sendCancel("You may only place one offer in two minutes.");
			return false;
		}

Code:
else if(player->hasCondition(CONDITION_HELPTICKS) && (channelId == 0x08))
		{
			player->sendCancel("You may only speak every two minutes in this channel.");
			return false;
		}

Condition.cpp

Under:
Code:
case CONDITION_TRADETICKS:

Code:
case CONDITION_HELPTICKS:

Condition.h

Under:
Code:
ONDITION_EXHAUST_HEAL = 16777216,

Code:
CONDITION_HELPTICKS = 33554432

Game.cpp

Under:
Code:
Condition* conditionTrade = player->getCondition(CONDITION_TRADETICKS, CONDITIONID_DEFAULT);
		if(conditionTrade && conditionTrade->getTicks() > 0)
		{
			conditionTrade->setTicks(conditionTrade->getTicks() - (time(NULL) - player->getLastLogout()) * 1000);
			if(conditionTrade->getTicks() <= 0)
				player->removeCondition(conditionTrade);
			else
				player->addCondition(conditionTrade->clone());
		}

Code:
Condition* conditionHelp = player->getCondition(CONDITION_HELPTICKS, CONDITIONID_DEFAULT);
		if(conditionHelp && conditionHelp->getTicks() > 0)
		{
			conditionHelp->setTicks(conditionHelp->getTicks() - (time(NULL) - player->getLastLogout()) * 1000);
			if(conditionHelp->getTicks() <= 0)
				player->removeCondition(conditionHelp);
			else
				player->addCondition(conditionHelp->clone());
		}

and now just add this into your global.lua

Code:
CONDITION_HELPTICKS = 33554432

UPDATE! forgot 1 thing which you have to add!

Chat.cpp

Under:
Code:
if(!fromPlayer->hasFlag(PlayerFlag_CannotBeMuted) && (m_id == 0x05 || m_id == 0x06))
	{
		Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_TRADETICKS, 120000, 0);
		fromPlayer->addCondition(condition);
	}

Code:
if(!fromPlayer->hasFlag(PlayerFlag_CannotBeMuted) && (m_id == 0x08))
	{
		Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_HELPTICKS, 30000, 0);
		fromPlayer->addCondition(condition);
	}


I've tested it before posting here :)

kind regards, Evil Hero
 
Last edited:
CONDITION_HELPTICKS = Should be last number * 2, which is: 33554432
and will go under exhaust_heal
 
Have I forgotten something? I followed evil hero's instructions 100%. (Is this case sensitive to space and enter?)


Compile log:
Code:
Compiler: Default compiler
Building Makefile: "C:\Users\Stefan Brannfjell\Desktop\forgotten sources\project\Makefile.win"
Executing  make...
make.exe -f "C:\Users\Stefan Brannfjell\Desktop\forgotten sources\project\Makefile.win" all
g++.exe -c ../chat.cpp -o ../chat.o -I"C:/forgotten/include"  -D__USE_MYSQL__ -D__USE_SQLITE__  

In file included from ../creature.h:29,
                 from ../player.h:25,

                 from ../chat.cpp:24:
../condition.h:64: error: expected `}' before "CONDITION_HELPTICKS"

../condition.h:65: error: invalid conversion from `int' to `ConditionType_t'

../condition.h:65: error: expected `,' or `;' before '}' token

../condition.h:65: error: expected declaration before '}' token

In file included from ../creature.h:29,
                 from ../player.h:25,

                 from ../chat.cpp:24:
../condition.h:21:1: unterminated #ifndef
In file included from ../player.h:25,
                 from ../chat.cpp:24:

../creature.h:21:1: unterminated #ifndef
In file included from ../chat.cpp:24:
../player.h:21:1: unterminated #ifndef

make.exe: *** [../chat.o] Error 1

Execution terminated

985-compiler-error.png
 
Last edited:
I suck at tracking errors in this, learned to compile TFS for like 8 hours ago.

(download sources through tortoise svn, following nikolas tutorial and compiling it to .exe, run it bugfree). :P

Also, is there a way to change this to 2 messages/min instead of 1 message each 2 mins?

edit:
Code:
	CONDITION_EXHAUST_COMBAT	= 8388608,
	CONDITION_EXHAUST_HEAL		= 16777216
	CONDITION_HELPTICKS         = 33554432

I hope this was the error :P You was right with the comma :o
 
Last edited:
Back
Top