Raised This Month: $ Target: $400
 0% 

Random Players Selection crashing


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
r0ck
Senior Member
Join Date: Jun 2011
Location: India
Old 11-07-2011 , 06:56   Random Players Selection crashing
Reply With Quote #1

this code is crashing on (round end) when players are 20+ in ct team ..
tested the mod on 20 slot server works perfectly without crash for hours but on 32 it crashes..... like i said people in ct are 20+ .
it crashes without any logs on round end.

i took help from this topic Random Selection tutorial by Exolent
first i tried the first one without array but it crashed when 15+ then i tried the 2nd one...

my round end code :- [cant show whole due to pvt but problem with random selection only]
PHP Code:
public RoundEndEvent()
{
    
gp_TNextRound 0
    
new total, Array:players ArrayCreate(132)
    
    for(new 
1<= g_iMaxPlayersn++)
    {
        if(
is_user_connected(n) && cs_get_user_team(n) == CS_TEAM_CT)
        {
            if(
g_TNextPlayer[n])
            {
                
gp_TNextRound++
            }
            else
            {
                
ArrayPushCell(playersn)
                
total++
            }
        }
    }
            
    new 
g_TAmount = (TAllowed() - gp_TNextRound)
    
    if(
g_TAmount 0)
    {
        new 
countplayerrand
        
do
        {
            
rand random(total)
            
player ArrayGetCell(playersrand)
            
g_TNextPlayer[player] = true
            count
++
            
ArrayDeleteItem(playersrand)
            
total--
        }
        while(
count g_TAmount)
    }

__________________
Preparing to release my plugins..
r0ck is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 11-09-2011 , 16:56   Re: Random Players Selection crashing
Reply With Quote #2

It may be because the amount of terrorists in the server is less than that of g_TAmount.

Plus, a note of advice: Don't tag variables with g_ if you declare them within the function. That makes them a local variable, not a global variable, which "g_" indicates. It makes it easier to understand and read if you tag it properly.
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please

Last edited by nikhilgupta345; 11-09-2011 at 16:57.
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
r0ck
Senior Member
Join Date: Jun 2011
Location: India
Old 11-12-2011 , 12:11   Re: Random Players Selection crashing
Reply With Quote #3

kk ill see but i dont think u have read my whole code and 1 more think g_Tamount cant be more than cts that are selected for random selection.

thanks for suggestion
__________________
Preparing to release my plugins..
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 14:20.


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