What's better of these two?
#1

What's the best option to make timers from these two options.
Multiple Timers

A
PHP Code:
new stime;
forward Time();
public 
OnGameModeInit()
{
      
SetTimer("Time",1000,true);
      return 
1;
}
public 
Time()
{
       
// some code
      
if(stime%120==0// Do some code each 2 minutes
      
{
      }
      if(
stime%1800 == 0// Do some code each 1800 seconds
      
{
      }
      
stime++;
      return 
1;

Or

B
PHP Code:
public OnGameModeInit()
{
      
SetTimer("Time",1000,true);
      
SetTimer("Time1",120000,true);
      
SetTimer("Time2"1800000true);
      return 
1;
}
forward Time();
forward Time1();
forward Time2();
public 
Time()
{
}
public 
Time1()
{
}
public 
Time2()
{

What's best? A or B
Reply
#2

I think A, because it's a more optimized option.
Reply
#3

Quote:
Originally Posted by DelK
View Post
I think A, because it's a more optimized option.
How is more code more optimised than less code? B is better - the server works out who to call not you
Reply
#4

(A) Is better. I'm using the same method since I found it out on my own. Oh and also it's easier to find a specific code part in one timer rather than looking up until you find what you were looking for.

Code:
if(++stime%120==0) { 

} 
if(stime%1800==0) { 

}
Reply
#5

Quote:
Originally Posted by OneDay
View Post
How is more code more optimised than less code? B is better - the server works out who to call not you
"How is more code more optimised than less code?"
Less code doesnt mean that it'll run faster. The code amount doesn't matter if you have no clue what you are doing and you use old methods which aren't a thing anymore. Number of lines never matter. Obviously writing a system on the lowest lines of number possible is always a good thing for better readibility, but thats it. Run some tests.

Also having less timers than more timers is a good thing.
Take timers are cron jobs. If you can put code into one cron job instead of making tons of them, why wouldn't you do it?
Reply
#6

Quote:
Originally Posted by whadez
View Post
"How is more code more optimised than less code?"
Less code doesnt mean that it'll run faster. The code amount doesn't matter if you have no clue what you are doing and you use old methods which aren't a thing anymore. Number of lines never matter. Obviously writing a system on the lowest lines of number possible is always a good thing for better readibility, but thats it. Run some tests.

Also having less timers than more timers is a good thing.
Take timers are cron jobs. If you can put code into one cron job instead of making tons of them, why wouldn't you do it?
Well explained!
I'm gonna go with A.
Reply
#7

Timer's benchmark
https://gist.github.com/Southclaws/7...8e3b67c632483d
Reply
#8

More timers more lag, Less timers less lag A is better.
Reply
#9

Quote:
Originally Posted by KaryM4Life
View Post
More timers more lag, Less timers less lag A is better.
by what logic is this being said xd?

how they cause lag?
Reply
#10

Quote:
Originally Posted by jlalt
View Post
by what logic is this being said xd?

how they cause lag?
Another scripter told me that :c
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)