Run time error 4: "Array index out of bounds (more then 6/7:C)
#1

My script had alot of errors :V
Код:
[00:45:01] [debug] Run time error 4: "Array index out of bounds"
[00:45:01] [debug]  Accessing element at index 5 past array upper bound 4
[00:45:01] [debug] AMX backtrace:
[00:45:01] [debug] #0 0015764c in public OnPlayerEnterCheckpoint (2) from _dark_.amx
[00:45:07] [debug] Run time error 4: "Array index out of bounds"
[00:45:07] [debug]  Accessing element at index 5 past array upper bound 4

[05:30:28] [debug] Run time error 4: "Array index out of bounds"
[05:30:28] [debug]  Accessing element at index 65535 past array upper bound 99
[05:30:28] [debug] AMX backtrace:
[05:30:28] [debug] #0 0008de88 in public FC_OnPlayerDeath (0, 65535, 255) from _dark_.amx
[05:30:28] [debug] #1 native CallLocalFunction () from samp03svr
[05:30:28] [debug] #2 0000e2f8 in public OnPlayerDeath (0, 65535, 255) from _dark_.amx
[05:31:07] [debug] #0 00157ec4 in public OnVehicleDeath (401, 1) from _dark_.amx
[05:32:53] [debug] Run time error 4: "Array index out of bounds"
[05:32:53] [debug]  Accessing element at index 65535 past array upper bound 99
and sometimes this error
Код:
[22:58:21] [connection] 39.42.29.193:3113 requests connection cookie.
[22:58:23] [connection] 39.42.29.193:3113 requests connection cookie.
[23:12:05] [connection] 197.129.68.75:60194 requests connection cookie.
[23:12:36] Kicking 197.129.68.75 because they didn't logon to the game.
Error:
1-OnPlayerEnterCheckpoint
PHP код:
public OnPlayerEnterCheckpoint(playerid)
{
new 
text[128];
    if(
IsCapturing[playerid][usapro] == 1)
    {
        if(
IsPlayerInVehicle(playeridusapro))
        {
             
DisablePlayerCheckpoint(playerid);
            
IsCapturing[playerid][usapro] = 0;
                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~USA prototype ~w~for his team!"pName(playerid));
                
RemovePlayerFromVehicle(playerid);
                        
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
GivePlayerMoney(playerid6000);
SetVehicleToRespawn(usapro);
SetPlayerScore(playeridGetPlayerScore(playerid)+6);
TogglePlayerAllDynamicCPs(playerid1);
TextStats(playerid);
                
Savestatus(playerid);
        }
        else
        {
             
DisablePlayerCheckpoint(playerid);
            
SCM(playeridRED"You're not in the USA Prototype.");
        }
    }
    if(
IsCapturing[playerid][auspro] == 1)
    {
        if(
IsPlayerInVehicle(playeridauspro))
        {
            
DisablePlayerCheckpoint(playerid);
            
IsCapturing[playerid][auspro] = 0;
            
TextStats(playerid);
                
Savestatus(playerid);
                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~ Australia prototype ~w~for his team!"pName(playerid));
                
RemovePlayerFromVehicle(playerid);
 
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
 
GivePlayerMoney(playerid6000);
 
SetVehicleToRespawn(auspro);
 
SetPlayerScore(playeridGetPlayerScore(playerid)+6);
TogglePlayerAllDynamicCPs(playerid1);
        }
        else
        {
              
DisablePlayerCheckpoint(playerid);
            
SCM(playeridRED"You're not in the Australia Prototype.");
        }
    }
    if(
IsCapturing[playerid][arabpro] == 1)
    {
        if(
IsPlayerInVehicle(playeridarabpro))
        {
            
DisablePlayerCheckpoint(playerid);
            
IsCapturing[playerid][arabpro] = 0;
            
TextStats(playerid);
                
Savestatus(playerid);
                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~Arabian prototype ~w~for his team!"pName(playerid));
                
RemovePlayerFromVehicle(playerid);
 
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
 
GivePlayerMoney(playerid6000);
 
SetVehicleToRespawn(arabpro);
 
SetPlayerScore(playeridGetPlayerScore(playerid)+6);
TogglePlayerAllDynamicCPs(playerid1);
        }
        else
        {
            
DisablePlayerCheckpoint(playerid);
            
SCM(playeridRED"You're not in the Arabian Prototype.");
        }
    }
    if(
IsCapturing[playerid][sovpro] == 1)
    {
        if(
IsPlayerInVehicle(playeridsovpro))
        {
            
DisablePlayerCheckpoint(playerid);
                   
RemovePlayerFromVehicle(playerid);
                   
TextStats(playerid);
                
Savestatus(playerid);
                   
format(textsizeof(text), "~r~%s~w~ has Captured ~r~Soviet prototype ~w~for his team!"pName(playerid));
                
IsCapturing[playerid][sovpro] = 0;
                
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
                 
GivePlayerMoney(playerid6000);
                
SetVehicleToRespawn(sovpro);
                
SetPlayerScore(playeridGetPlayerScore(playerid)+6);
                 
TogglePlayerAllDynamicCPs(playerid1);
        }
        else
        {
            
DisablePlayerCheckpoint(playerid);
            
SCM(playeridRED"You're not in the Soviet Prototype.");
        }
    }
    if(
IsCapturing[playerid][eurapro] == 1)
    {
        if(
IsPlayerInVehicle(playerideurapro))
        {
            
DisablePlayerCheckpoint(playerid);
                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~Erusia prototype ~w~for his team!"pName(playerid));
                
IsCapturing[playerid][eurapro] = 0;
                
RemovePlayerFromVehicle(playerid);
                
TextStats(playerid);
                
Savestatus(playerid);
                 
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
                 
GivePlayerMoney(playerid6000);
             
SetVehicleToRespawn(eurapro);
             
SetPlayerScore(playeridGetPlayerScore(playerid)+6);
              
TogglePlayerAllDynamicCPs(playerid1);
        }
        else
        {
            
DisablePlayerCheckpoint(playerid);
            
SCM(playeridRED"You're not in the Erusia Prototype.");
        }
    }
    return 
1;

OnPlayerDeath i'll try to remove some Latest things :P

2-OnVehicleDeath
PHP код:
public OnVehicleDeath(vehicleidkillerid)
{
new 
text[128];
    if(
IsCapturing[killerid][usapro] == 1)
    {
        if(
vehicleid == usapro)
        {
        
DisablePlayerCheckpoint(killerid);
            
IsCapturing[killerid][usapro] = 0;
                
format(textsizeof(text), "%s has failed to capture the USA Prototype."pName(killerid));
                        
SendClientMessageToAllREDtext);
                        
TogglePlayerAllDynamicCPs(killerid1);
        }
    }
    if(
IsCapturing[killerid][auspro] == 1)
    {
        if(
vehicleid == auspro)
        {
        
DisablePlayerCheckpoint(killerid);
            
IsCapturing[killerid][auspro] = 0;
                
format(textsizeof(text), "%s has failed to capture the Australian Prototype."pName(killerid));
                        
SendClientMessageToAllREDtext);
                        
TogglePlayerAllDynamicCPs(killerid1);
        }
    }
    if(
IsCapturing[killerid][sovpro] == 1)
    {
        if(
vehicleid == sovpro)
        {
        
DisablePlayerCheckpoint(killerid);
            
IsCapturing[killerid][sovpro] = 0;
                    
format(textsizeof(text), "%s has failed to capture the Arabian Prototype."pName(killerid));
                        
SendClientMessageToAllREDtext);
                        
TogglePlayerAllDynamicCPs(killerid1);
        }
    }
    if(
IsCapturing[killerid][eurapro] == 1)
    {
        if(
vehicleid == eurapro)
        {
        
DisablePlayerCheckpoint(killerid);
            
IsCapturing[killerid][eurapro] = 0;
    
format(textsizeof(text),"%s has failed to capture the Arabian Prototype."pName(killerid));
                        
SendClientMessageToAllREDtext);
                        
TogglePlayerAllDynamicCPs(killerid1);
        }
    }
    new 
Float:P[3]; GetVehiclePos(vehicleidP[0], P[1], P[2]);
        if(
P[2] <= 0.4) return true;
        new 
model GetVehicleModel(vehicleid);
        switch(
model)
        {
            case 
PLANES: return true;
            case 
HELIS: return true;
            default:
            {
                new
                                
ht random(EFFECT_RANDOM),
                                
xang random(EFFECT_RANDOM)-EFFECT_FIX_DEFAULT,
                                
yang random(EFFECT_RANDOM)-EFFECT_FIX_DEFAULT,
                                
zang random(EFFECT_RANDOM)
                        ;
                        
GetVehiclePos(vehicleidP[0], P[1], P[2]);
                        
CreateExplosion(P[0], P[1], P[2]+EFFECT_EXPLOSIONOFFSETEFFECT_EXPLOSIONTYPEEFFECT_EXPLOSIONRADIUS);
                        
SetVehicleAngularVelocity(vehicleidxang*EFFECT_MULTIPLIERyang*EFFECT_MULTIPLIERzang*EFFECT_FIX_Z);
                        
GetVehicleVelocity(vehicleidP[0], P[1], P[2]);
                        
SetVehicleVelocity(vehicleidP[0], P[1], P[2] + (ht*EFFECT_FIX_Z) );
                }
        }
    return 
1;

Any Solution ?
Reply
#2

Try using debug level 3, so it shows you the exact lines that produce the crash.
If you don't know how to do that, here's how:
You should create a file called pawn.cfg in your pawno folder, inside this file write:

PHP код:
-d3 
Save the file and recompile your script and run it with crashdetect again.
Reply
#3

i did but it didn't show me the line where error '-'
Reply
#4

Which text editor are you using, You should use pawno to compile. Otherwise it won't show
If you're using Sublime or any other text editor, Switch over to pawno.

Just for this purpose.
Reply
#5

Quote:
Originally Posted by DarkSkull
Посмотреть сообщение
Which text editor are you using, You should use pawno to compile. Otherwise it won't show
If you're using Sublime or any other text editor, Switch over to pawno.

Just for this purpose.
i'am using pawno to compile ofc ...
Reply
#6

OnVehicleDeath, you must check killerid before using it to avoid run time 4 error, same in OnPlayerDeath
PHP код:
public OnVehicleDeath(vehicleidkillerid)
{
    if(
killerid != INVALID_PLAYER_ID)
    {
        new 
text[128];
        if(
IsCapturing[killerid][usapro] == 1)
        {
            if(
vehicleid == usapro)
            {
            
DisablePlayerCheckpoint(killerid);
                
IsCapturing[killerid][usapro] = 0;
                    
format(textsizeof(text), "%s has failed to capture the USA Prototype."pName(killerid));
                            
SendClientMessageToAllREDtext);
                            
TogglePlayerAllDynamicCPs(killerid1);
            }
        }
        if(
IsCapturing[killerid][auspro] == 1)
        {
            if(
vehicleid == auspro)
            {
            
DisablePlayerCheckpoint(killerid);
                
IsCapturing[killerid][auspro] = 0;
                    
format(textsizeof(text), "%s has failed to capture the Australian Prototype."pName(killerid));
                            
SendClientMessageToAllREDtext);
                            
TogglePlayerAllDynamicCPs(killerid1);
            }
        }
        if(
IsCapturing[killerid][sovpro] == 1)
        {
            if(
vehicleid == sovpro)
            {
            
DisablePlayerCheckpoint(killerid);
                
IsCapturing[killerid][sovpro] = 0;
                        
format(textsizeof(text), "%s has failed to capture the Arabian Prototype."pName(killerid));
                            
SendClientMessageToAllREDtext);
                            
TogglePlayerAllDynamicCPs(killerid1);
            }
        }
        if(
IsCapturing[killerid][eurapro] == 1)
        {
            if(
vehicleid == eurapro)
            {
            
DisablePlayerCheckpoint(killerid);
                
IsCapturing[killerid][eurapro] = 0;
        
format(textsizeof(text),"%s has failed to capture the Arabian Prototype."pName(killerid));
                            
SendClientMessageToAllREDtext);
                            
TogglePlayerAllDynamicCPs(killerid1);
            }
        }
        new 
Float:P[3]; GetVehiclePos(vehicleidP[0], P[1], P[2]);
            if(
P[2] <= 0.4) return true;
            new 
model GetVehicleModel(vehicleid);
            switch(
model)
            {
                case 
PLANES: return true;
                case 
HELIS: return true;
                default:
                {
                    new
                                    
ht random(EFFECT_RANDOM),
                                    
xang random(EFFECT_RANDOM)-EFFECT_FIX_DEFAULT,
                                    
yang random(EFFECT_RANDOM)-EFFECT_FIX_DEFAULT,
                                    
zang random(EFFECT_RANDOM)
                            ;
                            
GetVehiclePos(vehicleidP[0], P[1], P[2]);
                            
CreateExplosion(P[0], P[1], P[2]+EFFECT_EXPLOSIONOFFSETEFFECT_EXPLOSIONTYPEEFFECT_EXPLOSIONRADIUS);
                            
SetVehicleAngularVelocity(vehicleidxang*EFFECT_MULTIPLIERyang*EFFECT_MULTIPLIERzang*EFFECT_FIX_Z);
                            
GetVehicleVelocity(vehicleidP[0], P[1], P[2]);
                            
SetVehicleVelocity(vehicleidP[0], P[1], P[2] + (ht*EFFECT_FIX_Z) );
                }
            }
    }
    return 
1;

Reply
#7

I think others solved, no errors
But this one ?
how to solve it ?
PHP код:
public OnPlayerEnterCheckpoint(playerid)
{
new 
text[128];
    if(
IsCapturing[playerid][usapro] == 1)
    {
        if(
IsPlayerInVehicle(playeridusapro))
        {
             
DisablePlayerCheckpoint(playerid);
            
IsCapturing[playerid][usapro] = 0;
                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~USA prototype ~w~for his team!"pName(playerid));
                
RemovePlayerFromVehicle(playerid);
                        
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
GivePlayerMoney(playerid6000);
SetVehicleToRespawn(usapro);
SetPlayerScore(playeridGetPlayerScore(playerid)+6);
TogglePlayerAllDynamicCPs(playerid1);
TextStats(playerid);
                
Savestatus(playerid);
        }
        else
        {
             
DisablePlayerCheckpoint(playerid);
            
SCM(playeridRED"You're not in the USA Prototype.");
        }
    }
    if(
IsCapturing[playerid][auspro] == 1)
    {
        if(
IsPlayerInVehicle(playeridauspro))
        {
            
DisablePlayerCheckpoint(playerid);
            
IsCapturing[playerid][auspro] = 0;
            
TextStats(playerid);
                
Savestatus(playerid);
                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~ Australia prototype ~w~for his team!"pName(playerid));
                
RemovePlayerFromVehicle(playerid);
 
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
 
GivePlayerMoney(playerid6000);
 
SetVehicleToRespawn(auspro);
 
SetPlayerScore(playeridGetPlayerScore(playerid)+6);
TogglePlayerAllDynamicCPs(playerid1);
        }
        else
        {
              
DisablePlayerCheckpoint(playerid);
            
SCM(playeridRED"You're not in the Australia Prototype.");
        }
    }
    if(
IsCapturing[playerid][arabpro] == 1)
    {
        if(
IsPlayerInVehicle(playeridarabpro))
        {
            
DisablePlayerCheckpoint(playerid);
            
IsCapturing[playerid][arabpro] = 0;
            
TextStats(playerid);
                
Savestatus(playerid);
                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~Arabian prototype ~w~for his team!"pName(playerid));
                
RemovePlayerFromVehicle(playerid);
 
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
 
GivePlayerMoney(playerid6000);
 
SetVehicleToRespawn(arabpro);
 
SetPlayerScore(playeridGetPlayerScore(playerid)+6);
TogglePlayerAllDynamicCPs(playerid1);
        }
        else
        {
            
DisablePlayerCheckpoint(playerid);
            
SCM(playeridRED"You're not in the Arabian Prototype.");
        }
    }
    if(
IsCapturing[playerid][sovpro] == 1)
    {
        if(
IsPlayerInVehicle(playeridsovpro))
        {
            
DisablePlayerCheckpoint(playerid);
                   
RemovePlayerFromVehicle(playerid);
                   
TextStats(playerid);
                
Savestatus(playerid);
                   
format(textsizeof(text), "~r~%s~w~ has Captured ~r~Soviet prototype ~w~for his team!"pName(playerid));
                
IsCapturing[playerid][sovpro] = 0;
                
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
                 
GivePlayerMoney(playerid6000);
                
SetVehicleToRespawn(sovpro);
                
SetPlayerScore(playeridGetPlayerScore(playerid)+6);
                 
TogglePlayerAllDynamicCPs(playerid1);
        }
        else
        {
            
DisablePlayerCheckpoint(playerid);
            
SCM(playeridRED"You're not in the Soviet Prototype.");
        }
    }
    if(
IsCapturing[playerid][eurapro] == 1)
    {
        if(
IsPlayerInVehicle(playerideurapro))
        {
            
DisablePlayerCheckpoint(playerid);
                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~Erusia prototype ~w~for his team!"pName(playerid));
                
IsCapturing[playerid][eurapro] = 0;
                
RemovePlayerFromVehicle(playerid);
                
TextStats(playerid);
                
Savestatus(playerid);
                 
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
                 
GivePlayerMoney(playerid6000);
             
SetVehicleToRespawn(eurapro);
             
SetPlayerScore(playeridGetPlayerScore(playerid)+6);
              
TogglePlayerAllDynamicCPs(playerid1);
        }
        else
        {
            
DisablePlayerCheckpoint(playerid);
            
SCM(playeridRED"You're not in the Erusia Prototype.");
        }
    }
    return 
1;

Reply
#8

PHP код:
public OnPlayerEnterCheckpoint(playerid
{
    if(
playerid != INVALID_PLAYER_ID)
    {
        new 
text[128]; 
        if(
IsCapturing[playerid][usapro] == 1
        {
            if(
IsPlayerInVehicle(playeridusapro)) 
            {
                
DisablePlayerCheckpoint(playerid); 
                
IsCapturing[playerid][usapro] = 0
                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~USA prototype ~w~for his team!"pName(playerid));
                
RemovePlayerFromVehicle(playerid); 
                
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
                
GivePlayerMoney(playerid6000); 
                
SetVehicleToRespawn(usapro);
                
SetPlayerScore(playeridGetPlayerScore(playerid)+6); 
                
TogglePlayerAllDynamicCPs(playerid1); 
                
TextStats(playerid);
                
Savestatus(playerid); 
            } 
            else 
            {
                
DisablePlayerCheckpoint(playerid); 
                
SCM(playeridRED"You're not in the USA Prototype."); 
            }
        }
    }
}
.... 
Would be better if you use switch statements.
Reply
#9

Ali ? Nothing Fixed
anyway know ?
Reply
#10

Meh ? any one know how to solve this prob ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)