• 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!

!frags

DedicatedOT

New Member
Joined
Jun 13, 2009
Messages
977
Reaction score
4
Location
USA
Lua:
bool Commands::playerKills(Creature* creature, const std::string& cmd, const std::string& param)
{
	Player* player = creature->getPlayer();
	if(player)
	{
		int32_t fragTime = g_config.getNumber(ConfigManager::FRAG_TIME);
		if(player->redSkullTicks && fragTime > 0)
		{
			int32_t frags = (player->redSkullTicks / fragTime) + 1;
			int32_t remainingTime = player->redSkullTicks - (fragTime * (frags - 1));
			int32_t hours = ((remainingTime / 1000) / 60) / 60;
			int32_t minutes = ((remainingTime / 1000) / 60) - (hours * 60);

			char buffer[175];
			sprintf(buffer, "You have %d unjustified frag%s. The amount of unjustified frags will decrease after: %s.", frags, (frags > 1 ? "s" : ""), formatTime(hours, minutes).c_str());
			player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, buffer);
		}
		else
			player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "You do not have any unjustified frag.");
	}
	return false;
}

That's from commands.cpp.

Whenever someone says !frags. It only says
Code:
You have 1 unjustified frag. The amount of unjustified frags will decrease after:.

So what is %s? It's not showing up correctly.
 
It's a method that sprintf uses. %s is replaced by a string during run time. Try changing it to %d and compile again
 
24yr8k2.png
 

Thanks man. I found it!

PHP:
std::string formatTime(int32_t hours, int32_t minutes)
{
	std::stringstream time("");
	if(hours)
		time << hours << " " << (hours > 1 ? "hours" : "hour") << (minutes ? " and " : "");

	if(minutes)
		time << minutes << " " << (minutes > 1 ? "minutes" : "minute");

	return time.str();
}
 
Back
Top