Raised This Month: $ Target: $400
 0% 

get_players or global var


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
vitorrossi
Senior Member
Join Date: Apr 2012
Location: NY, USA
Old 05-13-2015 , 18:46   get_players or global var
Reply With Quote #1

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:
g_iConnected
g_iPlayers
[32
and storing and deleting players as

PHP Code:
client_putinserver(id){
    
g_iPlayers[g_iConnected++]
}

client_disconnect(id){
    for(new 
0g_iConnectedi++)
        if(
g_iPlayers[i] == id)
            
g_iPlayers[i] = g_iPlayers[--g_iConnected]
            break

would be a good idea to avoid calling get_players and looping so often. In this way I would also store team counts and alive counts in global vars.

What would be better?

Last edited by vitorrossi; 05-13-2015 at 18:47.
vitorrossi is offline
 



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 18:41.


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