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

Online List

Raotiz

High Five
Joined
Apr 11, 2010
Messages
693
Reaction score
49
Location
Sweden
Is it necessary to edit the sources to get online-list working?
I've added
Code:
  `online` int(1) NOT NULL default '0',
  KEY `online` (`online`)
1 means Iam online, 0 means offline
When Iam online it is still 0 when it should be 1, 1 = than it shows in online list
 
That wont do anything. There should be a table or a column already for keeping track on whether a player is online or not.
 
Add in sources in ioplayer.cpp at the end add this
Code:
void IOPlayer::updatePlayerStatus(Player* player)
{
	Database* db = Database::instance();
	DBQuery query;

	query << "UPDATE `players` SET `online` = " << player->getStatus() << " WHERE `id` = " << player->getGUID();
	db->executeQuery(query.str());
}

search for this
Code:
bool Game::placeCreature(Creature* creature, const Position& pos, bool extendedPos /*=false*/, bool forced /*= false*/)

and replace it by
Code:
bool Game::placeCreature(Creature* creature, const Position& pos, bool extendedPos /*=false*/, bool forced /*= false*/)
{
	if(!internalPlaceCreature(creature, pos, extendedPos, forced)){
		return false;
	}

	SpectatorVec list;
	SpectatorVec::iterator it;
	getSpectators(list, creature->getPosition(), false, true);

	//send to client
	Player* tmpPlayer = NULL;
	for(it = list.begin(); it != list.end(); ++it) {
		if((tmpPlayer = (*it)->getPlayer())){
			tmpPlayer->sendCreatureAppear(creature, true);
		}
	}

	//event method
	for(it = list.begin(); it != list.end(); ++it) {
		(*it)->onCreatureAppear(creature, true);
	}

	int32_t newStackPos = creature->getParent()->__getIndexOfThing(creature);
	creature->getParent()->postAddNotification(creature, newStackPos);

	addCreatureCheck(creature);
	checkPlayersRecord();
	
	Player* player = creature->getPlayer();
	if (player) {
	player->setStatus(PLAYERSTATUS_ONLINE);
	IOPlayer::instance()->updatePlayerStatus(player);
	}

	creature->onPlacedCreature();
	return true;
}

search for
Code:
bool Game::removeCreature(Creature* creature, bool isLogout /*= true*/)

and replace it by this
Code:
bool Game::removeCreature(Creature* creature, bool isLogout /*= true*/)
{
	if(creature->isRemoved())
		return false;

#ifdef __DEBUG__
	std::cout << "removing creature "<< std::endl;
#endif

	//std::cout << "remove: " << creature << " " << creature->getID() << std::endl;

	Cylinder* cylinder = creature->getTile();

	SpectatorVec list;
	SpectatorVec::iterator it;
	getSpectators(list, cylinder->getPosition(), false, true);

	int32_t index = cylinder->__getIndexOfThing(creature);
	if(!map->removeCreature(creature)){
		return false;
	}

	//send to client
	Player* player = NULL;
	for(it = list.begin(); it != list.end(); ++it){
		if((player = (*it)->getPlayer())){
			player->sendCreatureDisappear(creature, index, isLogout);
		}
	}

	//event method
	for(it = list.begin(); it != list.end(); ++it){
		(*it)->onCreatureDisappear(creature, index, isLogout);
	}

	creature->getParent()->postRemoveNotification(creature, index, true);

	listCreature.removeList(creature->getID());
	creature->removeList();
	creature->setRemoved();
	FreeThing(creature);

	removeCreatureCheck(creature);

	for(std::list<Creature*>::iterator cit = creature->summons.begin(); cit != creature->summons.end(); ++cit){
		(*cit)->setLossSkill(false);
		removeCreature(*cit);
	}
	
	player = creature->getPlayer();
	if (player) {
		player->setStatus(PLAYERSTATUS_OFFLINE);
		IOPlayer::instance()->updatePlayerStatus(player);
	}

and in
Code:
bool getGuidByName(uint32_t& guid, std::string& name);

add
Code:
void updatePlayerStatus(Player* player);

then compile all then it should work;)
 
oh raotiz really sorry i made a mistake xD my bad bro search this
Code:
enum playerinfo_t {
	PLAYERINFO_LEVEL,
	PLAYERINFO_LEVELPERCENT,
	PLAYERINFO_HEALTH,
	PLAYERINFO_MAXHEALTH,
	PLAYERINFO_MANA,
	PLAYERINFO_MAXMANA,
	PLAYERINFO_MAGICLEVEL,
	PLAYERINFO_MAGICLEVELPERCENT,
	PLAYERINFO_SOUL,
};

and under that add this.

Code:
enum playerstatus_t {
	PLAYERSTATUS_OFFLINE = 0,
	PLAYERSTATUS_ONLINE = 1
};

search for this
Code:
void stopWalk();

under that add
Code:
	playerstatus_t getStatus() const { return status; }
	void setStatus(playerstatus_t _status) { status = _status; }

that should work
 
Last edited by a moderator:
Back
Top