• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Help crash
#1
i am having problems with this function. crashdetect flagged this for me
[debug] AMX backtrace:
[debug] #0 00002774 in ?? (4016892) in XAF.amx
[debug] #1 00002dd4 in ?? (0, 4016892, 5000, 3) in XAF.amx
[debug] #2 001e3734 in public Timer1minute (0) in XAF.amx


Code:
ptask Timer1minute[60000](i) {
    if (JugadorInfo[i][zLogueado] == true) {
        // Verifica si el jugador quiere ver los textos
        if (JugadorInfo[i][zVerTextos][1] == 1) {
            ServerInfo[AnuncioTextoCmds]++;
            if (ServerInfo[AnuncioTextoCmds] == 3) ServerInfo[AnuncioTextoCmds] = 1;
            switch (ServerInfo[AnuncioTextoCmds]) {
                case 1: PlayerTextDrawSetString(i, InfoDeCmds, "");
                case 2: PlayerTextDrawSetString(i, InfoDeCmds, "");
                case 3: PlayerTextDrawSetString(i, InfoDeCmds, "");
            }
            PlayerTextDrawShow(i, InfoDeCmds);
        }
        // Incrementa el tiempo del jugador
        JugadorInfo[i][zMiTiempo]++;
        JugadorInfo[i][zTimeMiRango]++;
        // Actualiza la base de datos con el nuevo tiempo
        static Query[180];
        format(Query, sizeof(Query), "UPDATE `USERS` SET TIEMPO = '%d', TRG = '%d' WHERE `ID` = '%d' COLLATE NOCASE", JugadorInfo[i][zMiTiempo], JugadorInfo[i][zTimeMiRango], JugadorInfo[i][zMiID]);
        db_query(ZLDB, Query);

        // Verifica las caducidades para el VIP y el rango
        VerificarCaducidadVip(i);
        VerificarCaducidadRango(i);

        // Incrementa el tiempo del staff si es administrador
        if (JugadorInfo[i][zAdmin] > 0 && JugadorInfo[i][zAfk] < 3) {
            JugadorInfo[i][zTiempoStaff]++;
            static Query2[150];
            format(Query2, sizeof(Query2), "UPDATE `USERS` SET TIMESTAFF = '%d' WHERE `ID` = '%d' COLLATE NOCASE", JugadorInfo[i][zTiempoStaff], JugadorInfo[i][zMiID]);
            db_query(ZLDB, Query2);
        }

        // Incrementa el tiempo de juego si el jugador no está AFK
        if (JugadorInfo[i][zAfk] < 3) {
            JugadorInfo[i][zPlayTiempo]++;
            static Query2[150];
            format(Query2, sizeof(Query2), "UPDATE `USERS` SET PLAYTIME = '%d' WHERE `ID` = '%d' COLLATE NOCASE", JugadorInfo[i][zPlayTiempo], JugadorInfo[i][zMiID]);
            db_query(ZLDB, Query2);
        }

        // Verifica el tiempo de juego reclamado
        if (JugadorInfo[i][zPlayReclamado] == 0) VerificarPlayTime(i);

        // Verifica si el jugador está encarcelado
        if (JugadorInfo[i][zJailed] == 1) {
            JugadorInfo[i][zJailTime]--;
            format(Query, sizeof(Query), "UPDATE `USERS` SET TIMEJAIL = '%d' WHERE `ID` = '%d' COLLATE NOCASE", JugadorInfo[i][zJailTime], JugadorInfo[i][zMiID]);
            db_query(ZLDB, Query);
            if (JugadorInfo[i][zJailTime] <= 0) JailRelease(i);
        }

        // Manejo de items
        // Score Free Kill
        if (JugadorInfo[i][zScoreFreeKill] == 1) {
            JugadorInfo[i][zTScoreFreeKill]--;
            format(Query, sizeof(Query), "UPDATE `USERS` SET TIMESCFREE = '%d' WHERE `ID` = '%d' COLLATE NOCASE", JugadorInfo[i][zTScoreFreeKill], JugadorInfo[i][zMiID]);
            db_query(ZLDB, Query);
            if (JugadorInfo[i][zTScoreFreeKill] <= 0) {
                format(Query, sizeof(Query), "UPDATE `USERS` SET TIMESCFREE = '0', SCFREE = '0' WHERE `ID` = '%d' COLLATE NOCASE", JugadorInfo[i][zMiID]);
                db_query(ZLDB, Query);
                JugadorInfo[i][zTScoreFreeKill] = 0;
                JugadorInfo[i][zScoreFreeKill] = 0;
                SendClientMessage(i, COLOR_ROJO, "« Info » "COL_BLANCO"Tu item score freeroam kill ha sido desactivado (tiempo finalizado), vuélvelo a comprar desde tu panel.");
            }
        }

        // Armour Spawn
        if (JugadorInfo[i][zArmourSpawn] == 1) {
            JugadorInfo[i][zTArmourSpawn]--;
            format(Query, sizeof(Query), "UPDATE `USERS` SET TIMEARSPW = '%d' WHERE `ID` = '%d' COLLATE NOCASE", JugadorInfo[i][zTArmourSpawn], JugadorInfo[i][zMiID]);
            db_query(ZLDB, Query);
            if (JugadorInfo[i][zTArmourSpawn] <= 0) {
                format(Query, sizeof(Query), "UPDATE `USERS` SET TIMEARSPW = '0', ARSPW = '0' WHERE `ID` = '%d' COLLATE NOCASE", JugadorInfo[i][zMiID]);
                db_query(ZLDB, Query);
                JugadorInfo[i][zTArmourSpawn] = 0;
                JugadorInfo[i][zArmourSpawn] = 0;
                SendClientMessage(i, COLOR_ROJO, "« Info » "COL_BLANCO"Tu item armour spawn ha sido desactivado (tiempo finalizado), vuélvelo a comprar desde tu panel.");
            }
        }

        // Volar (Fly)
        if (JugadorInfo[i][zVolar] == 1) {
            JugadorInfo[i][zTimeVolar]--;
            format(Query, sizeof(Query), "UPDATE `USERS` SET TIMEFLY = '%d' WHERE `ID` = '%d' COLLATE NOCASE", JugadorInfo[i][zTimeVolar], JugadorInfo[i][zMiID]);
            db_query(ZLDB, Query);
            if (JugadorInfo[i][zTimeVolar] <= 0) {
                format(Query, sizeof(Query), "UPDATE `USERS` SET TIMEFLY = '0', FLY = '0' WHERE `ID` = '%d' COLLATE NOCASE", JugadorInfo[i][zMiID]);
                db_query(ZLDB, Query);
                JugadorInfo[i][zTimeVolar] = 0;
                JugadorInfo[i][zVolar] = 0;
                if (JugadorInfo[i][zEnVuelo] == true) {
                    SendClientMessage(i, COLOR_ROJO, "« Info » "COL_BLANCO"Vuelo finalizado.");
                    JugadorInfo[i][zEnVuelo] = false;
                    StopFly(i);
                    GameTextForPlayer(i, "~b~Vuelo ~g~Finalizado", 6000, 3);
                }
                SendClientMessage(i, COLOR_ROJO, "« Info » "COL_BLANCO"Tu item vuelo ha sido desactivado (tiempo finalizado), vuélvelo a comprar desde tu panel.");
            }
        }

        // Teleport Click
        if (JugadorInfo[i][zTeleP] == 1) {
            JugadorInfo[i][zTimeTeleP]--;
            format(Query, sizeof(Query), "UPDATE `USERS` SET TIMETELE = '%d' WHERE `ID` = '%d' COLLATE NOCASE", JugadorInfo[i][zTimeTeleP], JugadorInfo[i][zMiID]);
            db_query(ZLDB, Query);
            if (JugadorInfo[i][zTimeTeleP] <= 0) {
                format(Query, sizeof(Query), "UPDATE `USERS` SET TIMETELE = '0', TELE = '0' WHERE `ID` = '%d' COLLATE NOCASE", JugadorInfo[i][zMiID]);
                db_query(ZLDB, Query);
                JugadorInfo[i][zTimeTeleP] = 0;
                JugadorInfo[i][zTeleP] = 0;
                SendClientMessage(i, COLOR_ROJO, "« Info » "COL_BLANCO"Tu item teleport click ha sido desactivado (tiempo finalizado), vuélvelo a comprar desde tu panel.");
            }
        }
    }
    return 1;
}
  Reply
#2
I think you should insert debug print statements at various points in the code to track the execution flow and identify where the crash occurs. You can use the printf function to print values to the server console or log file. By narrowing down the problematic section, you can focus your debugging efforts. minecraftle game
  Reply
#3
Create a file where pawncc.exe is named "pawn.cfg". Inside of that file type -d3 then save and go compile your script. This will compile your script with debug information.

Download crashdetect: https://github.com/Zeex/samp-plugin-cras...t/releases

Place crashdetect.dll in your plugins folder and update the server config to load it with the server.

When the code crashes again, you can see why its crashing and around the line number thats causing the error.
  Reply


Forum Jump: