Raised This Month: $ Target: $400
 0% 

[Help] Understanding count in this code.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
4ever16
Veteran Member
Join Date: Apr 2015
Old 12-17-2015 , 21:59   [Help] Understanding count in this code.
Reply With Quote #1

Help me understand this not balanced count.
What this code does is that if some of the team has 2 teamates only it runs a command.
But i want to change it to 4 teamates so i changed all 2 numbers to 4 but it doesnt work.
Instead it says something wierd or nothing at all. Like -5 teamates.
So whats the mathematics of this code how does it count!?
How to make so it counts 4 teamates or less.


PHP Code:
if ( !g_CustomGame || true )
    {
        if (
g_IsStarted)
        {
            new 
numTnumCt;
        
            for ( new 
<= gMaxPlayers i++ )
            {
                if ( 
is_user_connected(i) )
                {
                    if ( 
cs_get_user_team(i) == CS_TEAM_T )
                        
numT++
                    else if ( 
cs_get_user_team(i) == CS_TEAM_CT )
                        
numCt++
                }
            }
            
            if ( 
numT <= (get_pcvar_num(cvar_pLeft)/2) - || numCt <= (get_pcvar_num(cvar_pLeft)/2) - )
            {
                if ( 
g_NotBalanced == )
                {
                    if (
numT numCt)
                        
client_print(0print_chat"%s %L"PREFIXLANG_PLAYER"T_AUTO_WON")
                    else if (
numCt numT)
                        
client_print(0print_chat"%s %L"PREFIXLANG_PLAYER"CT_AUTO_WON")
                    else if (
numCt == numT)
                        
client_print(0print_chat"%s %L"PREFIXLANG_PLAYER"NO_TEAM_WON")
                    
client_print(0print_chat"%s %L"PREFIXLANG_PLAYER"ENDING_MATCH")
                    new 
taskId scanForTaskID()
                    
set_task(5.0"EndMatch"taskId)
                    
g_NotBalanced 0
                
}

                else
                {
                    
client_print(0print_chat"%s %L"PREFIXLANG_PLAYER"NOT_ENOUGH_TEAMMATES", (get_pcvar_num(cvar_pLeft)/2) - 2)
                    
client_print(0print_chat"%s %L"PREFIXLANG_PLAYER"NOT_ENOUGH_TEAMMATES2"g_NotBalanced )
                    
g_NotBalanced++
                }
            }
            
            else
                
g_NotBalanced 0;
        }
    }
                            
    return 
PLUGIN_HANDLED 

Last edited by 4ever16; 12-17-2015 at 22:00.
4ever16 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-17-2015 , 22:19   Re: [Help] Understanding count in this code.
Reply With Quote #2

Don't just change random numbers without looking at the code yourself. Take time to look at the code and think logically about it. Even if you didn't know how to code, you could probably figure out the general idea of what is going on.

I would assume that you could change "g_NotBalanced == 2" to "g_NotBalanced == 4". I would also assume that you need to change the cvar value. If that doesn't do it, you would need to attach the plugin because we have no idea of the context of the code and especially the global variables.
__________________

Last edited by fysiks; 12-17-2015 at 22:20.
fysiks is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 12-17-2015 , 23:45   Re: [Help] Understanding count in this code.
Reply With Quote #3

Expirementing more so angry it should be so easy.

if ( g_NotBalanced == 4 ) is how many rounds it will wait until ending the match.
4ever16 is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 12-18-2015 , 01:51   Re: [Help] Understanding count in this code.
Reply With Quote #4

Finally after fu**ing 4 hours!

PHP Code:
if ( !g_CustomGame || true )
    {
        if (
g_IsStarted)
        {
            new 
numTnumCt;
        
            for ( new 
<= gMaxPlayers i++ )
            {
                if ( 
is_user_connected(i) )
                {
                    if ( 
cs_get_user_team(i) == CS_TEAM_T )
                        
numT++
                    else if ( 
cs_get_user_team(i) == CS_TEAM_CT )
                        
numCt++
                }
            }
            
            if ( 
numT <= (get_pcvar_num(cvar_pLeft)/3) - || numCt <= (get_pcvar_num(cvar_pLeft)/3) - )
            {
                if ( 
g_NotBalanced == )
                {
                    if (
numT numCt)
                        
client_print(0print_chat"%s %L"PREFIXLANG_PLAYER"T_AUTO_WON")
                    else if (
numCt numT)
                        
client_print(0print_chat"%s %L"PREFIXLANG_PLAYER"CT_AUTO_WON")
                    else if (
numCt == numT)
                        
client_print(0print_chat"%s %L"PREFIXLANG_PLAYER"NO_TEAM_WON")
                    
client_print(0print_chat"%s %L"PREFIXLANG_PLAYER"ENDING_MATCH")
                    new 
taskId scanForTaskID()
                    
set_task(5.0"EndMatch"taskId)
                    
g_NotBalanced 0
                
}

                else
                {
                    
client_print(0print_chat"%s %L"PREFIXLANG_PLAYER"NOT_ENOUGH_TEAMMATES", (get_pcvar_num(cvar_pLeft)/-6) - -6)
                    
client_print(0print_chat"%s %L"PREFIXLANG_PLAYER"NOT_ENOUGH_TEAMMATES2"g_NotBalanced )
                    
g_NotBalanced++
                }
            }
            
            else
                
g_NotBalanced 0;
        }
    }
                            
    return 
PLUGIN_HANDLED 
4ever16 is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 12-18-2015 , 12:14   Re: [Help] Understanding count in this code.
Reply With Quote #5

ahahhaha, i feel you bro
__________________
Depresie 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 18:09.


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