Some questions...
#1

1. If i kill SetTimerEx, but that timer is not started, my server will crash or no?
2. What in the script wants most RAM and CPU? Ex: Commands, timers, objects, vehicles or anything else...
3. Is there a chance to crash my server if i attach objects to players and vehicles?(I attach too much objects on vehicles and players in jobs)
4. Foreach or for(new i = 0; i <= MAX_PLAYERS; i++)?
5. 5 timers with 200 lines or 1 timer with 1000 lines?? (What is better? Can i optimize script if i cut any timer in 4-5 timers?)
6. Can i optimize script if i use SCMF instead formating string?
7. Is it better if i create objects in include?(i creating objects in 10 000 lines) Will script work faster when have less lines?

Thank you!
Reply
#2

Quote:
Originally Posted by DusanInfinity
Посмотреть сообщение
1. If i kill SetTimerEx, but that timer is not started, my server will crash or no?
2. What in the script wants most RAM and CPU? Ex: Commands, timers, objects, vehicles or anything else...
3. Is there a chance to crash my server if i attach objects to players and vehicles?(I attach too much objects on vehicles and players in jobs)
4. Foreach or for(new i = 0; i <= MAX_PLAYERS; i++)?
5. 5 timers with 200 lines or 1 timer with 1000 lines?? (What is better? Can i optimize script if i cut any timer in 4-5 timers?)
6. Can i optimize script if i use SCMF instead formating string?
7. Is it better if i create objects in include?(i creating objects in 10 000 lines) Will script work faster when have less lines?

Thank you!
1.It'll probably crash the server.
2.Timers eats most of your RAM and CPU if you have too many of them and use them in OnPlayerUpdate.
3.It won't crash your server depending on your CPU and RAM but if the player has a bad computer he will probably crash.
4.There is really no difference between Foreach and the traditional way, i'd prefer the traditional way.
5.1 timer with 1000 lines, using timers constantly will consume your performance, i'd recommend using one timer and attach multiple variables into it.
6.natives are always faster.
7.It'll work faster if you have a cheap provider, but there will be no difference if you use includes as it still reads what's inside of it.
Reply
#3

Is there any code to check is timer active? I have that timer for all players(new JumpReset[MAX_PLAYERS]
If the timer is active, JumpReset wont be 0?
Reply
#4

1. It will not crash the server, I always kill a timer (even if it is not running yet) before setting it to execute.
2. It really depends on how you use each aspect. The less to execute in every tick, the less drop seen.
3. Not going to happen, there are limits - yet, it isn't probable (theoretically).
4. A better question would be "Foreach or "new pool = GetPlayerPoolSize(); for(new i = 0; i <= pool; i ++)"?". If you know how they both work, then you would get your answer. Foreach loops through all the connected players and GetPlayerPoolSize() loops goes through all the players till the player with the highest id (0, 1, 2, 5), up to 5 even if 3 and 4 isn't online. So technically, foreach.
5. I would personally make individual timers.
6. It's technically the same thing - it's nanoseconds (or the same), you aren't going to get any benefit out of it.
7. Think of includes as a copy and paste feature, it will just paste the code into your script. No, it won't. Your script is basically one line.

Quote:
Originally Posted by DusanInfinity
Посмотреть сообщение
Is there any code to check is timer active? I have that timer for all players(new JumpReset[MAX_PLAYERS]
If the timer is active, JumpReset wont be 0?
Use YSF, even though I wouldn't. Nor do I know why you would want to do that, if you knew what you are exactly doing within your script.
Reply
#5

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Use YSF, even though I wouldn't. Nor do I know why you would want to do that, if you knew what you are exactly doing within your script.
Because this guy tell me before you that killing non-active timer will crash server...
Reply
#6

Quote:
Originally Posted by DusanInfinity
Посмотреть сообщение
Because this guy tell me before you that killing non-active timer will crash server...
Did you even try it? Make a command that kills an inactive timer and see for yourself.
Reply
#7

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Did you even try it? Make a command that kills an inactive timer and see for yourself.
Yeah i test it on home server, but i don't know what will happen when 50-60 players killtimer...
Reply
#8

1. Killing a timer that does not exist does nothing. But bear in mind that timer ids start at 0 so timer variables should be initialized with an invalid value (usually -1) and set to that variable again once the timer is killed.
2. There is no definitive answer. A script rarely goes over more than a few dozen megabytes. A MAX_PLAYER (1000 slots) array is merely 4 kilobytes in size. This shouldn't be a factor.
3. Don't know. Never tested.
4. Foreach.
5. Multiple timers. The faster a timer is done processing its code the faster the server can go on with other things.
6. I assume "SCMF" is some lazy ass macro way of sending a formatted client message which means it still relies on format(). Ergo, there is no difference except that the macro will severely slow your compile time.
7. An include is nothing more than copy-paste. In the end it's just the same old script and it changes absolutely nothing.
Reply
#9

Well, i create this:
Код:
stock KillTimer_H(timerid)
{
	if(timerid == -1) return 1;
	return KillTimer(timerid);
}
Its good?
Reply
#10

pawn Код:
4. Foreach or for(new i = 0; i <= MAX_PLAYERS; i++)?
Personally I find foreach quite easier to use anytime, less time to type and such, the code looks better for me, efficiant wise I think its preety same. I'd go with foreach anytime
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)