[debug] Run time error 4: "Array index out of bounds" [debug] AMX backtrace: [debug] #0 003da258 in public J_OnPlayerKeyStateChange (playerid=0, newkeys=16, oldkeys=0) at C:\Users\Natan\Desktop\Brasil Top UP!\gamemodes\btu.pwn:69937 [debug] #1 0005fc24 in public abb_OnPlayerKeyStateChange (playerid=0, newkeys=16, oldkeys=0) at C:\Users\Natan\Desktop\Brasil Top UP!\pawno\include\../BTU_Includes/attachment-fix.inc:120 [debug] #2 native CallLocalFunction () from samp03svr [debug] #3 000430b8 in public OnPlayerKeyStateChange (playerid=0, newkeys=16, oldkeys=0) at C:\Users\Natan\Desktop\Brasil Top UP!\pawno\include\../BTU_Includes/#ds_ac#2.0.inc:413
for(new x; x != MAX_SOUNDS; x++){
if(SomInfo[x][somCreated] && IsPlayerInRangeOfPoint(playerid, 1.8, SomInfo[x][somX], SomInfo[x][somY], SomInfo[x][somZ]) && SomInfo[x][somID] == playerid){ //AKI NESTA LINHA
destroyPlayerSound(playerid);
format(string, sizeof(string), "* %s desligou seu rбdio portбtil.", NomePlayer(playerid));
SendClientMessageInRange(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
PlayerInfo[playerid][pComRadio] = true;
SetPlayerAttachedObject(playerid,Slot_Radio,2226,5,0.394999,0.045000,0.027000,-25.299999,-101.699974,0.000000);
ApplyAnimation(playerid,"BOMBER","BOM_Plant_2Idle",4.1,0,1,1,0,0);
break;
}
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
if(HOLDING(128))
{
switch(GetPlayerWeapon(playerid))
{
case 34..36, 43:
{
_J_AimedWithValidWeap[playerid] = true;
for(new i = 0; i < MAX_PLAYER_ATTACHED_OBJECTS; i++)
{
if(IsPlayerAttachedObjectSlotUsed(playerid, i))
{
new BitStream:bs = BS_New();
BS_WriteValue(
bs,
PR_UINT16, playerid,
PR_UINT32, i,
PR_BOOL, 0
);
BS_RPC(bs, playerid, 113, PR_LOW_PRIORITY, PR_RELIABLE_ORDERED);
BS_Delete(bs);
}
}
}
}
}
else if(RELEASED(128))
{
if(_J_AimedWithValidWeap[playerid])
{
_J_AimedWithValidWeap[playerid] = false;
for(new i = 0; i < MAX_PLAYER_ATTACHED_OBJECTS; i++)
{
if(IsPlayerAttachedObjectSlotUsed(playerid, i))
{
new BitStream:bs = BS_New();
BS_WriteValue(
bs,
PR_UINT16, playerid,
PR_UINT32, i,
PR_BOOL, 1,
PR_UINT32, _J_AttachmentsEnum[playerid][i][_J_ModelID],
PR_UINT32, _J_AttachmentsEnum[playerid][i][_J_Bone],
PR_FLOAT, _J_AttachmentsEnum[playerid][i][_J_OffsetX],
PR_FLOAT, _J_AttachmentsEnum[playerid][i][_J_OffsetY],
PR_FLOAT, _J_AttachmentsEnum[playerid][i][_J_OffsetZ],
PR_FLOAT, _J_AttachmentsEnum[playerid][i][_J_RotX],
PR_FLOAT, _J_AttachmentsEnum[playerid][i][_J_RotY],
PR_FLOAT, _J_AttachmentsEnum[playerid][i][_J_RotZ],
PR_FLOAT, _J_AttachmentsEnum[playerid][i][_J_ScaleX],
PR_FLOAT, _J_AttachmentsEnum[playerid][i][_J_ScaleY],
PR_FLOAT, _J_AttachmentsEnum[playerid][i][_J_ScaleZ],
PR_UINT32, _J_AttachmentsEnum[playerid][i][_J_MaterialColor1],
PR_UINT32, _J_AttachmentsEnum[playerid][i][_J_MaterialColor2]
);
BS_RPC(bs, playerid, 113, PR_LOW_PRIORITY, PR_RELIABLE_ORDERED);
BS_Delete(bs);
}
}
}
}
}
#if defined J_OnPlayerKeyStateChange
return J_OnPlayerKeyStateChange(playerid, newkeys, oldkeys);//AKI NESTA LINHA
#else
return 1;
#endif
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_CROUCH)
fAutoC[playerid] = 0;
if(GetPlayerState(playerid) == 1 && (newkeys & 2048 || newkeys & 4096))
{
CallLocalFunction("PlayerCheater","id", playerid, Player_Joypad);
}
return CallLocalFunction("abb_OnPlayerKeyStateChange", "idd", playerid, newkeys, oldkeys); //AKI NESTA LINHA
}
forward abb_OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
for(new x; x != MAX_SOUNDS; x++)
for(new x; x <= MAX_SOUNDS; x++)
Vocк estб tentando acessar uma posiзгo do vetor que nгo existe.
Код:
for(new x; x <= MAX_SOUNDS; x++) |
for(new x; x < MAX_SOUNDS; x++)
Ainda sim estaria acessando, a matriz inicia do 0, ou seja o valor mбximo "MAX_SOUNDS" estaria passando pelo menos 1 vetor da matriz, entгo o correto seria.
PHP код:
|
Vocк deve ter definido MAX_SOUNDS com um determinado valor e ao declarar a matriz vocк nгo usou esse valor, logo o loop esta seguindo o valor de MAX_SOUNDS e tentando acessar uma posiзгo que nгo existe.
Veja um exemplo errado: PHP код:
|
#define MAX_SOUNDS 50
new SomInfo[MAX_SOUNDS][somI];