Thread Rating:
  • 3 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release For Plugin Developers
#1
Update Announcement

Well i was bored so i made this little code which i think will help you as well as plugin users to know if any update arrived so it will be easy for them to update as well as for you also.

CSHARP Code
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Addon;
  5. using System.Threading;
  6. using System.Net;
  7. namespace announcement
  8. {
  9. public class announcement : CPlugin
  10. {
  11. public void update()
  12. {
  13. while (true)
  14. {
  15. WebClient client = new WebClient();
  16. string current_version = "1.02";
  17. string str;
  18. str = client.DownloadString("http://www.yoursite.com/text.txt");
  19. if (str != current_version)
  20. ServerSay("your update text", false);
  21. Thread.Sleep(90000);
  22. }
  23. }
  24. public override void OnServerLoad()
  25. {
  26. new Thread(new ThreadStart(update)).Start();
  27. }
  28. }
  29. }

Well hope you guys like it. Wink
Reply

#2
One question, why do you make a while loop? You can call the function on OnMapLoaded() without a loop.
Reply

#3
me no make plugins but this is nice & useful.
[Image: r212360a129ce9b84444093b6cd2699013a1fbn155.png]
Reply

#4
(02-18-2012, 17:18)masterbob Wrote: One question, why do you make a while loop? You can call the function on OnMapLoaded() without a loop.
Well that's depend on you how to use it its just an example and well its not OnMapLoaded() its OnMapChange() and 110% chances message will not show OnMapChange(). Well i personally used it in this wayTongue
CSHARP Code
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Addon;
  5. using System.Net;
  6. namespace update
  7. {
  8. public class update : CPlugin
  9. {
  10. public override ChatType OnSay(string Message, ServerClient Client)
  11. {
  12. if (Message.StartsWith("!update"))
  13. {
  14. try
  15. {
  16. WebClient client = new WebClient();
  17. string current_version = "1.02";
  18. string version;
  19. string Msg;
  20. version = client.DownloadString("http://www.yoursite.com/version.txt");
  21. Msg = client.DownloadString("http://www.yoursite.com/text.txt");
  22. if (version != current_version)
  23. {
  24. TellClient(Client.ClientNum, "^2PM: ^3" + Msg, true);
  25. }
  26. else
  27. {
  28. TellClient(Client.ClientNum, "^2PM: ^3You have an updated version.", true);
  29. }
  30. return ChatType.ChatNone;
  31. }
  32. catch
  33. { }
  34. TellClient(Client.ClientNum, "^3PM: ^1Server is not responding try another time.", true);
  35. return ChatType.ChatNone;
  36. }
  37. return ChatType.ChatContinue;
  38. }
  39. }
  40. }


Reply

#5
it can be operated with the addition of addon 1.414???
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
Wink Plugin with !ban !kick and !tampban clemi555 3 4,167 11-09-2013, 09:21
Last Post: clemi555
  AntiNoScope Plugin clemi555 5 4,745 11-08-2013, 19:13
Last Post: clemi555
  [Release] Bunker Plugin 1.3 archit 68 41,552 10-30-2013, 11:59
Last Post: clacki
  Help Modifying plugin maverigh 5 5,668 10-19-2013, 10:29
Last Post: Nekochan
Shocked [Request] Switch plugin axel-le-meilleur 6 5,177 10-19-2013, 06:59
Last Post: iRoNinja
  [Release] Yurio Map Plugin Yurio 101 62,273 09-26-2013, 13:38
Last Post: First_Semyon
Brick [Release] v1.1 ChangeMap/NextMap Plugin without any configuration milchshake 23 18,637 09-23-2013, 13:18
Last Post: SgtLegend
  Help !say Plugin (like the !say from GodPlugin) Hallla 0 2,711 09-13-2013, 09:31
Last Post: Hallla
Rainbow [Release] MW3: Random Weapon Plugin V1 Nekochan 50 33,272 09-11-2013, 15:11
Last Post: EnVi Sweden Rocks
  Search Plugin Fluid Killcam N3xT_974 1 3,063 09-10-2013, 20:27
Last Post: Nekochan

Forum Jump:


Users browsing this thread:
1 Guest(s)

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