From 208d88c35850b52fee3a019495cab29749b9f6cd Mon Sep 17 00:00:00 2001 From: Zoey76 <zoey_76@msn.com> Date: Tue, 10 Jan 2012 07:14:22 +0000 Subject: [PATCH] BETA: Implementing Admin command sendhome: * The sendhome command can be used: 1. From Alt + G panel. 1. Entering the player's name: //sendhome Zoey76 1. On a target if it's a player. '''Note 1:''' This command send a player to it's race home town, '''not''' to the closest town. '''Note 2:''' Require [L5124]. --- .../admincommandhandlers/AdminTeleport.java | 71 ++++++++++++++++++- .../sql/game/admin_command_access_rights.sql | 1 + 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminTeleport.java b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminTeleport.java index e054e38448..9be417e207 100644 --- a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminTeleport.java +++ b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminTeleport.java @@ -27,6 +27,7 @@ import com.l2jserver.gameserver.ai.CtrlIntention; import com.l2jserver.gameserver.datatables.NpcTable; import com.l2jserver.gameserver.datatables.SpawnTable; import com.l2jserver.gameserver.handler.IAdminCommandHandler; +import com.l2jserver.gameserver.instancemanager.MapRegionManager; import com.l2jserver.gameserver.instancemanager.RaidBossSpawnManager; import com.l2jserver.gameserver.model.L2CharPosition; import com.l2jserver.gameserver.model.L2Object; @@ -78,7 +79,8 @@ public class AdminTeleport implements IAdminCommandHandler "admin_godown", "admin_tele", "admin_teleto", - "admin_instant_move" + "admin_instant_move", + "admin_sendhome" }; @Override @@ -242,7 +244,38 @@ public class AdminTeleport implements IAdminCommandHandler activeChar.sendMessage("Usage: //go<north|south|east|west|up|down> [offset] (default 150)"); } } - + else if (command.startsWith("admin_sendhome")) + { + StringTokenizer st = new StringTokenizer(command, " "); + st.nextToken(); // Skip command. + if (st.countTokens() > 1) + { + activeChar.sendMessage("Usage: //sendhome <playername>"); + } + else if (st.countTokens() == 1) + { + final String name = st.nextToken(); + final L2PcInstance player = L2World.getInstance().getPlayer(name); + if (player == null) + { + activeChar.sendPacket(SystemMessageId.TARGET_IS_NOT_FOUND_IN_THE_GAME); + return false; + } + teleportHome(player); + } + else + { + final L2Object target = activeChar.getTarget(); + if (target instanceof L2PcInstance) + { + teleportHome(target.getActingPlayer()); + } + else + { + activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET); + } + } + } return true; } @@ -252,6 +285,40 @@ public class AdminTeleport implements IAdminCommandHandler return ADMIN_COMMANDS; } + /** + * This method sends a player to it's home town. + * @param player the player to teleport. + */ + private void teleportHome(L2PcInstance player) + { + String regionName; + switch(player.getRace()) + { + case Elf: + regionName = "elf_town"; + break; + case DarkElf: + regionName = "darkelf_town"; + break; + case Orc: + regionName = "orc_town"; + break; + case Dwarf: + regionName = "dwarf_town"; + break; + case Kamael: + regionName = "kamael_town"; + break; + case Human: + default: + regionName = "talking_island_town"; + } + + player.teleToLocation(MapRegionManager.getInstance().getMapRegionByName(regionName).getSpawnLoc(), true); + player.setInstanceId(0); + player.setIsIn7sDungeon(false); + } + private void teleportTo(L2PcInstance activeChar, String Coords) { try diff --git a/L2J_DataPack_BETA/dist/sql/game/admin_command_access_rights.sql b/L2J_DataPack_BETA/dist/sql/game/admin_command_access_rights.sql index ee2859bde0..a98933511a 100644 --- a/L2J_DataPack_BETA/dist/sql/game/admin_command_access_rights.sql +++ b/L2J_DataPack_BETA/dist/sql/game/admin_command_access_rights.sql @@ -583,6 +583,7 @@ INSERT IGNORE INTO `admin_command_access_rights` VALUES ('admin_tele',1,'false'), ('admin_teleto',1,'false'), ('admin_instant_move',1,'false'), +('admin_sendhome',1,'true'), -- ADMIN TERRITORY WAR ('admin_territory_war',1,'false'), -- GitLab