Whether or not it's a ZCMD-related issue is arguable since it doesn't check the size of cmdtext before using its indices in a smaller array. It's definitely an underlying PAWN issue:
PHP код:
CMD:thiscommandshouldbearound33charse(playerid) {
return true;
}
gives a warning:
warning 200: symbol "cmd_thiscommandshouldbearound33" is truncated to 31 characters. Because functions in the SA-MP's compiler for PAWN can't exceed 31 characters and if you look at the ZCMD source code, it basically creates a new function for each command that you write:
PHP код:
#define COMMAND:%1(%2) \
forward cmd_%1(%2); \
public cmd_%1(%2)
And such big commands IG do give you the array out of bounds for
cmdtext in
OnPlayerCommandText:
Код:
[debug] Run time error 4: "Array index out of bounds"
[debug] Accessing element at index 32 past array upper bound 31
[debug] AMX backtrace:
[debug] #0 00000260 in public OnPlayerCommandText (playerid=0, cmdtext[]=@00000324 "/eiejgoergoierjgioerjgiojerjgierjoogieorjgoejrg") at F:\cnr\OSG-CNR\pawno\include\zcmd.inc:94
The include itself has a lot of calls referring to the indices of
funcname which is declared with a size of MAX_FUNC_NAME (set to 32):
PHP код:
while (cmdtext[++pos] > ' ')
{
funcname[pos-1] = tolower(cmdtext[pos]);
}
When cmdtext[++pos] exceeds 33, it tries to access funcname[32] which is out of its bounds and thus resulting in the error.
TL; DR: ZCMD is accessing indices of funcname[] out of its bounds resulting in the error. Raising MAX_FUNC_NAME to anything past 32 is not going to work as functions in PAWN can't exceed 31 characters.
EDIT: Also refer to SickAttack's post below:
Quote:
Originally Posted by SickAttack
By loading CrashDetect (it doesn't come out by default), it's only logical for the error to appear (by following the include's code). But that's why OnPlayerCommandReceived exists (though, it could be added in the code directly which the author didn't do):
pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[]) { new pos; while(cmdtext[pos] != ' ' && cmdtext[pos] != EOS) { pos ++; }
if(pos > 28) { return SendClientMessage(playerid, -1, "Command is invalid."), 0; } return 1; }
|