Raised This Month: $ Target: $400
 0% 

Solved Questions about optimization and cs_set_user_team()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-02-2020 , 21:47   Re: Questions about optimization and cs_set_user_team()
Reply With Quote #1

1. Correct, you are only accessing players[] once per pass so it is fine.

2. Yeah, see the below code.

For your last question, it's called Hungarian notation. It helps the developer and/or person looking at the code what type of data is held in the variable. sz being null-terminated string.

PHP Code:
    new iPlayer CsTeams:csCurrentTeam csTeamCountCsTeams ];

    for ( 
numberOfPlayers i++ ) 
    {
        
iPlayer players];
        
csCurrentTeam cs_get_user_teamiPlayer );
        
        switch ( 
CsTeams:random_num_:CS_TEAM_T _:CS_TEAM_CT ) ) 
        {
            case 
CS_TEAM_T
            {
                if ( 
csTeamCountCS_TEAM_T ] < maxPlayersPerTeam )
                {
                    if ( 
csCurrentTeam != CS_TEAM_T 
                    {
                        
cs_set_user_teamiPlayer CS_TEAM_T)
                    } 
                    
csTeamCountCS_TEAM_T ]++
                }
                else 
                {
                    
cs_set_user_teamiPlayer CS_TEAM_CT)
                    
csTeamCountCS_TEAM_CT ]++
                }
            }
            case 
CS_TEAM_CT
            {
                if ( 
csTeamCountCS_TEAM_CT ] < maxPlayersPerTeam 
                {
                    if ( 
csCurrentTeam != CS_TEAM_CT )
                    {
                        
cs_set_user_teamiPlayer CS_TEAM_CT)
                    }
                    
csTeamCountCS_TEAM_CT ]++
                } 
                else 
                {
                    
cs_set_user_teamiPlayer CS_TEAM_T)
                    
csTeamCountCS_TEAM_T ]++
                }
            }
        }
    } 
__________________

Last edited by Bugsy; 06-02-2020 at 22:54.
Bugsy 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 16:56.


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