• 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: 11)
[-] The following 4 users say Thank You to 8q4s8 for this post:
  • iAegle, narkos, shanky, X-Track
  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-C developer. 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-C developer. Neko engine wip
Steam: Click
  Reply
#9
Ok I finally found the bug! It wasn't in my plugin actually, it was in the permission plugin:

CSHARP Code
  1. if (userIsInGroup != "Admin")
  2. {
  3. if (!lowMsg.StartsWith("!"))
  4. 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

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. Dictionary<string, string> xuids = new Dictionary<string, string>();
  11. bool togglechat = false;
  12. Dictionary<string, bool> chat = new Dictionary<string, bool>();
  13.  
  14. public override void OnServerLoad()
  15. {
  16. ServerPrint("ChatPlugin by 8Q4S8 loaded!");
  17.  
  18. string admin = GetServerCFG("Permission", "Admin_xuids", "");
  19. string[] admins = admin.Split(',');
  20.  
  21. string mod = GetServerCFG("Permission", "Moderator_xuids", "");
  22. string[] mods = mod.Split(',');
  23.  
  24. foreach (string xuid in mods)
  25. {
  26. xuids.Add(xuid, "Mod");
  27. }
  28.  
  29. foreach (string xuidz in admins)
  30. {
  31. xuids.Add(xuidz, "Admin");
  32. }
  33. }
  34. public override ChatType OnSay(string Message, ServerClient Client)
  35. {
  36. if (!Message.StartsWith("!") && togglechat == false && chat[Client.XUID] == false)
  37. {
  38. if (xuids.ContainsKey(Client.XUID))
  39. {
  40. ServerSay("^1[" + xuids[Client.XUID]+ "] ^8" + Client.Name + "^7:^1 " + Message, true);
  41. return ChatType.ChatNone;
  42. }
  43. }
  44. if (Message.ToLower() == "!chat")
  45. {
  46. togglechat = !togglechat;
  47. return ChatType.ChatNone;
  48. }
  49. if (Message.ToLower() == "!toggletag")
  50. {
  51. chat[Client.XUID] = !chat[Client.XUID];
  52. return ChatType.ChatNone;
  53. }
  54. return ChatType.ChatContinue;
  55. }
  56. public override void OnPlayerConnect(ServerClient Client)
  57. {
  58. chat.Add(Client.XUID, false);
  59. }
  60. public override void OnPlayerDisconnect(ServerClient Client)
  61. {
  62. chat.Remove(Client.XUID);
  63. }
  64. }
  65. }


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


Attached Files
.zip   ChatPlugin.zip (Size: 5.5 KB / Downloads: 18)
[-] The following 2 users say Thank You to 8q4s8 for this post:
  • Dr3am95, shanky
  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 3,335 12-05-2013, 16:29
Last Post: Nekochan
  [GAME]The Letter Game Bandarigoda123 65 10,929 08-08-2013, 21:05
Last Post: AZUMIKKEL
  [Release] AntiRage for Infected Game Mode yokai134 17 7,682 08-04-2013, 22:22
Last Post: yokai134
  ESTRANGED best indie game I've seen so far Arteq 0 1,170 08-03-2013, 14:03
Last Post: Arteq
  how to remove commands in the chat ExoGamer* 6 1,804 07-20-2013, 09:24
Last Post: Pozzuh
  [HELP] bo2 - FD1 - dis-attach the console from the game masis 8 2,661 07-17-2013, 23:01
Last Post: surtek
Smile [Release] Map & Game Type Changer Plugin (Fixed) 30mba 31 11,719 07-10-2013, 16:27
Last Post: 26hz
  [Request] Names, Chat and Scoreboard Mibbix 6 2,068 06-21-2013, 22:16
Last Post: Mibbix
  Selling steam account for a game! Strentin 3 1,876 06-18-2013, 07:49
Last Post: xfxtroll
  Help Using chat outside in game Bandarigoda123 1 1,354 06-09-2013, 12:46
Last Post: Nekochan

Forum Jump:


Users browsing this thread: 1 Guest(s)