Dear people,
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!!
Don't think it'll be possible just do ^5/4 for talking as a moderator and ^1 as an admin. Not so hard.
CSHARP Code
using System;
using System.Collections.Generic;
using Addon;
using System.Text;
namespace ClassLibrary1
{
public class Class1:CPlugin
{
List
<string> Admins
= new List
<string>(); List
<string> Moderators
= new List
<string>();
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 admins)
{
Admins.Add(xuid);
}
foreach (string xuid in mods)
{
Moderators.Add(xuid);
}
}
public override ChatType OnSay(string Message, ServerClient Client)
{
if (!Message.StartsWith("!"))
{
if (Admins.Contains(Client.XUID))
{
ServerSay("^1[Admin] ^8" + Client.Name + "^7:^1 " + Message, true);
return ChatType.ChatNone;
}
if (Moderators.Contains(Client.XUID))
{
ServerSay("^1[Mod] ^7" + Client.Name + "^7:^4 " + Message, true);
return ChatType.ChatNone;
}
}
return ChatType.ChatContinue;
}
}
}
I was too lazy to add sv_config stuff, feel free to edit the code.
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.
Try to add 'else'.
(04-24-2013, 19:14)SailorMoon Wrote: [ -> ] (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.
Try to add 'else'.
I already tried it, it doesn't work
Try to use Dictionary?
Also try to make sleeping between two foreaches, problem may be there.
CSHARP Code
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;
}
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 :/