AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Randomly Select Cts (https://forums.alliedmods.net/showthread.php?t=204592)

r0ck 01-01-2013 08:20

Randomly Select Cts
 
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 )

ANTICHRISTUS 01-01-2013 13:03

Re: Randomly Select Cts
 
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.

r0ck 01-02-2013 02:54

Re: Randomly Select Cts
 
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)
    }



All times are GMT -4. The time now is 13:31.

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