AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Proper way of getting ratio of teams? (https://forums.alliedmods.net/showthread.php?t=100577)

VMAN 08-15-2009 21:03

Proper way of getting ratio of teams?
 
I have the number of players on ct and t in their own variables.

Basically, I want to check if the ratio of CT to T is 1:2.

I tried dividing amount of T's by amount of CT's, but that didn't seem to work.

Jon 08-15-2009 22:01

Re: Proper way of getting ratio of teams?
 
You are running that jailbreak server? Isn't the ratio on such a server like 1:3 or even 1:4?

VMAN 08-16-2009 01:34

Re: Proper way of getting ratio of teams?
 
On my server I do no more than 1:2

VMAN 08-17-2009 22:42

Re: Proper way of getting ratio of teams?
 
Anyone got a clue what I'm doing wrong?

Here's a better example of how I'm attempting to do it:

PHP Code:

    if(ct != 0) {
        if(
t/ct >= 2) {
            
dosomething();
        }
    } 

My function is not called

Xanimos 08-17-2009 22:54

Re: Proper way of getting ratio of teams?
 
Try using 2.0 instead of 2. And also is it possible that you aren't setting your t and ct variables right?

Code:
  new t_count, ct_count, Players[32],pnum; get_players( Players, pnum , "a" ); //only alive players for( new i =0; i < pnum; i++ ) {     switch( get_user_team( Players[i] ) )     {          case 1: {t_count++;}          case 2: {ct_count++;}     } }

joaquimandrade 08-17-2009 23:11

Re: Proper way of getting ratio of teams?
 
Based on the code above:

PHP Code:

    new playersCount[3Players[32],pnum;
    
    
get_playersPlayerspnum "a" ); //only alive players
    
for( new =0pnumi++ )
    {
        
playersCount[get_user_team(Players[i])]++
    }
    
    new 
Float:ratio playersCount[1] / (playersCount[1]+playersCount[2]) 

Edit:
in the code above i'm calculating the ratio of T players per alive players. What makes that if there are 5 T's and 10 Ct's it will give 0.3(3). But, you just want the ratio of T's per Ct's so the way you doing is correct

PHP Code:

  new Float:ratio playersCount[1] / playersCount[2

It would give 0.5

VMAN 08-18-2009 15:38

Re: Proper way of getting ratio of teams?
 
Thank you

VMAN 08-18-2009 19:59

Re: Proper way of getting ratio of teams?
 
When I compile I get one warning on this line

PHP Code:

new Float:ratio ct

Tag mismatch

Exolent[jNr] 08-18-2009 20:17

Re: Proper way of getting ratio of teams?
 
PHP Code:

new Float:ratio float) / floatct ); 


VMAN 08-18-2009 20:22

Re: Proper way of getting ratio of teams?
 
Thank you


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

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