mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-09 06:35:42 +12:00
add %JUMP and make %GIVE work for other users
This commit is contained in:
parent
d74c9ca816
commit
bb458bfd7c
2 changed files with 89 additions and 35 deletions
|
@ -59,6 +59,8 @@ namespace HISP.Game.Chat
|
||||||
return Command.Give(message, args, user);
|
return Command.Give(message, args, user);
|
||||||
if (message.ToUpper().StartsWith("%GOTO"))
|
if (message.ToUpper().StartsWith("%GOTO"))
|
||||||
return Command.Goto(message, args, user);
|
return Command.Goto(message, args, user);
|
||||||
|
if (message.ToUpper().StartsWith("%JUMP"))
|
||||||
|
return Command.Jump(message, args, user);
|
||||||
if (message.ToUpper().StartsWith("%KICK"))
|
if (message.ToUpper().StartsWith("%KICK"))
|
||||||
return Command.Kick(message, args, user);
|
return Command.Kick(message, args, user);
|
||||||
if (message.ToUpper().StartsWith("%RULES"))
|
if (message.ToUpper().StartsWith("%RULES"))
|
||||||
|
|
|
@ -11,6 +11,23 @@ namespace HISP.Game.Chat
|
||||||
public class Command
|
public class Command
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private static User findNamePartial(string name)
|
||||||
|
{
|
||||||
|
foreach (GameClient client in GameServer.ConnectedClients)
|
||||||
|
{
|
||||||
|
if (client == null)
|
||||||
|
continue;
|
||||||
|
if (client.LoggedIn)
|
||||||
|
{
|
||||||
|
if (client.LoggedinUser.Username.ToLower().Contains(name))
|
||||||
|
{
|
||||||
|
return client.LoggedinUser;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new KeyNotFoundException("name not found");
|
||||||
|
}
|
||||||
|
|
||||||
public static bool Give(string message, string[] args, User user)
|
public static bool Give(string message, string[] args, User user)
|
||||||
{
|
{
|
||||||
if (args.Length <= 0)
|
if (args.Length <= 0)
|
||||||
|
@ -25,8 +42,17 @@ namespace HISP.Game.Chat
|
||||||
itemId = int.Parse(args[1]);
|
itemId = int.Parse(args[1]);
|
||||||
Item.GetItemById(itemId);
|
Item.GetItemById(itemId);
|
||||||
ItemInstance newItemInstance = new ItemInstance(itemId);
|
ItemInstance newItemInstance = new ItemInstance(itemId);
|
||||||
user.Inventory.AddIgnoringFull(newItemInstance);
|
|
||||||
|
if(args.Length >= 3)
|
||||||
|
{
|
||||||
|
findNamePartial(args[2]).Inventory.AddIgnoringFull(newItemInstance);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
user.Inventory.AddIgnoringFull(newItemInstance);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(Exception)
|
catch(Exception)
|
||||||
{
|
{
|
||||||
|
@ -39,7 +65,16 @@ namespace HISP.Game.Chat
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
money = int.Parse(args[1]);
|
money = int.Parse(args[1]);
|
||||||
user.AddMoney(money);
|
if (args.Length >= 3)
|
||||||
|
{
|
||||||
|
findNamePartial(args[2]).AddMoney(money);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
user.AddMoney(money);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
@ -54,7 +89,7 @@ namespace HISP.Game.Chat
|
||||||
questId = int.Parse(args[1]);
|
questId = int.Parse(args[1]);
|
||||||
if(args.Length >= 3)
|
if(args.Length >= 3)
|
||||||
{
|
{
|
||||||
if (args[0].ToUpper() == "FORCE")
|
if (args[2].ToUpper() == "FORCE")
|
||||||
{
|
{
|
||||||
Quest.CompleteQuest(user, Quest.GetQuestById(questId));
|
Quest.CompleteQuest(user, Quest.GetQuestById(questId));
|
||||||
goto msg;
|
goto msg;
|
||||||
|
@ -222,6 +257,36 @@ namespace HISP.Game.Chat
|
||||||
user.LoggedinClient.SendPacket(chatPacket);
|
user.LoggedinClient.SendPacket(chatPacket);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool Jump(string message, string[] args, User user)
|
||||||
|
{
|
||||||
|
if (args.Length <= 0)
|
||||||
|
return false;
|
||||||
|
if (!user.Administrator)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(args.Length < 2)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
User tp = findNamePartial(args[0]);
|
||||||
|
if (args[1].ToUpper() == "HERE")
|
||||||
|
tp.Teleport(user.X, user.Y);
|
||||||
|
}
|
||||||
|
catch (KeyNotFoundException)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
|
||||||
|
user.LoggedinClient.SendPacket(chatPacket);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static bool Goto(string message, string[] args, User user)
|
public static bool Goto(string message, string[] args, User user)
|
||||||
{
|
{
|
||||||
if (args.Length <= 0)
|
if (args.Length <= 0)
|
||||||
|
@ -234,20 +299,8 @@ namespace HISP.Game.Chat
|
||||||
return false;
|
return false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
User tpTo = findNamePartial(args[1]);
|
||||||
{
|
user.Teleport(tpTo.X, tpTo.Y);
|
||||||
if (client == null)
|
|
||||||
return false;
|
|
||||||
if (client.LoggedIn)
|
|
||||||
{
|
|
||||||
if (client.LoggedinUser.Username.ToLower().Contains(args[1]))
|
|
||||||
{
|
|
||||||
user.Teleport(client.LoggedinUser.X, client.LoggedinUser.Y);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (KeyNotFoundException)
|
catch (KeyNotFoundException)
|
||||||
{
|
{
|
||||||
|
@ -365,31 +418,30 @@ namespace HISP.Game.Chat
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string areaName = string.Join(" ", args).ToLower();
|
string areaName = string.Join(" ", args).ToLower();
|
||||||
|
try
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
User tp = findNamePartial(areaName);
|
||||||
|
|
||||||
|
user.Teleport(tp.X, tp.Y);
|
||||||
|
formattedmessage += Messages.SuccessfullyWarpedToPlayer;
|
||||||
|
goto playSwf;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (KeyNotFoundException)
|
||||||
|
{
|
||||||
|
foreach (World.Waypoint waypoint in World.Waypoints)
|
||||||
{
|
{
|
||||||
if(client.LoggedinUser.Username.ToLower().Contains(areaName))
|
if (waypoint.Name.ToLower().Contains(areaName))
|
||||||
{
|
{
|
||||||
user.Teleport(client.LoggedinUser.X, client.LoggedinUser.Y);
|
user.Teleport(waypoint.PosX, waypoint.PosY);
|
||||||
formattedmessage += Messages.SuccessfullyWarpedToPlayer;
|
formattedmessage += Messages.SuccessfullyWarpedToLocation;
|
||||||
goto playSwf;
|
goto playSwf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
foreach(World.Waypoint waypoint in World.Waypoints)
|
goto cantUnderstandCommand;
|
||||||
{
|
|
||||||
if(waypoint.Name.ToLower().Contains(areaName))
|
|
||||||
{
|
|
||||||
user.Teleport(waypoint.PosX, waypoint.PosY);
|
|
||||||
formattedmessage += Messages.SuccessfullyWarpedToLocation;
|
|
||||||
goto playSwf;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
goto cantUnderstandCommand;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
playSwf:;
|
playSwf:;
|
||||||
|
|
Loading…
Add table
Reference in a new issue