Added some code to enable chat above heads
This commit is contained in:
parent
ed0756e80c
commit
8bcc24da7e
4 changed files with 36 additions and 1 deletions
|
|
@ -234,6 +234,9 @@ namespace TShockAPI
|
|||
[Description("Prevent players from interacting with the world if dead")] public bool PreventDeadModification =
|
||||
false;
|
||||
|
||||
[Description("Displays chat messages above players' heads, but will disable chat prefixes to compensate.")] public
|
||||
bool EnableChatAboveHeads = false;
|
||||
|
||||
/// <summary>
|
||||
/// Reads a configuration file from a given path
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -422,6 +422,11 @@ namespace TShockAPI
|
|||
SendData(PacketTypes.ChatText, msg, 255, red, green, blue);
|
||||
}
|
||||
|
||||
public virtual void SendMessageFromPlayer(string msg, byte red, byte green, byte blue, int ply)
|
||||
{
|
||||
SendDataFromPlayer(PacketTypes.ChatText, ply, msg, 255, red, green, blue);
|
||||
}
|
||||
|
||||
public virtual void DamagePlayer(int damage)
|
||||
{
|
||||
NetMessage.SendData((int) PacketTypes.PlayerDamage, -1, -1, "", Index, ((new Random()).Next(-1, 1)), damage,
|
||||
|
|
@ -481,6 +486,14 @@ namespace TShockAPI
|
|||
NetMessage.SendData((int) msgType, Index, -1, text, number, number2, number3, number4, number5);
|
||||
}
|
||||
|
||||
public virtual void SendDataFromPlayer(PacketTypes msgType, int ply, string text = "", int number = 0, float number2 = 0f, float number3 = 0f, float number4 = 0f, int number5 = 0)
|
||||
{
|
||||
if (RealPlayer && !ConnectionAlive)
|
||||
return;
|
||||
|
||||
NetMessage.SendData((int) msgType, Index, ply, text, number, number2, number3, number4, number5);
|
||||
}
|
||||
|
||||
public virtual bool SendRawData(byte[] data)
|
||||
{
|
||||
if (!RealPlayer || !ConnectionAlive)
|
||||
|
|
|
|||
|
|
@ -801,12 +801,16 @@ namespace TShockAPI
|
|||
Log.Error(ex.ToString());
|
||||
}
|
||||
}
|
||||
else if (!tsplr.mute)
|
||||
else if (!tsplr.mute && !TShock.Config.EnableChatAboveHeads)
|
||||
{
|
||||
Utils.Broadcast(
|
||||
String.Format(Config.ChatFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix, text),
|
||||
tsplr.Group.R, tsplr.Group.G, tsplr.Group.B);
|
||||
e.Handled = true;
|
||||
} else if (!tsplr.mute && TShock.Config.EnableChatAboveHeads)
|
||||
{
|
||||
Utils.Broadcast(ply, text, tsplr.Group.R, tsplr.Group.G, tsplr.Group.B);
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (tsplr.mute)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -171,6 +171,21 @@ namespace TShockAPI
|
|||
Broadcast(msg, color.R, color.G, color.B);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Broadcasts a message from a player, not TShock
|
||||
/// </summary>
|
||||
/// <param name="ply">TSPlayer ply - the player that will send the packet</param>
|
||||
/// <param name="msg">string msg - the message</param>
|
||||
/// <param name="red">r</param>
|
||||
/// <param name="green">g</param>
|
||||
/// <param name="blue">b</param>
|
||||
public void Broadcast(int ply, string msg, byte red, byte green, byte blue)
|
||||
{
|
||||
TSPlayer.All.SendMessageFromPlayer(msg, red, green, blue, ply);
|
||||
TSPlayer.Server.SendMessage(msg, red, green, blue);
|
||||
Log.Info(string.Format("Broadcast: {0}", msg));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends message to all users with 'logs' permission.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue