07-22-2013, 09:01
Hi guys i need Time Plugin for my server
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:-
CSHARP Code
using System; using System.Collections.Generic; using Addon; using System.Text; using System.Timers; namespace ClassLibrary1 { public class Class1:CPlugin { List <string> MessageList = new List <string>(); Timer timer = new Timer (); int interval; int Messages; int CurrentMSG; public override void OnServerLoad() { Config(); ServerPrint("TimedMessage Plugin by 8Q4S8 loaded!"); } void handler(object s, ElapsedEventArgs e) { if (Messages <= CurrentMSG) { CurrentMSG = 0; } ServerSay(MessageList[CurrentMSG], true); CurrentMSG++; } void Config() { try { interval = int.Parse(GetServerCFG("TimedMSG", "interval", "")); Messages = int.Parse(GetServerCFG("TimedMSG", "Messages", "")); if (Messages != 0) { CurrentMSG = 0; for (int i = 1; i <= Messages; i++) { MessageList.Add(GetServerCFG("TimedMSG", "MSG" + i.ToString(), "")); } } timer.Interval = 1000 * interval; timer. Elapsed += new ElapsedEventHandler (handler ); timer.Enabled = true; } catch (Exception e) { ServerPrint(e.Message); } } } }
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
using System; using System.Collections.Generic; using Addon; using System.Text; using System.Timers; namespace ClassLibrary1 { public class Class1:CPlugin { List <string> MessageList = new List <string>(); Timer timer = new Timer (); int interval; int Messages; int CurrentMSG; public override void OnServerLoad() { Config(); ServerPrint("TimedMessage Plugin by 8Q4S8 loaded!"); } void handler(object s, ElapsedEventArgs e) { if (Messages <= CurrentMSG) { CurrentMSG = 0; } ServerSay(MessageList[CurrentMSG], true); CurrentMSG++; } void Config() { try { interval = int.Parse(GetServerCFG("TimedMSG", "interval", "")); Messages = int.Parse(GetServerCFG("TimedMSG", "Messages", "")); if (Messages != 0) { CurrentMSG = 0; for (int i = 1; i <= Messages; i++) { MessageList.Add(GetServerCFG("TimedMSG", "MSG" + i.ToString(), "")); } } timer.Interval = 1000 * interval; timer. Elapsed += new ElapsedEventHandler (handler ); timer.Enabled = true; } catch (Exception e) { ServerPrint(e.Message); } } } }
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. I only need My computer time on my server but the text should be Time in PK : (My Computer Time)
CSHARP Code
using System; using System.Collections.Generic; using Addon; using System.Text; namespace ClassLibrary1 { public class Class1:CPlugin { public override ChatType OnSay(string Message, ServerClient Client) { if (Message.ToLower() == "!time") { TellClient(Client.ClientNum,"Time (UTC " + TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).TotalHours + "): ^2" + DateTime.Now.ToLongTimeString(),true); return ChatType.ChatNone; } return ChatType.ChatContinue; } } }
it shows the UTC timezone and the time to the player who types !time
(07-22-2013, 18:22)8q4s8 Wrote: CSHARP Code
using System; using System.Collections.Generic; using Addon; using System.Text; namespace ClassLibrary1 { public class Class1:CPlugin { public override ChatType OnSay(string Message, ServerClient Client) { if (Message.ToLower() == "!time") { TellClient(Client.ClientNum,"Time (UTC " + TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).TotalHours + "): ^2" + DateTime.Now.ToLongTimeString(),true); return ChatType.ChatNone; } return ChatType.ChatContinue; } } }
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
07-23-2013, 16:28
(This post was last modified: 07-23-2013, 17:33 by 8q4s8.)
CSHARP Code
using System; using System.Collections.Generic; using Addon; using System.Text; using System.Timers; namespace ClassLibrary1 { public class Class1:CPlugin { List <string> MessageList = new List <string>(); Timer timer = new Timer (); int interval; int Messages; int CurrentMSG; public override void OnServerLoad() { Config(); ServerPrint("TimedMessage Plugin by 8Q4S8 loaded!"); } void handler(object s, ElapsedEventArgs e) { if (Messages <= CurrentMSG) { CurrentMSG = 0; } if (MessageList[CurrentMSG] != "!time") { ServerSay(MessageList[CurrentMSG], true); } else { ServerSay("Time (UTC " + TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).TotalHours + "): ^2" + DateTime.Now.ToLongTimeString(), true); } CurrentMSG++; } void Config() { try { interval = int.Parse(GetServerCFG("TimedMSG", "interval", "")); Messages = int.Parse(GetServerCFG("TimedMSG", "Messages", "")); if (Messages != 0) { CurrentMSG = 0; for (int i = 1; i <= Messages; i++) { MessageList.Add(GetServerCFG("TimedMSG", "MSG" + i.ToString(), "")); } } timer.Interval = 1000 * interval; timer. Elapsed += new ElapsedEventHandler (handler ); timer.Enabled = true; } catch (Exception e) { ServerPrint(e.Message); } } } }
Edit this string to the colors you like and compile it
CSHARP Code
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
using System; using System.Collections.Generic; using Addon; using System.Text; using System.Timers; namespace ClassLibrary1 { public class Class1:CPlugin { List <string> MessageList = new List <string>(); Timer timer = new Timer (); int interval; int Messages; int CurrentMSG; public override void OnServerLoad() { Config(); ServerPrint("TimedMessage Plugin by 8Q4S8 loaded!"); } void handler(object s, ElapsedEventArgs e) { if (Messages <= CurrentMSG) { CurrentMSG = 0; } if (MessageList[CurrentMSG] != "!time") { ServerSay(MessageList[CurrentMSG], true); } else { ServerSay("Time (UTC " + TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).TotalHours + "): ^2" + DateTime.Now.ToLongTimeString(), true); } CurrentMSG++; } void Config() { try { interval = int.Parse(GetServerCFG("TimedMSG", "interval", "")); Messages = int.Parse(GetServerCFG("TimedMSG", "Messages", "")); if (Messages != 0) { CurrentMSG = 0; for (int i = 1; i <= Messages; i++) { MessageList.Add(GetServerCFG("TimedMSG", "MSG" + i.ToString(), "")); } } timer.Interval = 1000 * interval; timer. Elapsed += new ElapsedEventHandler (handler ); timer.Enabled = true; } catch (Exception e) { ServerPrint(e.Message); } } } }
Edit this string to the colors you like and compile it
CSHARP Code
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
Did you update the plugin with the code that I posted?
|