PDA

View Full Version : Run time error 4: "Array index out of bounds"


Banditul18
13/02/2017, 03:06 PM
Hello , i open my server log and i se this:
[15:52:08] [debug] Run time error 4: "Array index out of bounds"
[15:52:08] [debug] Attempted to read/write array element at index 65535 in array of size 50
[15:52:08] [debug] AMX backtrace:
[15:52:08] [debug] #0 000be7e4 in public cmd_id (playerid=7, params[]=@003926a0 "3") at E:\V1-1.1.1\pawno\include\PPC_PlayerCommands.inc:5759
[15:52:08] [debug] #1 native CallLocalFunction () from samp03svr
[15:52:08] [debug] #2 00008c90 in public OnPlayerCommandText (playerid=7, cmdtext[]=@00392688 "/id 3") at E:\V1-1.1.1\pawno\include\izcmd.inc:112
The command its this:
CMD:id(playerid, params[])
{
new id, string[144];
if(sscanf(params, "u", id))
return SendClientMessage(playerid, COLOR_RED,"Use: /id [Nume/ID]");

format(string, sizeof(string), "Name:%s(%i) | Scor:%i | Class:%s | Admin:%i | VIP:%i", pName(id), id,APlayerData[id][PlayerScore], GetPlayerClassEx(id), APlayerData[id][PlayerLevel], APlayerData[id][VPlayerLevel]);
SendClientMessage(playerid, Grey, string);
return 1;
}
I need to check the invalid playerid id or something?

JesterlJoker
13/02/2017, 03:10 PM
This problem is already solved

http://forum.sa-mp.com/showthread.php?t=628680

Mic_H
13/02/2017, 03:10 PM
Yes you need to check for INVALID_PLAYER_ID
CMD:id(playerid, params[])
{
new id, string[144];
if(sscanf(params, "u", id))
return SendClientMessage(playerid, COLOR_RED,"Use: /id [Nume/ID]");
if(id != INVALID_PLAYER_ID)
{
format(string, sizeof(string), "Name:%s(%i) | Scor:%i | Class:%s | Admin:%i | VIP:%i", pName(id), id,APlayerData[id][PlayerScore], GetPlayerClassEx(id), APlayerData[id][PlayerLevel], APlayerData[id][VPlayerLevel]);
SendClientMessage(playerid, Grey, string);
}
else
return SendClientMessage(playerid, COLOR_RED, "Error: Invalid PlayerID/PlayerName.");
return 1;
}

JesterlJoker
13/02/2017, 03:16 PM
This problem is already solved

http://forum.sa-mp.com/showthread.php?t=628680