• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Request] iPrintLn Automatic time
#1
Brick 
Hey Guys!Smile

need help with iPrintLn ..
I want is the message every minute or second...
[Sorry for My english Undecided]


Code:
using Addon;
using System.Threading;

namespace iPrintLn
{
    public class iPrintLn : CPlugin
    {
    
        public override void OnServerLoad()
        {
            ServerPrint("iPrintLntest");
        }

        public override void OnPlayerConnect(ServerClient Client)
        {
            iPrintLn("message", null);

        }

        private void iPrintLnBold(string p, bool p_2)
        {

        }

        private bool player { get; set; }

      
    }

}
  Reply
#2
http://msdn.microsoft.com/en-us/library/....110).aspx
  Reply
#3
(12-17-2012, 15:31)JariZ Wrote: http://msdn.microsoft.com/en-us/library/....110).aspx

Aaaaaaand again Threads....
Use Stopwatches:
http://msdn.microsoft.com/en-us/library/...watch.aspx
[Image: compiling.png][Image: aLKA8og_460sa.gif]
  Reply
#4
Timer works fine and you don't have to work with threads yourself....
  Reply
#5
Se precisar de ajuda cara me add...

English:

If you need help add me...

Thanks Barata...
Don't worry if things aren't the way you planned, in the end everything will solve itself...
  Reply
#6
(12-18-2012, 06:24)barata Wrote: Se precisar de ajuda cara me add...

English:

If you need help add me...

Thanks Barata...

looks good this way?
forgiveness is that I am new to visual basic plugins ...


Code:
using Addon;
using System.Threading;
using System.Runtime.InteropServices;
using System.Threading;
using System;
using System.Diagnostics;

namespace iPrintLn
{
    public class iPrintLn : CPlugin
    {


        static void Main(string[] args)
        {
            Stopwatch stopWatch = new Stopwatch();
            stopWatch.Start();
            Thread.Sleep(10000);
            stopWatch.Stop();
            // Get the elapsed time as a TimeSpan value.
            TimeSpan ts = stopWatch.Elapsed;

            // Format and display the TimeSpan value.
            string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                ts.Hours, ts.Minutes, ts.Seconds,
                ts.Milliseconds / 10);
            Console.WriteLine("RunTime " + elapsedTime);
        
        }

        public override void OnServerFrame()
        {
          iPrintLn("message", null);
        
        }  

     }

}
  Reply
#7
CSHARP Code
  1. using System;
  2. using System.Collections.Generic;
  3. using Addon;
  4. using System.Collections;
  5.  
  6. namespace mes
  7. {
  8. public class mes : CPlugin
  9. {
  10. int Interval;
  11.  
  12. public override void OnMapChange()
  13. {
  14. Interval = 0;
  15. }
  16.  
  17. public override void OnFastRestart()
  18. {
  19. Interval = 0;
  20. }
  21.  
  22. public override void OnServerFrame()
  23. {
  24. List<ServerClient> clients;
  25. try
  26. {
  27. clients = GetClients();
  28. if (clients != null)
  29. {
  30. foreach (ServerClient client in GetClients())
  31. {
  32. if (client.Other.isAlive == true &&
  33. client.ConnectionState != ConnectionStates.MapLoading &&
  34. client.ConnectionState != ConnectionStates.Connecting &&
  35. client.ConnectionState != ConnectionStates.Zombie)
  36. {
  37. if (Interval <= 0)
  38. {
  39. iPrintLn("message", null);
  40. Interval = 60 * 60; // period 60 sec
  41. }
  42.  
  43. }
  44. }
  45. }
  46. }
  47. catch (Exception e)
  48. {
  49. ServerPrint("Error in mes plugin: \n" +
  50. e.Message + "\n" +
  51. e.StackTrace + "\n" +
  52. e.Source + "\n" +
  53. e.InnerException + "\n" +
  54. e.HelpLink);
  55. }
  56.  
  57. if (Interval > 0)
  58. Interval--;
  59.  
  60. }
  61. }
  62. }
  Reply
#8
(12-19-2012, 07:48)XxBRxX Wrote:
(12-18-2012, 06:24)barata Wrote: Se precisar de ajuda cara me add...

English:

If you need help add me...

Thanks Barata...

looks good this way?
forgiveness is that I am new to visual basic plugins ...


Code:
using Addon;
using System.Threading;
using System.Runtime.InteropServices;
using System.Threading;
using System;
using System.Diagnostics;

namespace iPrintLn
{
    public class iPrintLn : CPlugin
    {


        static void Main(string[] args)
        {
            Stopwatch stopWatch = new Stopwatch();
            stopWatch.Start();
            Thread.Sleep(10000);
            stopWatch.Stop();
            // Get the elapsed time as a TimeSpan value.
            TimeSpan ts = stopWatch.Elapsed;

            // Format and display the TimeSpan value.
            string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                ts.Hours, ts.Minutes, ts.Seconds,
                ts.Milliseconds / 10);
            Console.WriteLine("RunTime " + elapsedTime);
        
        }

        public override void OnServerFrame()
        {
          iPrintLn("message", null);
        
        }  

     }

}

In Librarys there are no Main.
And this is C# not VB Wink

Look into my sourcecode from EpicZombie in the "main"(dont know how i named it) class in OnServerFrame you can see the usage of StopWatch.


@Zoomby:
Do you even know what your code does? You know that OnServerFrame isn't called in constant times. -> It depends on your CPU how hast it can call OnServerFrame
[Image: compiling.png][Image: aLKA8og_460sa.gif]
  Reply
#9
This works for me perfectly. I checked out. I cited an example. To use it or not, decide for yourself.
  Reply
#10
(12-19-2012, 18:45)[Z00MBY] Alex Wrote: This works for me perfectly. I checked out. I cited an example. To use it or not, decide for yourself.

hey guys.
I pull some lines that gave me error.
tego version of teknogods v206..
I'll see if it works that way.

Code:
using System;
using System.Collections.Generic;
using Addon;
using System.Collections;

namespace mes
{
    public class mes : CPlugin
    {
        int Interval;

        public override void OnMapChange()
        {
            Interval = 0;
        }

        public override void OnFastRestart()
        {
            Interval = 0;
        }

        public override void OnServerFrame()
        {
            List<ServerClient> clients;
            try
            {
                clients = GetClients();
                if (clients != null)
                {
                    foreach (ServerClient client in GetClients())
                    {

                        {
                            if (Interval <= 0)
                            {
                                iPrintLn("message", null);
                                Interval = 60 * 60; // period 60 sec
                            }

                        }
                    }
                }
            }
            catch (Exception e)
            {
                ServerPrint("Error in mes plugin: \n" +
                             e.Message + "\n" +
                             e.StackTrace + "\n" +
                             e.Source + "\n" +
                             e.InnerException + "\n" +
                             e.HelpLink);
            }

            if (Interval > 0)
                Interval--;

        }
    }
}
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Request] Request for Assistance with Modding COD: BO using Mod Tools one1lion 9 6,047 09-17-2013, 21:04
Last Post: one1lion
  [Request] Airdrop Heaven mod The_Reaper_1 0 2,292 09-10-2013, 14:13
Last Post: The_Reaper_1
  [Request] Request for !afk and !balance plugins. UlTiiMaTuM 3 3,220 09-10-2013, 02:13
Last Post: UlTiiMaTuM
Information [Request] Need Time Plugin and Server Msg Plugin sylvester123 14 8,654 07-26-2013, 08:07
Last Post: sylvester123
  4D1 Extend Feeding Time Tacticalicious 1 2,407 07-02-2013, 20:59
Last Post: surtek
  [REQUEST] Antinoob mod sleepunknot 3 2,838 05-15-2013, 20:10
Last Post: sleepunknot
Tongue What are you doing in free time? Nekochan 16 7,915 05-05-2013, 08:25
Last Post: Pozzuh
  Moab and server request CHRISLUVMSR 6 4,243 04-17-2013, 18:28
Last Post: X-Track
  [Request] Teknogods Expert's Classes 1.5 request The6thMessenger 0 2,250 04-13-2013, 08:22
Last Post: The6thMessenger
  [Request] Automatic save Rendflex 10 5,733 04-06-2013, 21:51
Last Post: barata

Forum Jump:


Users browsing this thread: 1 Guest(s)