Skip to content
Snippets Groups Projects
Commit 208d88c3 authored by Zoey76's avatar Zoey76
Browse files

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].
parent 6c9502d7
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment