Add new commands

This commit is contained in:
SilicaAndPina 2021-06-28 17:49:31 +12:00
parent 13de417f2d
commit d74c9ca816
3 changed files with 42 additions and 3 deletions

View file

@ -65,6 +65,8 @@ namespace HISP.Game.Chat
return Command.Rules(message, args, user);
if (message.ToUpper().StartsWith("%NOCLIP"))
return Command.NoClip(message, args, user);
if (message.ToUpper().StartsWith("%STEALTH"))
return Command.Stealth(message, args, user);
if (message.ToUpper().StartsWith("%BAN"))
return Command.Ban(message, args, user);
if (message.ToUpper().StartsWith("%UNBAN"))
@ -488,7 +490,7 @@ namespace HISP.Game.Chat
int numbListening = GameServer.GetNumberOfPlayersListeningToAdsChat(); // vry specific function ik
return Messages.FormatAdsChatForSender(numbListening-1, user.Username, message);
case ChatChannel.Buddies:
return Messages.FormatBuddyChatMessageForSender(user.Friends.Count, user.Username, message);
return Messages.FormatBuddyChatMessageForSender(GameServer.GetNumberOfBuddiesOnline(user), user.Username, message);
case ChatChannel.Isle:
int inIsle = 0;
if (World.InIsle(user.X, user.Y))

View file

@ -148,6 +148,16 @@ namespace HISP.Game.Chat
return true;
}
public static bool Stealth(string message, string[] args, User user)
{
if (!user.Administrator || !user.Moderator)
return false;
user.Stealth = !user.Stealth;
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
user.LoggedinClient.SendPacket(chatPacket);
return true;
}
public static bool NoClip(string message, string[] args, User user)
{
if (!user.Administrator)
@ -224,8 +234,20 @@ namespace HISP.Game.Chat
return false;
try
{
User teleportTo = GameServer.GetUserByName(args[1]);
user.Teleport(teleportTo.X, teleportTo.Y);
foreach (GameClient client in GameServer.ConnectedClients)
{
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)
{
@ -343,6 +365,7 @@ namespace HISP.Game.Chat
else
{
string areaName = string.Join(" ", args).ToLower();
foreach (GameClient client in GameServer.ConnectedClients)
{
if (client.LoggedIn)

View file

@ -7430,6 +7430,20 @@ namespace HISP.Server
}
return count;
}
public static int GetNumberOfBuddiesOnline(User user)
{
int total = 0;
foreach(int bud in user.Friends.List.ToArray())
{
if (IsUserOnline(bud))
{
total++;
}
}
return total;
}
public static int GetNumberOfAdminsOnline()
{
int count = 0;