ItsMods

Full Version: Rules plugin v2
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
Yes, new Thread + Thread.Sleep
(01-12-2012, 22:42)Yurio Wrote: [ -> ]Yes, new Thread + Thread.Sleep

do you know if this will be implemented?

My mod of the jariz's original plugin (for .NET 3 is not checked):

CSHARP Code
  1. using System.IO;
  2. using System.Threading;
  3. using Addon;
  4.  
  5. namespace Rules
  6. {
  7. public class Rules : CPlugin
  8. {
  9. string[] rules = { "" };
  10. public override void OnServerLoad()
  11. {
  12. rules = File.ReadAllLines("addon\\rules.txt");
  13. ServerPrint("Rules plugin");
  14. }
  15.  
  16. public override ChatType OnSay(string Message, ServerClient Client)
  17. {
  18. ServerPrint(Client.Name + ": " + Message);
  19. if (Message.StartsWith("!cmd"))
  20. {
  21. Thread shru = new Thread(ShowRules);
  22. shru.Start(Client);
  23. return ChatType.ChatNone;
  24. }
  25. return ChatType.ChatGame;
  26. }
  27.  
  28. private void ShowRules(object cli)
  29. {
  30. ServerClient sc = (ServerClient)cli;
  31. foreach (string rule in rules)
  32. {
  33. Thread.Sleep(1000);
  34. TellClient(sc.ClientNum, "[^1PM^7]: " + rule, true);
  35. ServerPrint("console to " + sc.Name + ": " + "[^1PM^7]: " + rule);
  36. }
  37. }
  38. }
  39. }
(01-15-2012, 07:34)Yurio Wrote: [ -> ]My mod of the jariz's original plugin (for .NET 3 is not checked):

CSHARP Code
  1. using System.IO;
  2. using System.Threading;
  3. using Addon;
  4.  
  5. namespace Rules
  6. {
  7. public class Rules : CPlugin
  8. {
  9. string[] rules = { "" };
  10. public override void OnServerLoad()
  11. {
  12. rules = File.ReadAllLines("addon\\rules.txt");
  13. ServerPrint("Rules plugin");
  14. }
  15.  
  16. public override ChatType OnSay(string Message, ServerClient Client)
  17. {
  18. ServerPrint(Client.Name + ": " + Message);
  19. if (Message.StartsWith("!cmd"))
  20. {
  21. Thread shru = new Thread(ShowRules);
  22. shru.Start(Client);
  23. return ChatType.ChatNone;
  24. }
  25. return ChatType.ChatGame;
  26. }
  27.  
  28. private void ShowRules(object cli)
  29. {
  30. ServerClient sc = (ServerClient)cli;
  31. foreach (string rule in rules)
  32. {
  33. Thread.Sleep(1000);
  34. TellClient(sc.ClientNum, "[^1PM^7]: " + rule, true);
  35. ServerPrint("console to " + sc.Name + ": " + "[^1PM^7]: " + rule);
  36. }
  37. }
  38. }
  39. }
how do i get this on my server
@Cprl.Rst someone has to complie the code to dll file
@Yurio Good job but messages pop up too fast,hard to read it

Camelot

You can write rules in Russian???
@camelot if you had actually read the thread you could see that rules can be edited and added yourself. So yes, in Russian as well

Camelot

When I wrote the rules of the game, I have question marks in game!
In that case IDK. Something with the encoding of the file I guess

Camelot

What do?
Pages: 1 2 3 4