SA-MP Forums Archive
Runtime Error NO.7 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Runtime Error NO.7 (/showthread.php?tid=604123)



Runtime Error NO.7 - zT KiNgKoNg - 01.04.2016

Frankly, I cannot tell you what the hell is going one... I do how-ever know that its usually caused by something using #emit - and thankfully I only have one function that uses this, that I created any-how....

Edit: Commands work correctly when not spawned, but when spawned the issue stated below still happens.
Edit Two: The issue was not caused by any of the systems located below, how-ever it was caused by Y_Timers.
Edit Thee: Narrowed it down to Zeex's Compiler Patches or YSI 3.1/4 (Maybe both)

Error:
Код:
[debug] Run time error 20: "Invalid index parameter (bad entry point)"
[debug] Run time error 7: "Stack underflow"
[debug]  Stack pointer (STK) is 0x108AF6C, stack top (STP) is 0x108AF68
[debug] AMX backtrace:
[debug] #0 ???????? in public OnPlayerCommandText ()
OnPlayerCommandText
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new Command[30],
        command_params[127],
        command_function[64],
        result = 1;

    sscanf(cmdtext, "s[30]s[127]", Command, command_params);
    for(new i, j = strlen(Command); i < j; i ++)
        Command[i] = tolower(Command[i]);

    format(command_function, 64, "cmd_%s", Command[1]);

    /*
        cmd_%1
        scmd_%1_%2
        mcmd_%1_%2
    */

    if(funcidx(command_function) == -1) // If a regular command doesn't exist, look for a helper command;
    {
        new iStaffLevel = 1,
            iModeratorLevel = 1,
            iLoop = 9;

        while(iLoop > 0)
        {
            format(command_function, 64, "scmd_%s_%d", Command[1], iLoop);

            if(funcidx(command_function) != -1)
                break;

            iLoop --;
        }

        if(iLoop == 0)
        {
            iLoop = 5;

            while(iLoop > 0)
            {
                format(command_function, 64, "mcmd_%s_%d" , Command[1], iLoop);
                if(funcidx(command_function) != -1)
                    break;

                iLoop --;
            }



        }

        if(iLoop == 0)
            result = 0;

        if(iModeratorLevel < iLoop || iStaffLevel < iLoop)
            result = 5;

    }
    if(result == 1)
    {
        if(isnull(command_params))result = CallLocalFunction(command_function, "is", playerid, "\1");
        else result = CallLocalFunction(command_function, "is", playerid, command_params);
    }

    if(0 < result < 7)
        printf("[COMMAND] [%d]: %s", playerid, cmdtext);
    switch(result)
    {
        case 0: SendClientMessageA(playerid, COLOR_ORANGE, "That is not a recognized command, please check the /help dialog...");
        case 1: return 1; // Command was found do fuck-all.
        case 2: SendClientMessageA(playerid, COLOR_GRAY, "You are unable to use that command right now.");
        case 3: SendClientMessageA(playerid, COLOR_GRAY, "You cannot use that command on the specified player right now.");
        case 4: SendClientMessageA(playerid, COLOR_GRAY, "Invalid ID Specified.");
        case 5: SendClientMessageA(playerid, COLOR_GRAY, "You have insufficient authority to use that command.");
        case 6: SendClientMessageA(playerid, COLOR_GRAY, "You can only use that command on {FF6347}Staff Duty{808080} or {008B8B}Moderator Duty{808080}.");
    }
    return true;
}
Function Using #emit
pawn Код:
stock WriteLog(directory[], file[], fstring[], log_level = LOG_LEVEL_GEN, {Float,_}:...)
{
    static const STATIC_ARGS = 5;
    new fstringm[1024];
    new n = (numargs() - STATIC_ARGS) * BYTES_PER_CELL;

    new fyear, fmonth, fday,
        fhour, fminute, fsecond;

    new File:log_file,
        filename[144],
        log_level_string[24];

    getdate(fyear, fmonth, fday);
    gettime(fhour, fminute, fsecond);
   
    format(filename, sizeof(filename), SERVER_DIRECTORY_LOGS"%s/%s%s", directory, file, SERVER_DIRECTORY_LOGS_FILE);

    if(!file_exists(filename))
    {
        file_create(filename);
        log_file = f_open(filename);

        new string[1487];
        format(string,sizeof(string), "File Creation Date: [%02d/%02d/%04d %02d:%02d:%02d]", fday, fmonth, fyear, fhour, fminute, fsecond);
        file_write(filename, string);
        f_close(log_file);
    }

    log_file = f_open(filename);

    switch(log_level)
    {
        case LOG_LEVEL_GEN: format(log_level_string, sizeof(log_level_string), "GENERAL");
        case LOG_LEVEL_INFO: format(log_level_string, sizeof(log_level_string), "INFO");
        case LOG_LEVEL_WARN: format(log_level_string, sizeof(log_level_string), "WARNING");
        case LOG_LEVEL_ERROR: format(log_level_string, sizeof(log_level_string), "ERROR");
    }

    if(n)
    {
        new arg_start,arg_end;
        #emit CONST.alt         fstring
        #emit LCTRL             5
        #emit ADD
        #emit STOR.S.pri        arg_start

        #emit LOAD.S.alt        n
        #emit ADD
        #emit STOR.S.pri        arg_end
        do
        {
            #emit LOAD.I
            #emit PUSH.pri
            arg_end -= BYTES_PER_CELL;
            #emit LOAD.S.pri  arg_end
        }
        while(arg_end > arg_start);

        #emit PUSH.S            fstring
        #emit PUSH.C            1024
        #emit PUSH.ADR          fstringm

        n += BYTES_PER_CELL * 3;
        #emit PUSH.S            n
        #emit SYSREQ.C          format

        n += BYTES_PER_CELL;
        #emit LCTRL             4
        #emit LOAD.S.alt        n
        #emit ADD
        #emit SCTRL             4

        if(log_file)
        {
            new string[1487];
            format(string,sizeof(string), "\n[%02d/%02d/%04d %02d:%02d:%02d][%s]: %s",fday, fmonth, fyear, fhour, fminute, fsecond, log_level_string, fstringm);
            file_write(filename, string);
        } else print("[ERROR]: Failed to open the file requested...");

    } else {
        if(log_file)
        {
            new string[1487];
            format(string,sizeof(string), "\n[%02d/%02d/%04d %02d:%02d:%02d][%s]: %s",fday, fmonth, fyear, fhour, fminute, fsecond, log_level_string, fstring);
            file_write(filename, string);
        } else print("[ERROR]: Failed to open the file requested...");
    }
    f_close(log_file);
}

Addition: I'm also getting this (stated below) after adding Y_Timers
pawn Код:
//CONNECT
[debug] Run time error 7: "Stack underflow"
[debug]  Stack pointer (STK) is 0x108AF70, stack top (STP) is 0x108AF68
[debug] AMX backtrace:
[debug] #0 ???????? in public OnPlayerConnect ()
//DISCONNECT
[debug] Run time error 7: "Stack underflow"
[debug]  Stack pointer (STK) is 0x1080224, stack top (STP) is 0x1080220
[debug] AMX backtrace:
[debug] #0 ???????? in public OnPlayerDisconnect ()
// ON ATTEMPT SPAWN
[debug] Run time error 20: "Invalid index parameter (bad entry point)"
[debug] Run time error 20: "Invalid index parameter (bad entry point)"
[debug] Run time error 20: "Invalid index parameter (bad entry point)"
[debug] Run time error 20: "Invalid index parameter (bad entry point)"
[debug] Run time error 20: "Invalid index parameter (bad entry point)"
[debug] Run time error 20: "Invalid index parameter (bad entry point)"
[debug] Run time error 20: "Invalid index parameter (bad entry point)"
[debug] Run time error 20: "Invalid index parameter (bad entry point)"
[debug] Run time error 20: "Invalid index parameter (bad entry point)"
[debug] Run time error 20: "Invalid index parameter (bad entry point)"
[debug] Run time error 20: "Invalid index parameter (bad entry point)"
[debug] Run time error 20: "Invalid index parameter (bad entry point)"
[debug] Run time error 20: "Invalid index parameter (bad entry point)"
[debug] Run time error 20: "Invalid index parameter (bad entry point)"
[debug] Run time error 20: "Invalid index parameter (bad entry point)"
[debug] Run time error 20: "Invalid index parameter (bad entry point)"
[debug] Run time error 20: "Invalid index parameter (bad entry point)"
[debug] Run time error 20: "Invalid index parameter (bad entry point)"



Re: Runtime Error NO.7 - zT KiNgKoNg - 02.04.2016

BUMP: I've been unable to resolve the issue myself... It seems to be YSI causing the issue (bug report created on Github), and/or Zeex's Compiler Patches.