Raised This Month: $ Target: $400
 0% 

Randomly Select Cts


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
r0ck
Senior Member
Join Date: Jun 2011
Location: India
Old 01-01-2013 , 08:20   Randomly Select Cts
Reply With Quote #1

I actually posted this long while ago (1 year) and someone gave me answere but its crashing server when there are 14-15+ Cts ........

I want a code in which at round end it randomly selects Cts so that they become Ts next round..
and it should in ratio (no of ts and cts) for example 1:2 = 1 T and 2 cts..

I have checked the server always crashes on round end when there are 14+ cts if you want i can post code being used (its also in last years post )
__________________
Preparing to release my plugins..
r0ck is offline
ANTICHRISTUS
kingdom of weird stuff
Join Date: Jun 2010
Location: My kingdom is not in thi
Old 01-01-2013 , 13:03   Re: Randomly Select Cts
Reply With Quote #2

if you don't find anything:
  • search in titles a plugin which select random players, I think that I see similar threads in the requests sub-forum.
  • use one of the Exolent[Jnr]'s plugins for the ratio.
__________________
ANTICHRISTUS is offline
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
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 13:31.


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