AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Random Players Selection crashing (https://forums.alliedmods.net/showthread.php?t=171529)

r0ck 11-07-2011 06:56

Random Players Selection crashing
 
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)
    }



nikhilgupta345 11-09-2011 16:56

Re: Random Players Selection crashing
 
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.

r0ck 11-12-2011 12:11

Re: Random Players Selection crashing
 
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 :D


All times are GMT -4. The time now is 14:20.

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