• 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 Auto clean after "xx" time

Wazzap

Killing Elite
Joined
Jun 15, 2010
Messages
124
Reaction score
4
Location
London / Poland
1.Description: After the expiration of the time specified in the config message appears cleanie
1 minute to clean. Get your things from floor now!
2. Tibia 7.60
3. Code
In game.cpp below
long Game::cleanMap()
{
OTSYS_THREAD_LOCK_CLASS lockClass(gameLock, "Game::cleanMap()");
return map->clean();
}
Add:
#ifdef _BBK_KIED_CLEAN__
long Game::beforeClean()
{
for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it) {
it->second->sendTextMessage(MSG_RED_INFO, "1 minute to clean. Get your things from floor now!");
}
addEvent(makeTask(60000, std::mem_fun(&Game::secondsToClean)));
}
void Game::secondsToClean()
{
autocleanMap(5);
}
void Game::autocleanMap(int seconds)
{
OTSYS_THREAD_LOCK_CLASS lockClass(gameLock, "Game::autocleanMap()");
if (seconds == 0)
{
std::cout << ":: auto clean... ";
timer();
long count = cleanMap();
double sec = timer();

std::stringstream msg;
msg << "Clean completed. Collected " << count << (count==1? " item." : " items.") << std::ends;
for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it){
if(dynamic_cast<Player*>(it->second))
(*it).second->sendTextMessage(MSG_RED_INFO, msg.str().c_str());
}

std::cout << "ok (" << timer() << "s)" << std::endl;
addEvent(makeTask((g_config.getGlobalNumber("autoclean", 2))*60000, std::mem_fun(&Game::beforeClean)));
}
else
{
std::stringstream msg;
msg << "TIME " << seconds << std::ends;

AutoList<Player>::listiterator it = Player::listPlayer.list.begin();
while (it != Player::listPlayer.list.end())
{
(*it).second->sendTextMessage(MSG_RED_INFO, msg.str().c_str());
++it;
}

addEvent(makeTask(1000, boost::bind(&Game::autocleanMap, this, seconds - 1)));
}
}
#endif //_BBK_KIED_CLEAN__
In game.h below
long cleanMap();
Add:
#ifdef _BBK_KIED_CLEAN__
long beforeClean();
void secondsToClean();
void autocleanMap(int seconds);
#endif //_BBK_KIED_CLEAN__
In otserv.cpp below
#ifdef YUR_CVS_MODS
double t = timer();
std::cout << "Loaded in " << t << " s" << std::endl;
#endif
add:
#ifdef _BBK_KIED_CLEAN__
if (g_config.getGlobalNumber("autoclean") > 0)
g_game.addEvent(makeTask((g_config.getGlobalNumber("autoclean", 2))*60000, std::mem_fun(&Game::beforeClean)));
else
std::cout << ":: Auto clean Off" << std::endl;
#endif //_BBK_KIED_CLEAN__
Then add to the project:
-D_BBK_KIED_CLEAN__
Add to config.lua
-- Wazza AutoClean
-- (0 - off, 1 - one minute, 60 - one hour)
autoclean = 1
 
Back
Top