Пример #1
0
void Commands::getInfo(Player* player, const std::string& cmd, const std::string& param)
{
	Player* paramPlayer = g_game.getPlayerByName(param);

	if (!paramPlayer) {
		player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Player not found.");
		return;
	}

	if (player->getAccountType() < paramPlayer->getAccountType()) {
		player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "You can not get info about this player.");
		return;
	}

	uint32_t playerIp = paramPlayer->getIP();

	std::ostringstream info;
	info << "Name: " << paramPlayer->name << std::endl <<
	     "Access: " << paramPlayer->group->access << std::endl <<
	     "Level: " << paramPlayer->level << std::endl <<
	     "Magic Level: " << paramPlayer->magLevel << std::endl <<
	     "Speed: " << paramPlayer->getSpeed() << std::endl <<
	     "Position: " << paramPlayer->getPosition() << std::endl <<
	     "IP: " << convertIPToString(playerIp) << std::endl;
	player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, info.str());

	if (playerIp != 0) {
		PlayerVector vec;

		for (const auto& it : g_game.getPlayers()) {
			if (it.second->getIP() != playerIp || it.second == paramPlayer) {
				continue;
			}

			vec.push_back(it.second);
		}

		if (!vec.empty()) {
			std::ostringstream ss;

			Player* tmpPlayer = vec[0];
			ss << "Other players on same IP: " << tmpPlayer->getName() << " [" << tmpPlayer->getLevel() << "]";

			for (PlayerVector::size_type i = 1, size = vec.size(); i < size; ++i) {
				tmpPlayer = vec[i];
				ss << ", " << tmpPlayer->getName() << " [" << tmpPlayer->getLevel() << "]";
			}

			ss << ".";
			player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, ss.str());
		}
	}
}
Пример #2
0
void House::removePlayers(bool ignoreInvites)
{
	PlayerVector kickList;
	for(HouseTileList::iterator it = houseTiles.begin(); it != houseTiles.end(); ++it)
	{
		CreatureVector* creatures = (*it)->getCreatures();
		if(!creatures)
			continue;

		Player* player = nullptr;
		for(CreatureVector::iterator cit = creatures->begin(); cit != creatures->end(); ++cit)
		{
			if((player = (*cit)->getPlayer()) && !player->isRemoved()
				&& (ignoreInvites || !isInvited(player)))
				kickList.push_back(player);
		}
	}

	if(kickList.empty())
		return;

	for(PlayerVector::iterator it = kickList.begin(); it != kickList.end(); ++it)
		removePlayer((*it), false);
}
Пример #3
0
void House::setHouseOwner(uint32_t guid, bool updateDatabase/* = true*/, Player* player/* = NULL*/)
{
	if (updateDatabase) {
		Database* db = Database::getInstance();

		std::ostringstream query;
		query << "UPDATE `houses` SET `owner` = " << guid << " WHERE `id` = " << houseid;
		db->executeQuery(query.str());
	}

	if (isLoaded && houseOwner == guid) {
		return;
	}

	isLoaded = true;

	if (houseOwner) {
		//send items to depot
		if (player) {
			transferToDepot(player);
		} else {
			transferToDepot();
		}

		PlayerVector toKick;

		for (HouseTileList::iterator it = houseTiles.begin(); it != houseTiles.end(); ++it) {
			if (const CreatureVector* creatures = (*it)->getCreatures()) {
				for (CreatureVector::const_iterator cit = creatures->begin(), cend = creatures->end(); cit != cend; ++cit) {
					Player* player = (*cit)->getPlayer();

					if (player) {
						toKick.push_back(player);
					}
				}
			}
		}

		while (!toKick.empty()) {
			Player* c = toKick.back();
			toKick.pop_back();
			kickPlayer(NULL, c->getName());
		}

		// we need to remove players from beds
		HouseBedItemList::iterator bit;

		for (bit = bedsList.begin(); bit != bedsList.end(); ++bit) {
			if ((*bit)->getSleeper() != 0) {
				(*bit)->wakeUp(NULL);
			}
		}

		//clean access lists
		houseOwner = 0;
		setAccessList(SUBOWNER_LIST, "");
		setAccessList(GUEST_LIST, "");

		for (HouseDoorList::iterator it = doorList.begin(); it != doorList.end(); ++it) {
			(*it)->setAccessList("");
		}

		//reset paid date
		paidUntil = 0;
		rentWarnings = 0;
	}

	std::string name;

	if (guid != 0 && IOLoginData::getInstance()->getNameByGuid(guid, name)) {
		houseOwner = guid;
		houseOwnerName = name;
	}

	updateDoorDescription();
}