mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-06 21:25:42 +12:00
Add command support.
This commit is contained in:
parent
da205c3cd3
commit
b6dd899372
7 changed files with 129 additions and 18 deletions
|
@ -53,8 +53,9 @@
|
|||
"for_others":"<B>TAG!!</B> %USERNAME% is now it! (tagged by %TAGGER%)"
|
||||
},
|
||||
"commands":{
|
||||
"mute_help":"<FONT COLOR='#FF0000'><B>PLAYER COMMAND [%COMMAND%] COMPLETED</B></FONT> Mute Channel Not Recognized. (ALL/ADS/GLOBAL/ISLAND/NEAR/HERE/BUDDY/PM/BR/SOCIALS/LOGINS)",
|
||||
"command_completed":"<FONT COLOR='#FF0000'><B>PLAYER COMMAND [%COMMAND%] COMPLETED</B></FONT>"
|
||||
"mute_help":"Mute Channel Not Recognized. (ALL/ADS/GLOBAL/ISLAND/NEAR/HERE/BUDDY/PM/BR/SOCIALS/LOGINS)",
|
||||
"player_command_completed":"<FONT COLOR='#FF0000'><B>PLAYER COMMAND [%COMMAND%] COMPLETED</B></FONT>",
|
||||
"admin_command_completed":"<FONT COLOR='#FF0000'><B>COMMAND [%COMMAND%]:</B></FONT>"
|
||||
},
|
||||
"disconnect":{
|
||||
"banned":"Your account has been BANNED. You will no longer be able to login",
|
||||
|
|
|
@ -53,13 +53,43 @@ namespace HISP.Game.Chat
|
|||
|
||||
if (user.Administrator || user.Moderator)
|
||||
if (message[0] == '%')
|
||||
{
|
||||
if(message.StartsWith("%STICKBUG"))
|
||||
{
|
||||
return Command.Stickbug(message, args, user);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (message[0] == '!')
|
||||
{
|
||||
if (message.StartsWith("!MUTE"))
|
||||
{
|
||||
// Alias for !MUTE
|
||||
if (message.StartsWith("!MUTEALL"))
|
||||
return Command.Mute(message, new string[] { "ALL" }, user);
|
||||
else if (message.StartsWith("!MUTEADS"))
|
||||
return Command.Mute(message, new string[] { "ADS" }, user);
|
||||
else if (message.StartsWith("!MUTEGLOBAL"))
|
||||
return Command.Mute(message, new string[] { "GLOBAL" }, user);
|
||||
else if (message.StartsWith("!MUTEISLAND"))
|
||||
return Command.Mute(message, new string[] { "ISLAND" }, user);
|
||||
else if (message.StartsWith("!MUTENEAR"))
|
||||
return Command.Mute(message, new string[] { "NEAR" }, user);
|
||||
else if (message.StartsWith("!MUTEHERE"))
|
||||
return Command.Mute(message, new string[] { "HERE" }, user);
|
||||
else if (message.StartsWith("!MUTEBUDDY"))
|
||||
return Command.Mute(message, new string[] { "BUDDY" }, user);
|
||||
else if (message.StartsWith("!MUTEPM"))
|
||||
return Command.Mute(message, new string[] { "PM" }, user);
|
||||
else if (message.StartsWith("!MUTEPM"))
|
||||
return Command.Mute(message, new string[] { "PM" }, user);
|
||||
else if (message.StartsWith("!MUTEBR"))
|
||||
return Command.Mute(message, new string[] { "BR" }, user);
|
||||
else if (message.StartsWith("!MUTESOCIALS"))
|
||||
return Command.Mute(message, new string[] { "SOCIALS" }, user);
|
||||
else if (message.StartsWith("!MUTELOGINS"))
|
||||
return Command.Mute(message, new string[] { "LOGINS" }, user);
|
||||
|
||||
else if (message.StartsWith("!MUTE"))
|
||||
return Command.Mute(message, args, user);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,18 +1,60 @@
|
|||
using HISP.Player;
|
||||
using HISP.Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HISP.Game.Chat
|
||||
{
|
||||
class Command
|
||||
{
|
||||
|
||||
public static bool Stickbug(string message, string[] args, User user)
|
||||
{
|
||||
if (args.Length <= 0)
|
||||
return false;
|
||||
if (!user.Administrator)
|
||||
return false;
|
||||
|
||||
if(args[0] == "ALL")
|
||||
{
|
||||
foreach(GameClient client in GameServer.ConnectedClients)
|
||||
{
|
||||
if(client.LoggedIn)
|
||||
{
|
||||
byte[] swfModulePacket = PacketBuilder.CreateSwfModulePacket("fun/stickbug.swf", PacketBuilder.PACKET_SWF_MODULE_GENTLE);
|
||||
client.SendPacket(swfModulePacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
User victimUser = GameServer.GetUserByName(args[0]);
|
||||
byte[] swfModulePacket = PacketBuilder.CreateSwfModulePacket("fun/stickbug.swf", PacketBuilder.PACKET_SWF_MODULE_GENTLE);
|
||||
victimUser.LoggedinClient.SendPacket(swfModulePacket);
|
||||
}
|
||||
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 Mute(string message, string[] args, User user)
|
||||
{
|
||||
string mesasge = Messages.FormatPlayerCommandCompleteMessage(message.Substring(1));
|
||||
|
||||
if (args.Length <= 0)
|
||||
{
|
||||
message += Messages.MuteHelp;
|
||||
goto leave;
|
||||
}
|
||||
|
||||
string muteType = args[0];
|
||||
|
||||
if (muteType == "GLOBAL")
|
||||
|
@ -33,19 +75,33 @@ namespace HISP.Game.Chat
|
|||
} else if (muteType == "SOCIALS")
|
||||
{
|
||||
user.MuteSocials = true;
|
||||
} else if (muteType == "ALL")
|
||||
}
|
||||
else if (muteType == "PM")
|
||||
{
|
||||
user.MutePrivateMessage = true;
|
||||
}
|
||||
else if (muteType == "BR")
|
||||
{
|
||||
user.MuteBuddyRequests = true;
|
||||
}
|
||||
else if (muteType == "LOGINS")
|
||||
{
|
||||
user.MuteLogins = true;
|
||||
}
|
||||
else if (muteType == "ALL")
|
||||
{
|
||||
user.MuteAll = true;
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
message += Messages.MuteHelp;
|
||||
goto leave;
|
||||
}
|
||||
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatCommandComplete(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
|
||||
|
||||
leave:;
|
||||
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(message, PacketBuilder.CHAT_BOTTOM_LEFT);
|
||||
user.LoggedinClient.SendPacket(chatPacket);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,9 @@ namespace HISP.Game
|
|||
public static string ModChatFormat;
|
||||
public static string AdminChatFormat;
|
||||
|
||||
public static string CommandFormat;
|
||||
public static string AdminCommandFormat;
|
||||
public static string PlayerCommandFormat;
|
||||
public static string MuteHelp;
|
||||
|
||||
public static string GlobalChatFormatForModerators;
|
||||
public static string DirectChatFormatForModerators;
|
||||
|
@ -261,9 +263,14 @@ namespace HISP.Game
|
|||
{
|
||||
return StatsCompetitionGearFormat.Replace("%GEARFORMAT%", competitonGearFormat);
|
||||
}
|
||||
public static string FormatCommandComplete(string command)
|
||||
public static string FormatAdminCommandCompleteMessage(string command)
|
||||
{
|
||||
return CommandFormat.Replace("%COMMAND%", command);
|
||||
return AdminCommandFormat.Replace("%COMMAND%", command);
|
||||
}
|
||||
|
||||
public static string FormatPlayerCommandCompleteMessage(string command)
|
||||
{
|
||||
return PlayerCommandFormat.Replace("%COMMAND%", command);
|
||||
}
|
||||
|
||||
public static string FormatEquipItemMessage(string name)
|
||||
|
|
|
@ -455,7 +455,10 @@ namespace HISP.Server
|
|||
Messages.ModChatFormatForSender = gameData.messages.chat.for_sender.mod_format;
|
||||
Messages.AdminChatFormatForSender = gameData.messages.chat.for_sender.admin_format;
|
||||
|
||||
Messages.CommandFormat = gameData.messages.commands.command_completed;
|
||||
Messages.AdminCommandFormat = gameData.messages.commands.admin_command_completed;
|
||||
Messages.PlayerCommandFormat = gameData.messages.commands.player_command_completed;
|
||||
Messages.MuteHelp = gameData.messages.commands.mute_help;
|
||||
|
||||
|
||||
Messages.PasswordNotice = gameData.messages.chat.password_included;
|
||||
Messages.CapsNotice = gameData.messages.chat.caps_notice;
|
||||
|
|
|
@ -1437,6 +1437,20 @@ namespace HISP.Server
|
|||
}
|
||||
return usersHere.ToArray();
|
||||
}
|
||||
|
||||
public static User GetUserByName(string username)
|
||||
{
|
||||
foreach(GameClient client in ConnectedClients)
|
||||
{
|
||||
if(client.LoggedIn)
|
||||
{
|
||||
if (client.LoggedinUser.Username == username)
|
||||
return client.LoggedinUser;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("User was not found.");
|
||||
}
|
||||
|
||||
public static User[] GetNearbyUsers(int x, int y, bool includeStealth=false, bool includeMuted=false)
|
||||
{
|
||||
int startX = x - 15;
|
||||
|
|
Binary file not shown.
Loading…
Add table
Reference in a new issue