I use this addon -> Permission plugin now what I want is that when it detects that you are an Admin in the server the chat color is red, when it detects it's a moderator the chat color is blue. If it is possible at all what I ask it would be cool if you can make something like this too [Mod] Playername: text here
I've no idea if this is possible but if you could create this it would be amazing!!
There's a little bug in the plugin but I couldn't find a fix. The problem is that the chat doesn't get hid if a mod talks, for admins it's working fine. I use the code that I posted above so if you find the bug please tell me.
(04-24-2013, 19:03)8q4s8 Wrote: There's a little bug in the plugin but I couldn't find a fix. The problem is that the chat doesn't get hid if a mod talks, for admins it's working fine. I use the code that I posted above so if you find the bug please tell me.
(04-24-2013, 19:03)8q4s8 Wrote: There's a little bug in the plugin but I couldn't find a fix. The problem is that the chat doesn't get hid if a mod talks, for admins it's working fine. I use the code that I posted above so if you find the bug please tell me.
04-24-2013, 20:37 (This post was last modified: 04-25-2013, 13:22 by 8q4s8.)
Ok I finally found the bug! It wasn't in my plugin actually, it was in the permission plugin:
Code:
if (userIsInGroup != "Admin")
{
if (!lowMsg.StartsWith("!"))
return ChatType.ChatAll;
return ChatType.ChatAll;
I replaced it with ChatContinue and it worked! Also I added a few more functions:
!chat - disable all the tags
!toggletag - enables/disables your tag
Code:
using System;
using System.Collections.Generic;
using Addon;
using System.Text;
namespace ClassLibrary1
{
public class Class1:CPlugin
{
Dictionary<string, string> xuids = new Dictionary<string, string>();
bool togglechat = false;
Dictionary<string, bool> chat = new Dictionary<string, bool>();
public override void OnServerLoad()
{
ServerPrint("ChatPlugin by 8Q4S8 loaded!");
string admin = GetServerCFG("Permission", "Admin_xuids", "");
string[] admins = admin.Split(',');
string mod = GetServerCFG("Permission", "Moderator_xuids", "");
string[] mods = mod.Split(',');
foreach (string xuid in mods)
{
xuids.Add(xuid, "Mod");
}
foreach (string xuidz in admins)
{
xuids.Add(xuidz, "Admin");
}
}
public override ChatType OnSay(string Message, ServerClient Client)
{
if (!Message.StartsWith("!") && togglechat == false && chat[Client.XUID] == false)
{
if (xuids.ContainsKey(Client.XUID))
{
ServerSay("^1[" + xuids[Client.XUID]+ "] ^8" + Client.Name + "^7:^1 " + Message, true);
return ChatType.ChatNone;
}
}
if (Message.ToLower() == "!chat")
{
togglechat = !togglechat;
return ChatType.ChatNone;
}
if (Message.ToLower() == "!toggletag")
{
chat[Client.XUID] = !chat[Client.XUID];
return ChatType.ChatNone;
}
return ChatType.ChatContinue;
}
public override void OnPlayerConnect(ServerClient Client)
{
chat.Add(Client.XUID, false);
}
public override void OnPlayerDisconnect(ServerClient Client)
{
chat.Remove(Client.XUID);
}
}
}
You can also change the code back to the version with List<>, it should work too.
I also attached the edited permission plugin, credits for that go obviously to @Pozzuh
I still can't figure it out why the first return ChatType.ChatNone; does not work under ServerSay("^1[" + xuids[Client.XUID]+ "] ^8" + Client.Name + "^7:^1 " + Message, true);
but the second return ChatType.ChatNone; works fine..
8q4s8 told me that another plugin might cause the problem, but I removed all the plugins and tested it, it still does not work - anyone that can help me out? I really don't know what is wrong :/