Raised This Month: $51 Target: $400
 12% 

Get random players ( server crash )


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bos93
Veteran Member
Join Date: Jul 2010
Old 01-17-2013 , 17:14   Get random players ( server crash )
Reply With Quote #1

PHP Code:
    int aPlayers[32];
    
int iNum 0;

    for (
int i 1<= gpGlobals->maxClients; ++i)
    {
        
edict_t *pPlayer INDEXENT);

        if( 
IS_VALID_ENTpPlayer ) )
        {
            if (!
IsAlivepPlayer ) )
                continue;
    
            
aPlayers[iNum++] = i;
        }
    }

    if( !
iNum) return;

    
int iPlayer aPlayers[rand() % iNum];

    
UTIL_ColorChatINDEXENTiPlayer ) , "Index %d"iPlayer); 
PHP Code:
inline bool IsAlive(edict_t *pEdict)
{
    return ((
pEdict->v.deadflag == DEAD_NO) && (pEdict->v.health 0));

PHP Code:
bool IS_VALID_ENT(const edict_tent)
{
    if(
FNullEnt(ent))
    {
        return 
false;
    }

    
int iEnt ENTINDEX(ent);
    if (
iEnt || iEnt gpGlobals->maxEntities
        return 
false;

    if (
iEnt <= gpGlobals->maxClients)
    {
        if (!
IS_PLAYER_VALID[iEnt]) 
        {
            return 
false;
        }
    }

    return 
true;

IS_PLAYER_VALID - Connect true \ Disconnect false

It works, but the server can crash, what's the problem?
__________________

Last edited by Bos93; 01-17-2013 at 17:16.
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
Bos93
Veteran Member
Join Date: Jul 2010
Old 01-17-2013 , 23:37   Re: Get random players ( server crash )
Reply With Quote #2

The problem was In another function
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
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 18:21.


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