Vice City Multiplayer

VC:MP 0.3 => mIRC/pawn Scripting => Snippet Showroom => Topic started by: Fuzzy168 on July 25, 2013, 11:19:12 am

Title: New Timer System by Fuzzie
Post by: Fuzzy168 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)
Title: Re: New Timer System by Fuzzie
Post by: aledark24 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"
Title: Re: New Timer System by Fuzzie
Post by: Fuzzy168 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.
Title: Re: New Timer System by Fuzzie
Post by: Doom on July 29, 2013, 06:30:00 pm
Looks pretty decent to me. Gotta test it out with different things.
Title: Re: New Timer System by Fuzzie
Post by: Fuzzy168 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. :/
Title: Re: New Timer System by Fuzzie
Post by: Aldo 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.
Title: Re: New Timer System by Fuzzie
Post by: Fuzzy168 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..
Title: Re: New Timer System by Fuzzie
Post by: Aldo 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.
Title: Re: New Timer System by Fuzzie
Post by: Fuzzy168 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.  :-\
Title: Re: New Timer System by Fuzzie
Post by: NeskWriter on August 08, 2013, 05:25:54 pm
I dunno how does it work, but it sounds goed as for me :)