public override void onPlayerTileChange(PlayerTileChangeEvent Event)
{
Player player = Server.GetPlayerByName(Event.Sender.Name);
bool starthouse = player.PluginData.ContainsKey("starthouse") ? (bool)player.PluginData["starthouse"] : false;
bool endhouse = player.PluginData.ContainsKey("endhouse") ? (bool)player.PluginData["endhouse"] : false;
bool check = player.PluginData.ContainsKey("check") ? (bool)player.PluginData["check"] : false;
bool teleportSet = player.PluginData.ContainsKey("teleportset") ? (bool)player.PluginData["teleportset"] : false;
int houseIndex = player.PluginData.ContainsKey("houseIndex") ? (int)player.PluginData["houseIndex"] : -1;
string houseName = player.PluginData.ContainsKey("houseName") ? (string)player.PluginData["houseName"] : null;
if (starthouse || endhouse)
{
String NodeName = starthouse ? "topleft" : "bottomright";
String cornerDesc = starthouse ? "top-left" : "bottom-right";
Event.Cancelled = true;
if (GetHouseNameImInside(player) == null)
{
UpdateCoordsForPlayer(player.Name, (int)Event.Position.X, (int)Event.Position.Y, houseIndex);
player.sendMessage("You've set the " + cornerDesc + " corner of house " + houseName, chatColor);
player.PluginData["starthouse"] = false;
player.PluginData["endhouse"] = false;
}
else
{
player.sendMessage("You're inside another house, you cannot set your " + cornerDesc + " here");
}
}
else if (IsInsideAnotherHouse(player.Name, (int)Event.Position.X, (int)Event.Position.Y) && ! starthouse && ! endhouse &&
!player.Op)
{
Event.Cancelled = true;
player.sendMessage("You're trying to build inside someone's house--this is not allowed", chatColor);
}
else if (check)
{
Event.Cancelled = true;
player.PluginData["check"] = false;
player.sendMessage("The block you just clicked on is at " + (int)Event.Position.X + "," + (int)Event.Position.Y, chatColor);
}
else if (teleportSet)
{
if (GetMyHouseNamePositionInside(player.Name, (int)Event.Position.X, (int)Event.Position.Y) == (string)player.PluginData["teleporthouse"])
{
int playerIndex = GetPlayerHouseIndex(player.Name);
houseIndex = GetHouseCoordsIndexByName(player.Name, (string)player.PluginData["teleporthouse"]);
PlayerHouseCoords tempCoords = playerHouses[playerIndex].Houses[houseIndex];
tempCoords.TeleportPoint.X = (int)Event.Position.X;
tempCoords.TeleportPoint.Y = (int)Event.Position.Y;
playerHouses[playerIndex].Houses[houseIndex] = tempCoords;
player.sendMessage("Teleport point set for house " + (string)player.PluginData["teleporthouse"], chatColor);
}
else
player.sendMessage("That block is not inside your house called " + (string)player.PluginData["teleporthouse"], chatColor);
player.PluginData["teleportset"] = false;
}
base.onPlayerTileChange(Event);
}