I've decided to add these 2 commands to RunUO, and figured I'd share them with everyone else, in case they found them useful. While the Admin gump is nice, sometimes I know exactly who I need to get/goto, and that's why I added this. To use these commands, you would type "[GetPlayer PlayerName" or "[GotoPlayer PlayerName".
To enable these commands, you need to edit "\Scripts\Commands\Handlers.cs". In the static Initialize() method, add in these 2 Register lines:
Then, outside of that method, add the following code:
...and there you go, compile and then you are all done!
To enable these commands, you need to edit "\Scripts\Commands\Handlers.cs". In the static Initialize() method, add in these 2 Register lines:
Code:
Register("GetPlayer", AccessLevel.GameMaster, new CommandEventHandler(GetPlayer_OnCommand));
Register("GotoPlayer", AccessLevel.GameMaster, new CommandEventHandler(GotoPlayer_OnCommand));
Then, outside of that method, add the following code:
Code:
[Usage("GetPlayer PlayerName")]
[Description("Gets a player based on player name.")]
public static void GetPlayer_OnCommand(CommandEventArgs e)
{
var player = GetPlayer(e.ArgString);
if (player == null) return;
player.MoveToWorld(e.Mobile.Location, e.Mobile.Map);
}
[Usage("GotoPlayer PlayerName")]
[Description("Goes to a player based on player name.")]
public static void GotoPlayer_OnCommand(CommandEventArgs e)
{
var player = GetPlayer(e.ArgString);
if (player == null) return;
var map = player.Map;
var location = player.Location;
if (map == null || map == Map.Internal)
{
map = player.LogoutMap;
location = player.LogoutLocation;
}
if (map != null && map != Map.Internal)
{
e.Mobile.MoveToWorld(location, map);
}
}
private static Mobile GetPlayer(string playerName)
{
Mobile retVal = null;
foreach (var account in Accounts.GetAccounts())
{
var accountObject = account as Account;
if (accountObject == null) continue;
for (var index = 0; index < accountObject.Length; index++)
{
var mobile = accountObject[index];
if (mobile == null) continue;
if (String.Compare(mobile.RawName, playerName, StringComparison.CurrentCultureIgnoreCase) != 0)
continue;
retVal = mobile;
break;
}
if (retVal != null) break;
}
return retVal;
}
...and there you go, compile and then you are all done!