AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Code doesn't count correct (https://forums.alliedmods.net/showthread.php?t=221447)

Kia 07-22-2013 06:14

Code doesn't count correct
 
Hello everybody,

For my ranking system I need to know who is the first / second etc. place of a race. For this I use this code :

PHP Code:

new PlayerZ[32], id2Amount g_PartyData[id][Amount_In_Party]
    
get_party_index(idPlayerZ)
    
    static 
PlayersFinished 0
    
    
for(new iAmounti++) 
    {
        
id2 PlayerZ[i]    
        if(!
g_bIsInRace[id2])
            
PlayersFinished++
    }
    
    for(new 
iAmounti++) 
    {
        
id2 PlayerZ[i]
        switch(
PlayersFinished)
        {
            case 
1:
            {
                
g_PartyData[id2][FIRST] = id
                client_print
(0print_chat"[DEBUG] %i is first player."id)
            }
            case 
2:
            {
                
g_PartyData[id2][SECOND] = id
                client_print
(0print_chat"[DEBUG] %i is second player."id)
            }
            case 
3:
            {
                
g_PartyData[id2][THIRD] = id
                client_print
(0print_chat"[DEBUG] %i is third player."id)
            }
            case 
4:
            {
                
g_PartyData[id2][FOURTH] = id
            
}
            case 
5:
            {
                
g_PartyData[id2][FIFTH] = id
            
}
            case 
6:
            {
                
g_PartyData[id2][SIXTH] = id
            
}
            case 
7:
            {
                
g_PartyData[id2][SEVENTH] = id
            
}
            case 
8:
            {
                
g_PartyData[id2][EIGHTH] = id
            
}    
        }
    }
    if(
PlayersFinished == g_PartyData[id][Amount_In_Party])
    {
        
calculate_players_elo(id)
    } 

But it always shows the second player as third (printing out ""[DEBUG] %i is third player.", id)") and the function "calculate_players_elo(id)" never gets executed.

Anyone knows what I'm doing wrong or has better idea how to do this?

Smatify 07-22-2013 07:40

Re: Code doesn't count correct
 
Maybe is this the problem?
PHP Code:

static PlayersFinished 


Kia 07-22-2013 07:44

Re: Code doesn't count correct
 
Nevermind, Smatify told me my mistake.

PHP Code:

 static PlayersFinished 

->
PHP Code:

  new PlayersFinished 



All times are GMT -4. The time now is 06:24.

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