[Ajuda] Run time error 4: "Array index out of bounds"
#1

Meu servidor sempre esta dando isso:
Код:
[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
btu.pwn:69937
PHP код:
        for(new x!= MAX_SOUNDSx++){
        
            if(
SomInfo[x][somCreated] && IsPlayerInRangeOfPoint(playerid1.8SomInfo[x][somX], SomInfo[x][somY], SomInfo[x][somZ]) && SomInfo[x][somID] == playerid){ //AKI NESTA LINHA
            
                
destroyPlayerSound(playerid);
            
                
format(stringsizeof(string), "* %s desligou seu rбdio portбtil."NomePlayer(playerid));
                
SendClientMessageInRange(30.0playeridstringCOLOR_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;
            }
        } 
attachment-fix.inc:120
PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        if(
HOLDING(128))
        {
            switch(
GetPlayerWeapon(playerid))
            {
                case 
34..3643:
                {                    
                    
_J_AimedWithValidWeap[playerid] = true;
                    for(new 
0MAX_PLAYER_ATTACHED_OBJECTSi++)
                    {
                        if(
IsPlayerAttachedObjectSlotUsed(playeridi))
                        {
                            new 
BitStream:bs BS_New();
                            
                            
BS_WriteValue(
                                
bs
                                
PR_UINT16playerid
                                
PR_UINT32i,
                                
PR_BOOL0
                            
);  
                            
BS_RPC(bsplayerid113PR_LOW_PRIORITYPR_RELIABLE_ORDERED);
                            
BS_Delete(bs);
                        }
                    }
                }
            }
        }
        
        else if(
RELEASED(128))
        {
            if(
_J_AimedWithValidWeap[playerid])
            {                
                
_J_AimedWithValidWeap[playerid] = false;
                for(new 
0MAX_PLAYER_ATTACHED_OBJECTSi++)
                {
                    if(
IsPlayerAttachedObjectSlotUsed(playeridi))
                    {
                        new 
BitStream:bs BS_New();
                        
                        
BS_WriteValue(
                            
bs
                            
PR_UINT16playerid
                            
PR_UINT32i,
                            
PR_BOOL1,
                            
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(bsplayerid113PR_LOW_PRIORITYPR_RELIABLE_ORDERED); 
                        
BS_Delete(bs);                            
                    }
                }
            }
        }
    }
    
#if defined J_OnPlayerKeyStateChange
        
return J_OnPlayerKeyStateChange(playeridnewkeysoldkeys);//AKI NESTA LINHA
    #else
        
return 1;
    
#endif

#ds_ac#2.0.inc:413
PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
newkeys KEY_CROUCH)
        
fAutoC[playerid] = 0;
        
    if(
GetPlayerState(playerid) == && (newkeys 2048 || newkeys 4096))
    {
        
CallLocalFunction("PlayerCheater","id"playeridPlayer_Joypad);
    }
    return 
CallLocalFunction("abb_OnPlayerKeyStateChange""idd"playeridnewkeysoldkeys); //AKI NESTA LINHA
}
forward abb_OnPlayerKeyStateChange(playeridnewkeysoldkeys); 
Alguйm pode me ajudar por favor.
Reply
#2

Vocк estб tentando acessar uma posiзгo do vetor que nгo existe.

Tenta mudar essa parte
Код:
 for(new x; x != MAX_SOUNDS; x++)
para
Код:
 for(new x; x <= MAX_SOUNDS; x++)
Reply
#3

Nada ainda continua o mesmo problema sempre que pego um carro ou moto da isso ae
Reply
#4

Quote:
Originally Posted by Jason_King
Посмотреть сообщение
Vocк estб tentando acessar uma posiзгo do vetor que nгo existe.

Код:
 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 код:
 for(new xMAX_SOUNDSx++) 
Reply
#5

Quote:
Originally Posted by Sky™
Посмотреть сообщение
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 код:
 for(new xMAX_SOUNDSx++) 
Nossa verdade, vacilo meu

Foi mal Nathan. Segue o post do Sky que acho que agora mata seu problema.
Reply
#6

Deu em nada
Reply
#7

Quote:
Originally Posted by NATANGameron
Посмотреть сообщение
Deu em nada
Colega, este й apenas um dos pontos onde seu cуdigo tem erro ..
vocк pode pegar como exemplo este que o amigo acima indicou, e procurar ai pelos outros ..

Mas o erro й este, alguma array estб tendo seu valor excedido, com a primeira dica agora acredito que consiga encontrar os outros pontos ..

deu preguiзa verificar todo o cуdigo.
Reply
#8

Quote:
Originally Posted by Whoo
Посмотреть сообщение
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 10
new SomInfo[9][MAX_PLAYERS
Encontrei isso na GM:
PHP код:
#define MAX_SOUNDS      50
new SomInfo[MAX_SOUNDS][somI]; 
Reply
#9

Iai men?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)