ItsMods

Full Version: Need Time Plugin and Server Msg Plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi guys i need Time Plugin for my server

[attachment=2693]

I also need Server msg plugin i have Timed Messages in my server but it says console: (my timed message)
i don't need console. like this:-

[attachment=2694]
CSHARP Code
  1. using System;
  2. using System.Collections.Generic;
  3. using Addon;
  4. using System.Text;
  5. using System.Timers;
  6.  
  7. namespace ClassLibrary1
  8. {
  9. public class Class1:CPlugin
  10. {
  11. List<string> MessageList = new List<string>();
  12. Timer timer = new Timer();
  13. int interval;
  14. int Messages;
  15. int CurrentMSG;
  16.  
  17. public override void OnServerLoad()
  18. {
  19. Config();
  20. ServerPrint("TimedMessage Plugin by 8Q4S8 loaded!");
  21. }
  22. void handler(object s, ElapsedEventArgs e)
  23. {
  24. if (Messages <= CurrentMSG)
  25. {
  26. CurrentMSG = 0;
  27. }
  28.  
  29. ServerSay(MessageList[CurrentMSG], true);
  30.  
  31. CurrentMSG++;
  32. }
  33. void Config()
  34. {
  35. try
  36. {
  37. interval = int.Parse(GetServerCFG("TimedMSG", "interval", ""));
  38. Messages = int.Parse(GetServerCFG("TimedMSG", "Messages", ""));
  39.  
  40. if (Messages != 0)
  41. {
  42. CurrentMSG = 0;
  43. for (int i = 1; i <= Messages; i++)
  44. {
  45. MessageList.Add(GetServerCFG("TimedMSG", "MSG" + i.ToString(), ""));
  46. }
  47. }
  48. timer.Interval = 1000 * interval;
  49. timer.Elapsed += new ElapsedEventHandler(handler);
  50. timer.Enabled = true;
  51.  
  52.  
  53. }
  54. catch (Exception e)
  55. {
  56. ServerPrint(e.Message);
  57. }
  58. }
  59. }
  60. }


sv_config:
Code:
[TimedMSG]
//interval in seconds
interval=2
//the amount of messages you use
Messages=3
MSG1=^1Message1
MSG2=^2MSG2
MSG3=^33rd message

feel free to make a better config, I coded the plugin in 5 minutes.

The time plugin is a bit harder because you have to get the timezone/country of the player with his IP.
(07-22-2013, 12:58)8q4s8 Wrote: [ -> ]
CSHARP Code
  1. using System;
  2. using System.Collections.Generic;
  3. using Addon;
  4. using System.Text;
  5. using System.Timers;
  6.  
  7. namespace ClassLibrary1
  8. {
  9. public class Class1:CPlugin
  10. {
  11. List<string> MessageList = new List<string>();
  12. Timer timer = new Timer();
  13. int interval;
  14. int Messages;
  15. int CurrentMSG;
  16.  
  17. public override void OnServerLoad()
  18. {
  19. Config();
  20. ServerPrint("TimedMessage Plugin by 8Q4S8 loaded!");
  21. }
  22. void handler(object s, ElapsedEventArgs e)
  23. {
  24. if (Messages <= CurrentMSG)
  25. {
  26. CurrentMSG = 0;
  27. }
  28.  
  29. ServerSay(MessageList[CurrentMSG], true);
  30.  
  31. CurrentMSG++;
  32. }
  33. void Config()
  34. {
  35. try
  36. {
  37. interval = int.Parse(GetServerCFG("TimedMSG", "interval", ""));
  38. Messages = int.Parse(GetServerCFG("TimedMSG", "Messages", ""));
  39.  
  40. if (Messages != 0)
  41. {
  42. CurrentMSG = 0;
  43. for (int i = 1; i <= Messages; i++)
  44. {
  45. MessageList.Add(GetServerCFG("TimedMSG", "MSG" + i.ToString(), ""));
  46. }
  47. }
  48. timer.Interval = 1000 * interval;
  49. timer.Elapsed += new ElapsedEventHandler(handler);
  50. timer.Enabled = true;
  51.  
  52.  
  53. }
  54. catch (Exception e)
  55. {
  56. ServerPrint(e.Message);
  57. }
  58. }
  59. }
  60. }


sv_config:
Code:
[TimedMSG]
//interval in seconds
interval=2
//the amount of messages you use
Messages=3
MSG1=^1Message1
MSG2=^2MSG2
MSG3=^33rd message

feel free to make a better config, I coded the plugin in 5 minutes.

The time plugin is a bit harder because you have to get the timezone/country of the player with his IP.

Thanks it Works. Smile I only need My computer time on my server but the text should be Time in PK : (My Computer Time)
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. public override ChatType OnSay(string Message, ServerClient Client)
  11. {
  12. if (Message.ToLower() == "!time")
  13. {
  14. TellClient(Client.ClientNum,"Time (UTC " + TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).TotalHours + "): ^2" + DateTime.Now.ToLongTimeString(),true);
  15. return ChatType.ChatNone;
  16. }
  17. return ChatType.ChatContinue;
  18. }
  19. }
  20. }


it shows the UTC timezone and the time to the player who types !time
(07-22-2013, 18:22)8q4s8 Wrote: [ -> ]
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. public override ChatType OnSay(string Message, ServerClient Client)
  11. {
  12. if (Message.ToLower() == "!time")
  13. {
  14. TellClient(Client.ClientNum,"Time (UTC " + TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).TotalHours + "): ^2" + DateTime.Now.ToLongTimeString(),true);
  15. return ChatType.ChatNone;
  16. }
  17. return ChatType.ChatContinue;
  18. }
  19. }
  20. }


it shows the UTC timezone and the time to the player who types !time

I need auto time like timed messages, After 5 mins the should show time and i need same colors as shown in screenshot. Thanks
CSHARP Code
  1. using System;
  2. using System.Collections.Generic;
  3. using Addon;
  4. using System.Text;
  5. using System.Timers;
  6.  
  7. namespace ClassLibrary1
  8. {
  9. public class Class1:CPlugin
  10. {
  11. List<string> MessageList = new List<string>();
  12. Timer timer = new Timer();
  13. int interval;
  14. int Messages;
  15. int CurrentMSG;
  16.  
  17. public override void OnServerLoad()
  18. {
  19. Config();
  20. ServerPrint("TimedMessage Plugin by 8Q4S8 loaded!");
  21. }
  22. void handler(object s, ElapsedEventArgs e)
  23. {
  24. if (Messages <= CurrentMSG)
  25. {
  26. CurrentMSG = 0;
  27. }
  28. if (MessageList[CurrentMSG] != "!time")
  29. {
  30. ServerSay(MessageList[CurrentMSG], true);
  31. }
  32. else
  33. {
  34. ServerSay("Time (UTC " + TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).TotalHours + "): ^2" + DateTime.Now.ToLongTimeString(), true);
  35. }
  36.  
  37. CurrentMSG++;
  38. }
  39. void Config()
  40. {
  41. try
  42. {
  43. interval = int.Parse(GetServerCFG("TimedMSG", "interval", ""));
  44. Messages = int.Parse(GetServerCFG("TimedMSG", "Messages", ""));
  45.  
  46. if (Messages != 0)
  47. {
  48. CurrentMSG = 0;
  49. for (int i = 1; i <= Messages; i++)
  50. {
  51. MessageList.Add(GetServerCFG("TimedMSG", "MSG" + i.ToString(), ""));
  52. }
  53. }
  54. timer.Interval = 1000 * interval;
  55. timer.Elapsed += new ElapsedEventHandler(handler);
  56. timer.Enabled = true;
  57.  
  58.  
  59. }
  60. catch (Exception e)
  61. {
  62. ServerPrint(e.Message);
  63. }
  64. }
  65. }
  66. }


Edit this string to the colors you like and compile it
CSHARP Code
  1. ServerSay("Time (UTC + " + TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).TotalHours + "): ^2" + DateTime.Now.ToLongTimeString(), true);


then you can use MSG1=!time to show the time.
(07-23-2013, 16:28)8q4s8 Wrote: [ -> ]
CSHARP Code
  1. using System;
  2. using System.Collections.Generic;
  3. using Addon;
  4. using System.Text;
  5. using System.Timers;
  6.  
  7. namespace ClassLibrary1
  8. {
  9. public class Class1:CPlugin
  10. {
  11. List<string> MessageList = new List<string>();
  12. Timer timer = new Timer();
  13. int interval;
  14. int Messages;
  15. int CurrentMSG;
  16.  
  17. public override void OnServerLoad()
  18. {
  19. Config();
  20. ServerPrint("TimedMessage Plugin by 8Q4S8 loaded!");
  21. }
  22. void handler(object s, ElapsedEventArgs e)
  23. {
  24. if (Messages <= CurrentMSG)
  25. {
  26. CurrentMSG = 0;
  27. }
  28. if (MessageList[CurrentMSG] != "!time")
  29. {
  30. ServerSay(MessageList[CurrentMSG], true);
  31. }
  32. else
  33. {
  34. ServerSay("Time (UTC " + TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).TotalHours + "): ^2" + DateTime.Now.ToLongTimeString(), true);
  35. }
  36.  
  37. CurrentMSG++;
  38. }
  39. void Config()
  40. {
  41. try
  42. {
  43. interval = int.Parse(GetServerCFG("TimedMSG", "interval", ""));
  44. Messages = int.Parse(GetServerCFG("TimedMSG", "Messages", ""));
  45.  
  46. if (Messages != 0)
  47. {
  48. CurrentMSG = 0;
  49. for (int i = 1; i <= Messages; i++)
  50. {
  51. MessageList.Add(GetServerCFG("TimedMSG", "MSG" + i.ToString(), ""));
  52. }
  53. }
  54. timer.Interval = 1000 * interval;
  55. timer.Elapsed += new ElapsedEventHandler(handler);
  56. timer.Enabled = true;
  57.  
  58.  
  59. }
  60. catch (Exception e)
  61. {
  62. ServerPrint(e.Message);
  63. }
  64. }
  65. }
  66. }


Edit this string to the colors you like and compile it
CSHARP Code
  1. ServerSay("Time (UTC + " + TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).TotalHours + "): ^2" + DateTime.Now.ToLongTimeString(), true);


then you can use MSG1=!time to show the time.

need Autotime not !time, Autotime after every 5 mins and in colours also.
Did you even read it? You can use !time in timedmessage plugin with this code
(07-23-2013, 18:24)8q4s8 Wrote: [ -> ]Did you even read it? You can use !time in timedmessage plugin with this code

Added !time in Timed messages but not working Sad

[attachment=2700]
Did you update the plugin with the code that I posted?
Pages: 1 2