AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   this is working or have another best method? (https://forums.alliedmods.net/showthread.php?t=162657)

^SmileY 07-21-2011 11:12

this is working or have another best method?
 
this is working or have another best method?

PHP Code:

public SwapTeams()
{
    for(new 
1<= g_iMaxPlayersi++)
    {
        if(
is_user_connected(i))
        {
            switch(
cs_get_user_team(i))
            {
                case 
CS_TEAM_T:
                {
                    new 
MODEL[4] = {1,5,6,7// CTs const models (See cstrike.inc)
                    
cs_set_user_team(i,CS_TEAM_CT,random_num(MODEL))
                }    
                case 
CS_TEAM_CT:
                {
                    new 
MODEL[4] = {2,3,4,8// TRs const models (See cstrike.inc)
                    
cs_set_user_team(i,CS_TEAM_T,random_num(MODEL))
                }
            }
        }
    }


Edit: Is a random_num

jim_yang 07-21-2011 11:16

Re: this is working or have another best method?
 
if server is 32 ppl and it's full. this method will crash your server cause it sent too many messages at one moment. better add a delay.

Exolent[jNr] 07-21-2011 13:07

Re: this is working or have another best method?
 
PHP Code:

new MODEL[4] = {/*values*/}
cs_set_user_team(i,CS_TEAM_/*T or CT*/,random_num(MODEL)) 

You are selecting the model incorrectly.
You have to get a random index of the array:

PHP Code:

new MODEL[4] = {/*values*/}
cs_set_user_team(i,CS_TEAM_/*T or CT*/,MODEL[random(sizeof(MODEL))]) 


^SmileY 07-22-2011 10:00

Re: this is working or have another best method?
 
thnks


All times are GMT -4. The time now is 01:08.

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