int EventPerkMenuComponent::handleObjectMenuSelect(SceneObject* sceneObject, CreatureObject* player, byte selectedID) {
	EventPerkDataComponent* data = cast<EventPerkDataComponent*>(sceneObject->getDataObjectComponent()->get());

	if (data == NULL) {
		player->sendSystemMessage("Error: no dataObjectComponent.");
		return 1;
	}

	EventPerkDeed* deed = data->getDeed();

	if (deed == NULL) {
		player->sendSystemMessage("Error: deed is NULL.");
		return 1;
	}

	ManagedReference<CreatureObject*> owner = deed->getOwner().get();

	if (owner != player) {
		return TangibleObjectMenuComponent::handleObjectMenuSelect(sceneObject, player, selectedID);
	}

	if (selectedID == 132) {
		Time currentTime;
		uint32 timeDelta = currentTime.getMiliTime() - deed->getPurchaseTime()->getMiliTime();
		uint32 minutes = (EventPerkDeedTemplate::TIME_TO_LIVE - timeDelta) / 60000;

		StringIdChatParameter params("event_perk", "show_exp_time"); // This rental will expire in approximately %DI minutes.
		params.setDI(minutes);
		player->sendSystemMessage(params);
		return 0;
	} else if (selectedID == 128) {
		ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory");
		PlayerObject* ghost = player->getPlayerObject();

		if (inventory == NULL || inventory->isContainerFull()) {
			player->sendSystemMessage("@event_perk:redeed_failed"); // The rental could not be re-deeded.
			return 1;
		}

		if (ghost == NULL || ghost->getEventPerkCount() > 5) {
			player->sendSystemMessage("@event_perk:redeed_too_many_deeds"); // You have too many rental deeds in your possession and cannot redeed this rental.
			return 1;
		}

		deed->sendTo(player, true);
		inventory->transferObject(deed, -1, true);
		deed->setGenerated(false);
		sceneObject->destroyObjectFromWorld(true);

		player->sendSystemMessage("@event_perk:redeed_success"); // Your Rental has been removed and the deed reclaimed.
		return 0;
	}

	return TangibleObjectMenuComponent::handleObjectMenuSelect(sceneObject, player, selectedID);
}
int ScavengerDroidImplementation::handleObjectMenuSelect(CreatureObject* player, byte selectedID) {
	ManagedReference<CreatureObject*> perkOwner = getDeedOwner();

	bool isOwner = perkOwner != NULL && player == perkOwner;


	if (gameStatus == GAMESETUP && isOwner) {
		if (selectedID == 132) {
			sendSetupInstructionsSUI(player);
		} else if (selectedID == 133) {
			sendItemListSUI(player);
		} else if (selectedID == 134) {
			player->sendSystemMessage("@event_perk:scavenger_list_reset_msg");
			clearItemList();
		} else if (selectedID == 135) {
			startGame(player);
		}
	} else if (gameStatus == GAMESTARTED) {
		if (selectedID == 132) {
			sendGameInstructionsSUI(player);
		} else if (selectedID == 133) {
			sendItemListSUI(player);
		} else if (selectedID == 136) {
			StringIdChatParameter msg("event_perk", "scavenger_show_current_leader");

			ManagedReference<CreatureObject*> curWinner = currentWinner.get();

			if (curWinner == NULL)
				msg.setTO("Nobody");
			else
				msg.setTO(curWinner->getDisplayedName());
			player->sendSystemMessage(msg);
		}
	} else if (gameStatus == GAMEENDED) {
		if (selectedID == 136) {
			StringIdChatParameter msg("event_perk", "scavenger_show_leader");

			ManagedReference<CreatureObject*> curWinner = currentWinner.get();

			int timeMins = (gameEndTime.getMiliTime() - gameStartTime.getMiliTime()) / 60000;

			if (curWinner != NULL)
				msg.setTO(curWinner->getDisplayedName());
			else
				msg.setTO("Unknown");

			msg.setDI(timeMins);
			player->sendSystemMessage(msg);
		}
	}

	if (selectedID == 137 && (isOwner || (player->getPlayerObject() != NULL && player->getPlayerObject()->isPrivileged()))) {
		EventPerkDataComponent* data = cast<EventPerkDataComponent*>(getDataObjectComponent()->get());

		if (data == NULL) {
			player->sendSystemMessage("Error: no dataObjectComponent.");
			return 1;
		}

		EventPerkDeed* deed = data->getDeed();

		if (deed == NULL) {
			player->sendSystemMessage("Error: deed is NULL.");
			return 1;
		}

		Time currentTime;
		uint32 timeDelta = currentTime.getMiliTime() - deed->getPurchaseTime()->getMiliTime();
		uint32 minutes = (EventPerkDeedTemplate::TIME_TO_LIVE - timeDelta) / 60000;

		StringIdChatParameter params("event_perk", "show_exp_time"); // This rental will expire in approximately %DI minutes.
		params.setDI(minutes);
		player->sendSystemMessage(params);
		return 0;
	}

	return 0;
}