Raised This Month: $ Target: $400
 0% 

Randomly Select Cts


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
r0ck
Senior Member
Join Date: Jun 2011
Location: India
Old 01-02-2013 , 02:54   Re: Randomly Select Cts
Reply With Quote #3

I found the error at last sorry ....
The problem was models (cs_set_user_model crashing )

But with this code for random selection it sometimes show error......

Error Sometimes ( different values at different times) and it doesn't shuffle
and sometimes it shuffles without error

Quote:
Invalid cellvector handle provided (26:12:12) <----------------shows different values in log file
Displaying debug trace (plugin "TestPlugin2.amxx")
Run time error 10: native error (native "ArrayGetCell")
TestPlugin2.sma::LogEvent_RoundEnd (line 536)
Code
Code:
public LogEvent_RoundEnd() 
{ 
    g_TNextPlayerNo= 0 
    new total, Array:players = ArrayCreate(1, 32) 
     
    for(new n = 1; n <= g_iMaxPlayers; n++) 
    { 
        if(is_user_connected(n))
        {
            switch(cs_get_user_team(n))
            {
                case CS_TEAM_T: g_FirstSpawn[n] = true
                
                case CS_TEAM_CT:
                {
                    g_FirstSpawn[n] = true
                    
                    if(g_TNextPlayer[n])
                    {
                        g_TNextPlayerNo++
                    }
                    else
                    {
                        ArrayPushCell(players, n)
                        total++
                    }
                }
            }
        }
    } 
             
    new TAmount = (TAllowed() - g_TNextPlayerNo) 
     
    if(TAmount > 1) 
    { 
        new count, player, rand 
        do 
        { 
            rand = random(total) 
            player = ArrayGetCell(players, rand)  <--------- line 536
            g_TNextPlayer[player] = true 
            count++ 
            ArrayDeleteItem(players, rand) 
            total-- 
        } 
        while(count < TAmount && total > 1) 
    } 
}  
__________________
Preparing to release my plugins..

Last edited by r0ck; 01-02-2013 at 02:57.
r0ck 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 13:31.


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