Author Topic: New Timer System by Fuzzie  (Read 6460 times)

0 Members and 1 Guest are viewing this topic.

Offline Fuzzy168

  • VC:MP Veteran
  • *****
  • Posts: 729
  • Programming since 2011
    • View Profile
New Timer System by Fuzzie
« on: July 25, 2013, 11:19:12 am »
What's new with this timing system?
Nothing...

How is this timer different from the SetTimer() function?
The only differences is it isn't hardcoded or made into a single function like SetTimer() does.

Can this timer help cover up the holes the SetTimer() function has left? The fact it doesn't have any arguments argument?
That's exactly what it does.

Is this new timer system efficient?
Doubtful, but I think it is accurate enough. I'll run some test and upload screenshots.

I want to try this. Where can I get it?
Over here.
[pawn]#include <time>[/pawn]
[pawn]        new interval = 1000; /* Miliseconds */
   new repeating = 5; /* Number of times to repeat */
   new isDone = 0;
   new initTime = tickcount();
   new repeated = 0;
   while( isDone == 0 )
   {
       new lastCheckedTime = tickcount();
       if( lastCheckedTime - initTime >= interval )
       {
           initTime = tickcount();

           //What you this timer to do when an interval has passed.

           repeated++;
           if( repeated == repeating )
           {
               isDone = 1;
           }
       }
   }
   return 1;[/pawn]

How do I use this in a function?
Take this sample code as an example.
[pawn]#include <a_vcmp>
#include <time>

forward TestFunction( const argument1[], const argument2[], const argument3[] );

main()
{
   print( "TimerTest lock and loaded..." );
}

public OnGameModeInit()
{
   TestFunction( "I'm 1st.", "Why am I always 2nd", "Not 3rd again.." );
   return 1;
}

public TestFunction( const argument1[], const  argument2[], const argument3[] )
{
   new interval = 1000; /* Miliseconds */
   new repeating = 5; /* Number of times to repeat */
   new isDone = 0;
   new initTime = tickcount();
   new repeated = 0;
   while( isDone == 0 )
   {
       new lastCheckedTime = tickcount();
       if( lastCheckedTime - initTime >= interval )
       {
           initTime = tickcount();
          
           //What you this timer to do when an interval has passed.
           print( argument1 );
           print( argument2 );
           print( argument3 );
          
           repeated++;
           if( repeated == repeating )
           {
               isDone = 1;
           }
       }
   }
   return 1;
}[/pawn]

What would that code return?
This is what that code will return.
Code: [Select]
I'm 1st.
Why am I always 2nd
Not 3rd again..
I'm 1st.
Why am I always 2nd
Not 3rd again..
I'm 1st.
Why am I always 2nd
Not 3rd again..
I'm 1st.
Why am I always 2nd
Not 3rd again..
I'm 1st.
Why am I always 2nd
Not 3rd again..

Credits:Fuzzie(Me)
I'm beginning to feel like a Lag God, Lag God

Offline aledark24

  • Made Man
  • ***
  • Posts: 206
  • I am a scripter and you have celous of me....so you crashed my servers
    • View Profile
Re: New Timer System by Fuzzie
« Reply #1 on: July 25, 2013, 08:46:20 pm »
 :o wtf is this... xD so many lines... i choose the old settimer xD but if you say if work "nice work"
I am a great scripter and you are celous of my works
.....

Vice City Life Multiplayer By Saint

Offline Fuzzy168

  • VC:MP Veteran
  • *****
  • Posts: 729
  • Programming since 2011
    • View Profile
Re: New Timer System by Fuzzie
« Reply #2 on: July 26, 2013, 05:55:13 am »
:o wtf is this... xD so many lines... i choose the old settimer xD but if you say if work "nice work"
You are free to use the SetTimer() in the a_vcmp.inc. This system is for those who want to use timer with arguments. For example, a healing command/function.
I'm beginning to feel like a Lag God, Lag God

Offline Doom

  • Made Man
  • ***
  • Posts: 105
    • View Profile
Re: New Timer System by Fuzzie
« Reply #3 on: July 29, 2013, 06:30:00 pm »
Looks pretty decent to me. Gotta test it out with different things.

Offline Fuzzy168

  • VC:MP Veteran
  • *****
  • Posts: 729
  • Programming since 2011
    • View Profile
Re: New Timer System by Fuzzie
« Reply #4 on: July 30, 2013, 07:55:31 am »
Looks pretty decent to me. Gotta test it out with different things.
Thanks.. I can't really test it with people because Pawn servers just don't show up in other's Internet List. :/
I'm beginning to feel like a Lag God, Lag God

Offline Aldo

  • Wiseguy
  • **
  • Posts: 52
    • View Profile
Re: New Timer System by Fuzzie
« Reply #5 on: August 01, 2013, 04:13:19 pm »
What the heck is this? This is just an overly complex way of passing variables thru timers, but this isn't even a timer this is a repeating loop.

Offline Fuzzy168

  • VC:MP Veteran
  • *****
  • Posts: 729
  • Programming since 2011
    • View Profile
Re: New Timer System by Fuzzie
« Reply #6 on: August 02, 2013, 08:08:19 am »
What the heck is this? This is just an overly complex way of passing variables thru timers, but this isn't even a timer this is a repeating loop.
I think I've should have called it Timing system. I've tried making a single function but it doesn't work. Using this script once or twice wouldn't really burden much..
I'm beginning to feel like a Lag God, Lag God

Offline Aldo

  • Wiseguy
  • **
  • Posts: 52
    • View Profile
Re: New Timer System by Fuzzie
« Reply #7 on: August 04, 2013, 02:15:09 pm »
I think I've should have called it Timing system. I've tried making a single function but it doesn't work. Using this script once or twice wouldn't really burden much..

Not my point, the point is if you are going to release something for the public to use make it as simple as possible because not everyone is as good at something as you are.

Offline Fuzzy168

  • VC:MP Veteran
  • *****
  • Posts: 729
  • Programming since 2011
    • View Profile
Re: New Timer System by Fuzzie
« Reply #8 on: August 05, 2013, 08:06:44 am »
I think I've should have called it Timing system. I've tried making a single function but it doesn't work. Using this script once or twice wouldn't really burden much..

Not my point, the point is if you are going to release something for the public to use make it as simple as possible because not everyone is as good at something as you are.
This is the simplest I could have done.  :-\
I'm beginning to feel like a Lag God, Lag God

Offline NeskWriter

  • Crime Boss
  • ****
  • Posts: 355
    • View Profile
Re: New Timer System by Fuzzie
« Reply #9 on: August 08, 2013, 05:25:54 pm »
I dunno how does it work, but it sounds goed as for me :)


-Funniest quotes-

Quote from: asad3man
i cant able to understand