Raised This Month: $ Target: $400
 0% 

set_task & player loop.


Post New Thread Reply   
 
Thread Tools Display Modes
vamppa
Senior Member
Join Date: Apr 2010
Location: The Netherlands
Old 06-13-2014 , 01:47   Re: set_task & player loop.
Reply With Quote #11

What the code does is query_client_cvar.
Previously I had done this through individual tasks.
Until idea required code to check a global variable.

Quote:
Originally Posted by nextra
If you install individual tasks depending on different events they will usually end up offset from each other. So task for player 1 may run at 10, 30, 50 seconds and task for player 2 at 20, 40, 60.
previous reasoning for individual tasks was exactly same thought process as you mentioned here :- ) for reasons of offset. something this small would be an optimization gain compared to global set_task and looping through method.
Another optimization was to use a random frequency that floats between lets say 15 and 35 seconds.
To maintain a consistency threat for players that would override said legal cvar value. this allowed to go to a lower frequency. bonus was through the use of random timer it increased likely hood of individual set_task offset in scenarios of crowded server(16 players) ---> map change ----> offset. (is only a small bonus).
now this was fine and dandy till I had to check for pcvar which later turned into global variable that was checked with If statements which got changed into usage of a switch.
In the process I had already changed code to a global set_task and looping through all players method.
thought to be the best way for the job as code would need to check the global variable only once each task cycle.

Im probably going to test it as I always do but im wondering what is more efficient.

Last edited by vamppa; 06-13-2014 at 02:15.
vamppa is offline
vamppa
Senior Member
Join Date: Apr 2010
Location: The Netherlands
Old 06-13-2014 , 02:17   Re: set_task & player loop.
Reply With Quote #12

The decision is basically: Is a frequent global switch worse then looping through players on a lower frequency?
The question: How would you check one client cvar on a low frequency if idea required you to use a "preferable as frequent" global switch?
A) "would you use a global switch on individual task if it meant no loop through get_players method?"
B) "would you use a global set_task to check for global switch then loop through all players?"
C) Else

Last edited by vamppa; 06-13-2014 at 02:30.
vamppa is offline
Fr33m@n
Veteran Member
Join Date: May 2008
Location: France Marne
Old 06-13-2014 , 05:26   Re: set_task & player loop.
Reply With Quote #13

running a looping global set_task will not ruin your CPU as some people said...
For me it's the more simple way you can do what you want.
Difference should be trivial as said previously.

Note that a looping global set_task (in plugin_init) take less CPU than a entity think loop. (i monitored that with profiler before steamcmd update).
Fr33m@n is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 06-13-2014 , 06:11   Re: set_task & player loop.
Reply With Quote #14

As I've mentioned previously: In terms of performance you are way, way overthinking this.

Looping through all players with get_players is acceptable even in a global task that runs at the fastest possible speed (0.1 delay, 10 times per second). Running 32 tasks that do nothing because a global switch is disabled is equally not going to hurt your performance.

Running a global task or smaller offset tasks is not an issue of performance for the most part. The decision is based on wether you want individual tasks that can diverge or if you want a global checkpoint where everyone is checked. In your case where you want to check through client's cvars I would likely use a global task because there is little benefit of having individual tasks.

When using individual tasks I would consider it plain good style to disable the client tasks when the global switch is turned off, and restarting them when the global switch is turned back on.

But please, please understand this is not a performance issue in your case. This is the kind of premature optimization that will hurt your output. You are thinking about trivial performance differences in a case where you absolutely don't have to. If you need individual tasks to get the behavior you want - use them. It won't matter.
__________________
In Flames we trust!
Nextra is offline
vamppa
Senior Member
Join Date: Apr 2010
Location: The Netherlands
Old 06-13-2014 , 07:26   Re: set_task & player loop.
Reply With Quote #15

Ok thanks.
vamppa is offline
vamppa
Senior Member
Join Date: Apr 2010
Location: The Netherlands
Old 06-13-2014 , 07:37   Re: set_task & player loop.
Reply With Quote #16

To be absolutely certain looping through all players with get_players in a global set_task to check a cvar value of players would not cause a sudden dip in performance?
with a lot of players inside the server this would not cause the server to miss predict hit registration?
Lets say the servers fps would dip from 1000 to 768. wouldn't the instability effect shot registration lets say from a high fire rate weapon ?

I wonder how well people have tested this and im not talking about some noobs that cant tell much difference, or people who just whine.

Last edited by vamppa; 06-13-2014 at 07:52.
vamppa is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-13-2014 , 08:21   Re: set_task & player loop.
Reply With Quote #17

Nextra has already gave you a complete answer, I think it's time now you stop insisting, overthinking and worrying about trivial matter.

On a side note, please learn to use the EDIT button. Don't double-post. Thanks.
__________________
Arkshine is offline
vamppa
Senior Member
Join Date: Apr 2010
Location: The Netherlands
Old 06-13-2014 , 09:29   Re: set_task & player loop.
Reply With Quote #18

alright was looking to be certain it doesn't effect shot registration so I can inform other players about it.
Im learning afterall.

Thanks everyone for replying.
vamppa is offline
Old 06-13-2014, 10:19
Arkshine
This message has been deleted by Arkshine. Reason: No point
Old 06-14-2014, 10:48
vamppa
This message has been deleted by Arkshine. Reason: Is there a p๔int to answer to deleted post you don't even know the content?
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:36.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode