Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
In game chat
#1
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!!
Reply

#2
Don't think it'll be possible just do ^5/4 for talking as a moderator and ^1 as an admin. Not so hard.
Do not take life too seriously. You will never get out of it alive.
[Image: UGPjFJa.jpg]
Reply

#3
CSHARP Code
  1. using System;
  2. using System.Collections.Generic;
  3. using Addon;
  4. using System.Text;
  5.  
  6. namespace ClassLibrary1
  7. {
  8. public class Class1:CPlugin
  9. {
  10. List<string> Admins = new List<string>();
  11. List<string> Moderators = new List<string>();
  12.  
  13. public override void OnServerLoad()
  14. {
  15. ServerPrint("ChatPlugin by 8Q4S8 loaded!");
  16.  
  17. string admin = GetServerCFG("Permission", "Admin_xuids", "");
  18. string[] admins = admin.Split(',');
  19.  
  20. string mod = GetServerCFG("Permission", "Moderator_xuids", "");
  21. string[] mods = mod.Split(',');
  22.  
  23. foreach (string xuid in admins)
  24. {
  25. Admins.Add(xuid);
  26. }
  27. foreach (string xuid in mods)
  28. {
  29. Moderators.Add(xuid);
  30. }
  31. }
  32. public override ChatType OnSay(string Message, ServerClient Client)
  33. {
  34. if (!Message.StartsWith("!"))
  35. {
  36. if (Admins.Contains(Client.XUID))
  37. {
  38. ServerSay("^1[Admin] ^8" + Client.Name + "^7:^1 " + Message, true);
  39. return ChatType.ChatNone;
  40. }
  41. if (Moderators.Contains(Client.XUID))
  42. {
  43. ServerSay("^1[Mod] ^7" + Client.Name + "^7:^4 " + Message, true);
  44. return ChatType.ChatNone;
  45. }
  46. }
  47. return ChatType.ChatContinue;
  48. }
  49. }
  50. }


I was too lazy to add sv_config stuff, feel free to edit the code.


Attached Files
.zip   ChatPlugin.zip (Size: 2.19 KB / Downloads: 15)
Reply

#4
Thank you soo much! (:
Reply

#5
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.
Reply

#6
(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'.
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#7
(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
Reply

#8
Try to use Dictionary?

Also try to make sleeping between two foreaches, problem may be there.
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#9


Attached Files
.zip   ChatPlugin.zip (Size: 5.5 KB / Downloads: 22)
Reply

#10
CSHARP Code
  1. if (xuids.ContainsKey(Client.XUID))
  2. {
  3. ServerSay("^1[" + xuids[Client.XUID]+ "] ^8" + Client.Name + "^7:^1 " + Message, true);
  4. return ChatType.ChatNone;
  5. }
  6. }
  7. if (Message.ToLower() == "!chat")
  8. {
  9. togglechat = !togglechat;
  10. return ChatType.ChatNone;
  11. }


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 :/
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  What game have you bought in the last week? RaZ 12 8,043 12-05-2013, 16:29
Last Post: Nekochan
  [GAME]The Letter Game Bandarigoda123 65 30,108 08-08-2013, 21:05
Last Post: AZUMIKKEL
  [Release] AntiRage for Infected Game Mode yokai134 17 14,252 08-04-2013, 22:22
Last Post: yokai134
  ESTRANGED best indie game I've seen so far Arteq 0 2,568 08-03-2013, 14:03
Last Post: Arteq
  how to remove commands in the chat ExoGamer* 6 4,452 07-20-2013, 09:24
Last Post: Pozzuh
  [HELP] bo2 - FD1 - dis-attach the console from the game masis 8 5,880 07-17-2013, 23:01
Last Post: surtek
Smile [Release] Map & Game Type Changer Plugin (Fixed) 30mba 31 21,885 07-10-2013, 16:27
Last Post: 26hz
  [Request] Names, Chat and Scoreboard Mibbix 6 4,537 06-21-2013, 22:16
Last Post: Mibbix
  Selling steam account for a game! Strentin 3 4,109 06-18-2013, 07:49
Last Post: xfxtroll
  Help Using chat outside in game Bandarigoda123 1 3,036 06-09-2013, 12:46
Last Post: Nekochan

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.