Run time error 5 & Run time error 6.
#1

Hi'.
I'm making a very simple command but I got a weird problem. When I type the command, I get :
Код:
[20:07:29] [debug] Run time error 5: "Invalid memory access"
[20:07:29] [debug] AMX backtrace:
[20:07:29] [debug] #0 000169b0 in ?? (0, 628228) from test.amx
[20:07:29] [debug] #1 0001808c in public cmd_jetpack (0, 628408) from test.amx
[20:07:29] [debug] #2 native CallLocalFunction () from samp-server.exe
[20:07:29] [debug] #3 000169b0 in ?? (0, 628228) from test.amx
[20:07:29] [debug] #4 0001808c in public OnPlayerCommandText (0, 628408) from test.amx
After this, I'm unable to make a command or something like that. Plus, when I type "gmx" on the console I get:
Код:
Console input: gmx
[20:07:50] [debug] Run time error 6: "Invalid instruction"
[20:07:50] [debug]  Unknown opcode 0x99604 at address 0x00099604
[20:07:50] [debug] AMX backtrace:
[20:07:50] [debug] #0 00099604 in public ScriptInit_OnGameModeExit () from test.amx
[20:07:50] [debug] #1 000065d0 in public OnGameModeExit () from test.amx
After typing the command, every callback called are send me error :
Код:
[20:07:49] [debug] Run time error 6: "Invalid instruction"
[20:07:49] [debug]  Unknown opcode 0xf0000 at address 0x000000BE
[20:07:49] [debug] AMX backtrace:
[20:07:49] [debug] #0 000000be in public OnPlayerKeyStateChange (0, 1024, 0) from test.amx
There is the command:
PHP код:
CMD:jetpack(playerid)
{
    if(
pAccount[playerid][pAdmin] < GMODO) return ErrorMsg(playerid_false);
    
SetPlayerSpecialAction(playeridGetPlayerSpecialAction(playerid) == 2);
    
SCM(playerid, -1"Passed"); // Debug
    
if(GetPlayerSpecialAction(playerid) == 2)
        return 
AdminMessage(playerid"You have remove your jetpack"), 1;
    else
        return 
AdminMessage(playerid"You have spawned a jetpack"), 1;

Every function in this command is working on others commands. :/
Thanks for reading and your help.
Sorry for English mistake.
Reply
#2

The code looks clean. Do you have -d3 enabled?
Which command processor are you using?
Reply
#3

Alright, I'm using Sublime Text 3 (if you asking for this x.x)
I'm not using -d3 on Sublime but on Pawno I use it; there is the result :
Код:
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

Header size:           5524 bytes
Code size:           117384 bytes
Data size:           628312 bytes
Stack/heap size:      16384 bytes; estimated max. usage: unknown, due to recursion
Total requirements:  767604 bytes
Reply
#4

The debug flag will give you more information about the crash, such as which function in which line exactly failed (mostly, not counting #emit shenanigans)
Reply
#5

I don't get it.
I added -d3 flag on Sublime Text and.. nothing different:
Код:
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

Header size:           5644 bytes
Code size:           203648 bytes
Data size:           630048 bytes
Stack/heap size:      16384 bytes; estimated max. usage: unknown, due to recursion
Total requirements:  855724 bytes
[Finished in 2.7s]
Reply
#6

? Trigger your runtime crash again, and this time
Quote:

[20:07:29] [debug] #0 000169b0 in ?? (0, 62822 from test.amx

should have more information instead of "in ??"
Reply
#7

Alright, sorry for misunderstood what you said. x:
There is the log
Код:
21:23:18] [debug] Run time error 5: "Invalid memory access"
[21:23:18] [debug] AMX backtrace:
[21:23:18] [debug] #0 0002fa80 in AdminMessage (playerid=0, message[]=@000999ec "") at test.pwn:514
[21:23:18] [debug] #1 00031860 in public cmd_jetpack (playerid=0, ... <1 argument>) at test.pwn:708
[21:23:18] [debug] #2 native CallLocalFunction () from samp-server.exe
[21:23:18] [debug] #3 0002fa80 in AdminMessage (playerid=0, message[]=@000999ec "") at test.pwn:514
[21:23:18] [debug] #4 00031860 in public OnPlayerCommandText (playerid=0, cmdtext[]=@00099d44 "") at test.pwn:708
The problem seems to come from the return, so I make it more clean.
PHP код:
CMD:jetpack(playerid

    if(
pAccount[playerid][pAdmin] < GMODO) return ErrorMsg(playerid_false); 
    
SetPlayerSpecialAction(playeridGetPlayerSpecialAction(playerid) == 2); 
    
SCM(playerid, -1"Passed"); // Debug 
    
if(GetPlayerSpecialAction(playerid) == 2
        return 
AdminMessage(playerid"You have remove your jetpack"), 1
    else
    {
        
AdminMessage(playerid"You have spawned a jetpack");
        return 
1;
    } 
But the error come from the return 1 or the function AdminMessage.
Код:
[21:24:53] [debug] Run time error 5: "Invalid memory access"
[21:24:53] [debug] AMX backtrace:
[21:24:53] [debug] #0 0002fa80 in AdminMessage (playerid=0, message[]=@000999ec "") at test.pwn:514
[21:24:53] [debug] #1 00031860 in public cmd_jetpack (playerid=0, ... <1 argument>) at test.pwn:710
[21:24:53] [debug] #2 native CallLocalFunction () from samp-server.exe
[21:24:53] [debug] #3 0002fa80 in AdminMessage (playerid=0, message[]=@000999ec "") at test.pwn:514
[21:24:53] [debug] #4 00031860 in public OnPlayerCommandText (playerid=0, cmdtext[]=@00099d44 "") at test.pwn:710
There is the function here:
PHP код:
AdminMessage(playerid, const message[], va_args<>)
{
    static 
msg[190];
    
va_format(msgsizeof(msg), messageva_start<3>);
    return 
SCMF(playeridRED"Admin:"WHITE_U" %s"msg);

After congitate few minutes.. I found why. va_args need at least 1 arg. To prevent any error the code should like this:
PHP код:
CMD:jetpack(playerid

    if(
pAccount[playerid][pAdmin] < GMODO) return ErrorMsg(playerid_false); 
    
SetPlayerSpecialAction(playeridGetPlayerSpecialAction(playerid) == 2); 
    
SCM(playerid, -1"Passed"); // Debug 
    
if(GetPlayerSpecialAction(playerid) == 2
        return 
AdminMessage(playerid"You have remove your jetpack"0);
    else 
        return 
AdminMessage(playerid"You have spawned a jetpack"0); 

+rep for your help buddy. Thanks a lot! c:

EDIT: Anyone know how I can count the number of args with va_args<> ? ^^'
Reply
#8

Try this
pawn Код:
va_AdminMessage(playerid, const message[], va_args<>)
{
    static msg[190];
    static const premsg[] = "Admin:"WHITE_U" %s";
   
    if(numargs() == 2) return SCMF(playerid, RED, premsg, msg);
   
    va_format(msg, sizeof(msg), message, va_start<3>);
    return SCMF(playerid, RED, premsg, msg);
}
If it still fudges up, there's a little bit different option:

pawn Код:
//Somewhere at the top of your script
#define AdminMessage(%0,%1,%2) va_AdminMessage(%0,%1,%2)
//then
AdminMessage(playerid, const message[])
{
    return SCMF(playerid, RED, "Admin:"WHITE_U" %s", msg);
}
va_AdminMessage(playerid, const message[], va_args<>)
{
    static msg[190];
    va_format(msg, sizeof(msg), message, va_start<3>);
    return SCMF(playerid, RED, "Admin:"WHITE_U" %s", msg);
}
Reply
#9

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Try this
pawn Код:
va_AdminMessage(playerid, const message[], va_args<>)
{
    static msg[190];
    static const premsg[] = "Admin:"WHITE_U" %s";
   
    if(numargs() == 2) return SCMF(playerid, RED, premsg, msg);
   
    va_format(msg, sizeof(msg), message, va_start<3>);
    return SCMF(playerid, RED, premsg, msg);
}
If it still fudges up, there's a little bit different option:

pawn Код:
//Somewhere at the top of your script
#define AdminMessage(%0,%1,%2) va_AdminMessage(%0,%1,%2)
//then
AdminMessage(playerid, const message[])
{
    return SCMF(playerid, RED, "Admin:"WHITE_U" %s", msg);
}
va_AdminMessage(playerid, const message[], va_args<>)
{
    static msg[190];
    va_format(msg, sizeof(msg), message, va_start<3>);
    return SCMF(playerid, RED, "Admin:"WHITE_U" %s", msg);
}
The first version doesn't work and repeat the first message which is using the function.
The second works well when there are args but when there is no arg; this repeating the first message.
(Sorry for my english.. >.<)
Reply
#10

Whoops, my mistake, try this
pawn Код:
AdminMessage(playerid, const message[], va_args<>)
{
    static msg[190];
    static const premsg[] = "Admin:"WHITE_U" %s";
   
    if(numargs() == 2) return SCMF(playerid, RED, premsg, message);
   
    va_format(msg, sizeof(msg), message, va_start<3>);
    return SCMF(playerid, RED, premsg, msg);
}
Update: Look what Konstantinos said, I eyescanned the wrong thing. With his fix your original code should work no problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)