ond
Veteran OT User
In ioplayer.cpp:
After this function
Code:void IOPlayer::loadItems(ItemMap& itemMap, DBResult* result)
Add this:
Code:void IOPlayer::updateLoginInfo(Player* player) { Database* db = Database::instance(); DBQuery query; query << "UPDATE `players` SET `status` = 1" << " WHERE `id` = " << player->getGUID(); db->executeQuery(query.str()); } void IOPlayer::updateLogoutInfo(Player* player) { Database* db = Database::instance(); DBQuery query; query << "UPDATE `players` SET `status` = 0" << " WHERE `id` = " << player->getGUID(); db->executeQuery(query.str()); } bool IOPlayer::cleanOnlineInfo() { Database* db = Database::instance(); DBQuery query; return db->executeQuery("UPDATE `players` SET `status` = 0"); }
In ioplayer.h
After this:
Code:uint32_t getAccessByName(std::string name);
Add this:
Code:void updateLoginInfo(Player* player); void updateLogoutInfo(Player* player); bool cleanOnlineInfo();
------------------------------------------------------------------
Now in protocolgame.cpp
In function:
Code:bool ProtocolGame::login(const std::string& name)
After this:
Code:player->lastLoginSaved = std::max(time(NULL), player->lastLoginSaved + 1);
Add this:
Code:IOPlayer::instance()->updateLoginInfo(player);
Now in function
Code:bool ProtocolGame::connect(uint32_t playerId)
After this:
Code:player->lastip = player->getIP();
Add this:
Code:IOPlayer::instance()->updateLoginInfo(player);
------------------------------------------------------------------
Now in player.cpp
In function void Player:nCreatureDisappear(const Creature* creature, uint32_t stackpos, bool isLogout)
After this:
Code:g_chat.removeUserFromAllChannels(this);
Add this:
Code:IOPlayer::instance()->updateLogoutInfo(this);
------------------------------------------------------------------
Now in otserv.cpp
After this:
Code:#include "status.h"
Add this:
Code:#include "ioplayer.h"
Now search for that line:
Code:std::cout << ":: Worldtype: " << asUpperCaseString(worldType) << std::endl;
And after that line, add this:
Code:std::cout << ":: Cleaning online players info... " << std::flush; if(!IOPlayer::instance()->cleanOnlineInfo()){ std::stringstream errormsg; errormsg << "Unable to execute query for cleaning online status!"; ErrorMessage(errormsg.str().c_str()); exit(-1); } std::cout << "[done]" << std::endl;
/\
/\
/\
This will set all players status to 0 = player offline in website
Hope you enjoyed!
- - - Updated - - -
But if you want it in LUA, you'll need that function:
http://otland.net/f35/mysqlquery-otserv-57412/
In login.lua, add this:
Lua:mysqlQuery("UPDATE `players` SET `status` = '1' WHERE `name` = \"" .. getPlayerName(cid) .. "\"", "SET")
In logout.lua or die.lua
Lua:mysqlQuery("UPDATE `players` SET `status` = '0' WHERE `name` = \"" .. getPlayerName(cid) .. "\"", "SET")
That is a lot of editing for such small matter