Portal SAMP
[Ajuda] erro em plublic de rank - Versão de Impressão

+- Portal SAMP (https://portalsamp.com)
+-- Fórum: SA-MP (https://portalsamp.com/forumdisplay.php?fid=5)
+--- Fórum: Área de suporte (https://portalsamp.com/forumdisplay.php?fid=6)
+--- Tópico: [Ajuda] erro em plublic de rank (/showthread.php?tid=2108)



erro em plublic de rank - fear - 17/02/2022

boa noite. ativei o plugin crashdetect para olhar os erros do gamemode e ir arrumando conforme da com a ajuda do portal samp.

erro:
Código PHP:
[22:34:52] [debug#2 0001f820 in public TimerUpdateServerRanking () in ZP.amx
[22:34:53] [debugRun time error 4"Array index out of bounds" 

public do erro:

Código PHP:
call:TimerUpdateServerRanking()
{
    
UpdateServerRanking();
}


static 
UpdateServerRanking(type = -1)
{
    if(!~
type)
    {
        
        
UpdateServerRanking(RANKING_TYPE_KILLS);
        
UpdateServerRanking(RANKING_TYPE_DEATHS);
        
UpdateServerRanking(RANKING_TYPE_SCORE);
        
UpdateServerRanking(RANKING_TYPE_TIME_PLAYED);
        
UpdateServerRanking(RANKING_TYPE_WANTED_LEVEL);
        return;
    }
    new 
players GetPlayerPoolSize(),
    
higherID[MAX_RANKING_POSITIONS],
    
morePoints[MAX_RANKING_POSITIONS],
    
bool:inRanking[MAX_PLAYERS],
    
playerPoints,
    
pos,
    
i;

    while(
pos MAX_RANKING_POSITIONS)
    {
        
        
higherID[pos] = INVALID_PLAYER_ID;
        
morePoints[pos] = -1;

        for(
0<= playersi++)
        {
            
            if(
IsPlayerConnected(i) && !playerConnectedNow[i] && !inRanking[i])
            {
                
                switch(
type)
                {
                    
                    case 
RANKING_TYPE_KILLSplayerPoints playerRankingControl[i][E_PLAYER_KILLS];
                    case 
RANKING_TYPE_DEATHSplayerPoints playerRankingControl[i][E_PLAYER_DEATHS];
                    case 
RANKING_TYPE_SCOREplayerPoints GetPlayerScore(i);
                    case 
RANKING_TYPE_TIME_PLAYEDplayerPoints GetPlayerTimePlayed(itrue);
                    case 
RANKING_TYPE_WANTED_LEVELplayerPoints GetPlayerWantedLevel(i);
                }

                if(
playerPoints morePoints[pos])
                {
                    
                    
morePoints[pos] = playerPoints;
                    
higherID[pos] = i;
                }
            }
            if(
== players && higherID[pos] != INVALID_PLAYER_ID)
            {
                
                
inRanking[higherID[pos]] = true;
            }
        }
        
pos++;
    }

    new
    
resultHigherID[MAX_RANKING_POSITIONS],
    
resultMorePoints[MAX_RANKING_POSITIONS],
    
resultListType[MAX_RANKING_POSITIONS],//0 - lista de jogadores on, 1 - lista de jogadores off
    
resultInRanking[MAX_RANKING_POSITIONS 2][MAX_PLAYER_NAME],
    
inRankingIndex,
    
bool:found,
    
a;

    
pos 0;

    while(
pos MAX_RANKING_POSITIONS)
    {
        
        
resultHigherID[pos] = INVALID_PLAYER_ID;
        
resultMorePoints[pos] = -1;
        
resultListType[pos] = 0;

        for(
0MAX_RANKING_POSITIONSi++)
        {
            
            for(
0inRankingIndexa++)
            {
                
                if(
higherID[i] != INVALID_PLAYER_ID && !isnull(resultInRanking[a]) && !strcmp(resultInRanking[a], GetNameOfPlayer(higherID[i])))
                {
                    
                    
found true;
                    break;
                }
            }

            if(
found)
            {
                
                
found false;
                continue;
            }

            if(
morePoints[i] > resultMorePoints[pos])
            {
                
                
resultHigherID[pos] = i;
                
resultMorePoints[pos] = morePoints[i];
                
resultListType[pos] = 0;
            }
        }

        for(
0MAX_RANKING_POSITIONSi++)
        {
            
            for(
0inRankingIndexa++)
            {
                
                if(
serverRanking[i][type][E_PLAYER_VALUE] != -&& !isnull(resultInRanking[a]) && !strcmp(resultInRanking[a], serverRanking[i][type][E_PLAYER_NAME]))
                {
                    
                    
found true;
                    break;
                }
            }

            if(
found)
            {
                
                
found false;
                continue;
            }

            if(
serverRanking[i][type][E_PLAYER_VALUE] > resultMorePoints[pos])
            {
                
                
resultHigherID[pos] = i;
                
resultMorePoints[pos] = serverRanking[i][type][E_PLAYER_VALUE];
                
resultListType[pos] = 1;
            }
        }

        if(
resultHigherID[pos] != INVALID_PLAYER_ID)
        {
            
            if(
resultListType[pos])
            {
                
                
format(resultInRanking[inRankingIndex], MAX_PLAYER_NAMEserverRanking[resultHigherID[pos]][type][E_PLAYER_NAME]);

                
format(serverRanking[pos][type][E_PLAYER_NAME], MAX_PLAYER_NAMEserverRanking[resultHigherID[pos]][type][E_PLAYER_NAME]);
                
serverRanking[pos][type][E_PLAYER_VALUE] = serverRanking[resultHigherID[pos]][type][E_PLAYER_VALUE];
            }
            else
            {
                
                
format(resultInRanking[inRankingIndex], MAX_PLAYER_NAMEGetNameOfPlayer(higherID[resultHigherID[pos]]));

                
format(serverRanking[pos][type][E_PLAYER_NAME], MAX_PLAYER_NAMEGetNameOfPlayer(higherID[resultHigherID[pos]]));
                
serverRanking[pos][type][E_PLAYER_VALUE] = morePoints[resultHigherID[pos]];
            }

            
inRankingIndex++;
        }

        
pos++;
    }



Índice de matriz fora dos limites traduzido pode ser algo com >=? aonde esta esse erro.. dei uma olhada e não vi algo de errado...

ah e antes disso deu esse erro tb..


Código PHP:
[22:34:30] [debugLong callback execution detected (hang or performance issue



RE: erro em plublic de rank - ipsLuan - 19/02/2022

Com certeza deve ser isso: if(!~type)


RE: erro em plublic de rank - fear - 19/02/2022

(19/02/2022 00:37)ipsLuan Escreveu: Com certeza deve ser isso: if(!~type)

Como eu arrumo???


RE: erro em plublic de rank - SrDivuOfficial - 19/02/2022

(19/02/2022 09:02)fear Escreveu:
(19/02/2022 00:37)ipsLuan Escreveu: Com certeza deve ser isso: if(!~type)

Como eu arrumo???

e so você entender o código, e veja se a função correta é if(!type) ou if(type)


RE: erro em plublic de rank - fear - 19/02/2022

(19/02/2022 09:12)SrDivuOfficial Escreveu:
(19/02/2022 09:02)fear Escreveu:
(19/02/2022 00:37)ipsLuan Escreveu: Com certeza deve ser isso: if(!~type)

Como eu arrumo???

e so você entender o código, e veja se a função correta é if(!type) ou if(type)

Não fui eu que fiz...ta complicado.. mas vou tentar como tu disse qualquer coisa eu retorno. obrigado


RE: erro em plublic de rank - k2bi_YT - 19/02/2022

(19/02/2022 09:24)fear Escreveu:
(19/02/2022 09:12)SrDivuOfficial Escreveu:
(19/02/2022 09:02)fear Escreveu:
(19/02/2022 00:37)ipsLuan Escreveu: Com certeza deve ser isso: if(!~type)

Como eu arrumo???

e so você entender o código, e veja se a função correta é if(!type) ou if(type)

Não fui eu que fiz...ta complicado.. mas vou tentar como tu disse qualquer coisa eu retorno. obrigado


Ele quis dizer que, você tem que ver se a função if(!~type), está verificando se é verdadeiro ou falso entende?

Exemplo:
Código PHP:
...
...
if(!~
type)
{
    
//Sim aqui vai fazer o jogador teleportar (exemplo)

Ou pode ser que esteja retornando como falso
Exemplo:
Código PHP:
...
...
if(!~
type)
{
    
//Não, o jogador não tem os requisitos para teleportar