get_players or global var
I have a task that is called every 5 seconds, and in it I use get_players to retrieve all players, and loop through them to get team player counts and team alive counts since I've read that team flags on get_players can return false values sometimes.
I was wondering if having two global variables such as PHP Code:
PHP Code:
What would be better? |
Re: get_players or global var
Quote:
Explain exactly what you're trying to do. |
Re: get_players or global var
Your code makes absolutely no sense.
Why do you need this information so often? |
Re: get_players or global var
you might wanna be careful with approaches like these
first of all, that's pretty much a micro optimization (if it even is an optimization) also, there are certain cases in which a player leaves the server yet client_disconnect isn't called |
Re: get_players or global var
Quote:
|
Re: get_players or global var
Quote:
any type of client crash or connection loss (client_disconnect will eventually be called, but only after sv_timeout seconds) |
Re: get_players or global var
I'm not aware of any issues with get_players in the latest AMXX builds, especially not the "a" or "b" flag. Your approach only complicates the code and will not result in a performance benefit. Quite the opposite actually: get_players will in almost all cases be the fastest method for looping players, as it does all filtering at once (not that it matters).
If you truly wanted to cache data like team and alive counts you would need a very good reason for it. A task that runs every 5 seconds is definitely not one of those reasons. AddToFullPack and similar are pretty much the only use-cases that might qualify. Quote:
|
Re: get_players or global var
Quote:
Quote:
|
All times are GMT -4. The time now is 09:07. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.