Raised This Month: $ Target: $400
 0% 

Most efficiently get all user ids


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Misery
Senior Member
Join Date: Dec 2010
Old 12-30-2010 , 05:12   Most efficiently get all user ids
Reply With Quote #1

Hi,

I'd like to know how I can fill an array[32] containing valid user ids.
Since this code is to be implemented in a callback initialized using set_task(), I need the most efficient way to do this.

Would it be faster to... use get_players(), get the highest user ID. On each disconnect, update the table instead of re-using get_players() to re-fill it, using a list of empty indexes (lookup table). On each player connect, consult the lookup table, fill the element corresponding to the retrieved index, delete the index, go to next.

Or... simply use get_players() on each iteration?

Please advise! Thanks!

Misery
Misery is offline
Misery
Senior Member
Join Date: Dec 2010
Old 12-30-2010 , 05:51   Re: Most efficiently get all user ids
Reply With Quote #2

I'll add a few more details...
The function passed to set_task() will loop in the players[32] array.
Each iteration, it'll look wether or not the user id retrieved belongs to CT.
If so, a command will be executed on the CT player, else nothing will be done.
But the user id retrieved must *not* have executed the task function : if a player is in CTs and have executed it, nothing will be done for him.

This is why I tought it would be advantageous to update manually the array on each player disconnect/connect, intead of re-invoking get_players(), which could also mess up organization of the array on each iteration - i.e. a user id moved dues to a random sorting. If get_players() do a sort, then this would be different...

Thanks!
Misery is offline
Misery
Senior Member
Join Date: Dec 2010
Old 12-30-2010 , 06:56   Re: Most efficiently get all user ids
Reply With Quote #3

Nevermind, this post should just get trashed.
Misery is offline
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 02:06.


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