SA-MP Forums Archive
[Ajuda] Debug - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Debug (/showthread.php?tid=633915)



Debug - Scorpion659 - 09.05.2017

Olб, eu estava testando um debug e notei algo, olhe:

PHP код:
stock verificaritens()
{
    
printf("........Iniciado");
    new 
rand;
    for( new 
0<= sizeof(itens); i++ ){
        if(var[
i] == 1) { continue; }
        
rand random(3);
        switch(
rand){
            case 
0: { CreateObject(2768itens[i][0], itens[i][1], itens[i][2], 00300); }
            case 
1: { CreateObject(2814itens[i][0], itens[i][1], itens[i][2], 00300); }
            case 
2: { CreateObject(19570itens[i][0], itens[i][1], itens[i][2], 00300); }
        }
        var[
i] = 1;
    }
    
printf("........Carregado");
    return 
1;

pq ele nгo executa o ultimo printf dizendo carregado? geralmente quando coloco um printf dps de um for ele nгo printa, alguem sabe o pq?


Re: Debug - MultiKill - 09.05.2017

Ele esta gerando um erro na hora da execuзгo retornando a funзгo a 0, pois esta acessando um нndice invбlido.

Код:
for( new i = 0; i <= sizeof(itens); i++ ){
Enquanto i for menor ou igual ao tamanho da array ele vai rodar o loop.


Entгo se uma array tem 10 cйlulas e eu fazer como vocк fez o valor de i vai de 0 a 10, mesmo os нndices vбlidos da array sendo 0 a 9, tentando acessar o нndice 10 que nгo existe.

Recomendo usar o plugins crashdetect para descobrir erros na hora da execuзгo.


Re: Debug - Scorpion659 - 09.05.2017

Quote:
Originally Posted by MultiKill
Посмотреть сообщение
Ele esta gerando um erro na hora da execuзгo retornando a funзгo a 0, pois esta acessando um нndice invбlido.

Код:
for( new i = 0; i <= sizeof(itens); i++ ){
Enquanto i for menor ou igual ao tamanho da array ele vai rodar o loop.


Entгo se uma array tem 10 cйlulas e eu fazer como vocк fez o valor de i vai de 0 a 10, mesmo os нndices vбlidos da array sendo 0 a 9, tentando acessar o нndice 10 que nгo existe.

Recomendo usar o plugins crashdetect para descobrir erros na hora da execuзгo.
nossa cara, vlw, vou ver esse crashdetect, por causa desse erro tava bugando outras partes, tipo, tava executando essa funзгo no gamemode init, ai quando lia esse codigo ele n lia o resto do gamemode init, vlw

@edit

baixei o crashdetect e funcionou, testei com esse erro acima e olha:

[15:58:43] [debug] Run time error 4: "Array index out of bounds"
[15:58:43] [debug] Attempted to read/write array element at index 213 in array of size 213
[15:58:43] [debug] AMX backtrace:
[15:58:43] [debug] #0 000107c0 in ?? () from GM_KillerZ.amx
[15:58:43] [debug] #1 0001037c in public Streamer_OnGameModeInit () from GM_KillerZ.amx
[15:58:43] [debug] #2 native CallLocalFunction () from samp-server.exe
[15:58:43] [debug] #3 0000b8c0 in public SSCANF_OnGameModeInit () from GM_KillerZ.amx
[15:58:43] [debug] #4 00005828 in public zcmd_OnGameModeInit () from GM_KillerZ.amx
[15:58:43] [debug] #5 native CallLocalFunction () from samp-server.exe
[15:58:43] [debug] #6 000052a0 in public OnGameModeInit () from GM_KillerZ.amx

mas como eu vejo oq estб errado? oque eu vi foi isso:

[15:58:43] [debug] Run time error 4: "Array index out of bounds"
[15:58:43] [debug] Attempted to read/write array element at index 213 in array of size 213

ele ta falando do problema acima?