db_next_row crash the samp.server.exe
#1

Anything, wrong with this code?
if i open the samp-server.exe, the server close, but if don't have any rows, the samp continues, anything wrong?
pawn Код:
stock CarregarCasas()
{
    new DBResult:Consulta = db_query(Users, "SELECT * FROM `CASA`");
    new rows = db_num_rows(Consulta);
    if(!rows)   return print("Nгo tem casas para serem carregadas");
    for(new i; i < rows; i++);
    {
        db_get_field_assoc(Consulta, "NOME", CasaInfo[i][NOME], 100);
        db_get_field_assoc(Consulta, "PRECO", str, 15);
        CasaInfo[i][PRECO] = strval(str);
        db_get_field_assoc(Consulta, "LEVEL", str, 4);
        CasaInfo[i][LEVEL] = strval(str);
        printf("Level: %d",CasaInfo[i][LEVEL]);
        db_get_field_assoc(Consulta, "DONO", CasaInfo[i][DONO], 24);
        printf("Dono: %s", CasaInfo[i][DONO]);
        db_get_field_assoc(Consulta, "ENTRADAX", str, 15);
        CasaInfo[i][POSICAO][0] = floatstr(str);
        printf("X: %f", floatstr(str));
        db_get_field_assoc(Consulta, "ENTRADAY", str, 15);
        CasaInfo[i][POSICAO][1] = floatstr(str);
        printf("Y: %f", floatstr(str));
        db_get_field_assoc(Consulta, "ENTRADAZ", str, 15);
        CasaInfo[i][POSICAO][2] =  floatstr(str);
        printf("Z: %f", floatstr(str));
        CasaInfo[i][CHECK][0] = CreateDynamicCP(CasaInfo[i][POSICAO][0], CasaInfo[i][POSICAO][1], CasaInfo[i][POSICAO][2], 1.0);
        if(CasaInfo[i][LEVEL] == 1)
        {
            CasaInfo[i][SAIDA][0] = 223.1482;
            CasaInfo[i][SAIDA][1] = 1287.8635;
            CasaInfo[i][SAIDA][2] = 1082.1406;
            CasaInfo[i][INTERIOR] = 1;
            CasaInfo[i][CHECK][1] = CreateDynamicCP(CasaInfo[i][SAIDA][0], CasaInfo[i][SAIDA][1], CasaInfo[i][SAIDA][2], 1.0, 15500000+casaid, CasaInfo[i][INTERIOR]);
        }
        if(!CasaInfo[i][DONO][0]) format(str, sizeof(str), "Propiedade: %s \n Preзo:$%d \n Nivel: %d", CasaInfo[i][NOME], CasaInfo[i][PRECO], CasaInfo[casaid][LEVEL]);
        else if(CasaInfo[i][DONO][0] != 0) format(str, sizeof(str), "Propiedade: %s \n Dono: %s", CasaInfo[i][NOME], CasaInfo[i][DONO]);
        CasaInfo[i][LABEL] = CreateDynamic3DTextLabel(str, -1, CasaInfo[i][POSICAO][0], CasaInfo[i][POSICAO][0], CasaInfo[i][POSICAO][0] + 0.5, 10.0);
        //SetarDono(CasaInfo[i][NOME], CasaInfo[i][DONO], i);
        casaid++;
        db_next_row(Consulta);
    }
    db_free_result(Consulta);
    printf("Fields: %d", db_num_fields(Consulta));
    printf("%d Casas Carregadas!", rows);
    return true;
}
Reply
#2

The best point of action for these type of errors is to:

a) Make sure the server is configured properly. Basic mistakes are the hardest to find.
b) Install the crashdetect plugin and compile with debug options
c) Place print debug messages and run the server to know where you are falling short

If a, b and c fails - try again.
Reply
#3

Quote:
Originally Posted by SMCentral
Посмотреть сообщение
b) Install the crashdetect plugin and compile with debug options
Do this!

I assume a field/more fields are null and SQLite crashes the server if they are.

By using crashdetect and by compiling the mode with the debug options (they're mentioned to the original plugin's thread), it will mention the line the server crashed when it reached it. If it's on any "db_get_field_assoc" function, be sure that line's the field is not null.
Reply
#4

Код:
[10:51:29] Level: 1
[10:51:29] Dono: Game_Developer
[10:51:29] X: 2385.333496
[10:51:29] Y: -1712.134643
[10:51:29] Z: 14.242186
[10:51:29] Level: 1
[10:51:29] [debug] Server crashed while executing sqlite.amx
[10:51:29] [debug] AMX backtrace:
[10:51:29] [debug] #0 native db_get_field_assoc () [0044de30] from samp-server.exe
[10:51:29] [debug] #1 000122c8 in ?? () from sqlite.amx
[10:51:29] [debug] #2 000067e8 in public SSCANF_OnGameModeInit () from sqlite.amx
[10:51:29] [debug] #3 00000740 in public zcmd_OnGameModeInit () from sqlite.amx
[10:51:29] [debug] #4 native CallLocalFunction () [00471e90] from samp-server.exe
[10:51:29] [debug] #5 00000210 in public OnGameModeInit () from sqlite.amx
[10:51:29] [debug] Native backtrace:
[10:51:29] [debug] #0 0044dad1 in ?? () from C:\Users\Mateus Roberto\Documents\Servidor\Servidor Pasta\samp-server.exe
[10:51:29] [debug] #1 004010b6 in ?? () from C:\Users\Mateus Roberto\Documents\Servidor\Servidor Pasta\samp-server.exe
[10:51:29] [debug] #2 6f3c60ba in ?? () from C:\Users\Mateus Roberto\Documents\Servidor\Servidor Pasta\plugins\crashdetect.DLL
[10:51:29] [debug] #3 6f3c7fee in ?? () from C:\Users\Mateus Roberto\Documents\Servidor\Servidor Pasta\plugins\crashdetect.DLL
[10:51:29] [debug] #4 6f3c0091 in ?? () from C:\Users\Mateus Roberto\Documents\Servidor\Servidor Pasta\plugins\crashdetect.DLL
[10:51:29] [debug] #5 6f3c610a in ?? () from C:\Users\Mateus Roberto\Documents\Servidor\Servidor Pasta\plugins\crashdetect.DLL
[10:51:29] [debug] #6 0047219e in ?? () from C:\Users\Mateus Roberto\Documents\Servidor\Servidor Pasta\samp-server.exe
[10:51:29] [debug] #7 004010b6 in ?? () from C:\Users\Mateus Roberto\Documents\Servidor\Servidor Pasta\samp-server.exe
[10:51:29] [debug] #8 6f3c60ba in ?? () from C:\Users\Mateus Roberto\Documents\Servidor\Servidor Pasta\plugins\crashdetect.DLL
[10:51:29] [debug] #9 6f3c7fee in ?? () from C:\Users\Mateus Roberto\Documents\Servidor\Servidor Pasta\plugins\crashdetect.DLL
[10:51:29] [debug] #10 6f3c0091 in ?? () from C:\Users\Mateus Roberto\Documents\Servidor\Servidor Pasta\plugins\crashdetect.DLL
[10:51:29] [debug] #11 6f3c610a in ?? () from C:\Users\Mateus Roberto\Documents\Servidor\Servidor Pasta\plugins\crashdetect.DLL
[10:51:29] [debug] #12 0046e194 in ?? () from C:\Users\Mateus Roberto\Documents\Servidor\Servidor Pasta\samp-server.exe
[10:51:29] [debug] #13 65646f6d in ?? () from C:\Users\Mateus Roberto\Documents\Servidor\Servidor Pasta\samp-server.exe
[10:51:29] [debug] #14 71732f73 in ?? () from C:\Users\Mateus Roberto\Documents\Servidor\Servidor Pasta\samp-server.exe
[10:51:29] [debug] #15 6574696c in ?? () from C:\Users\Mateus Roberto\Documents\Servidor\Servidor Pasta\samp-server.exe
[10:51:29] [debug] #16 786d612e in ?? () from C:\Users\Mateus Roberto\Documents\Servidor\Servidor Pasta\samp-server.exe
Reply
#5

Код:
[10:51:29] [debug] #0 native db_get_field_assoc () [0044de30] from samp-server.exe
That's where the code is failing, if you compiled with debug options then it would even show the line of code that is at fault. I suggest that you make sure you are not attempting to load null data.

_Zeus explains it well.
Reply
#6

Fixed, the error is not in the pawn, but in the database, the "DONO" field is null, but i put one text at the field, and the samp server don't crash, Thankyou SMCentral,
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)