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

Hello

PHP код:
[09:25:17] [debugRun time error 4"Array index out of bounds"
[09:25:17] [debug]  Attempted to read/write array element at index 65535 in array of size 100
[09:25:17] [debugAMX backtrace:
[
09:25:17] [debug#0 00098364 in public FC_OnPlayerDeath (0, 65535, 255) from TDM.amx
[09:25:17] [debug#1 native CallLocalFunction () from samp03svr
[09:25:17] [debug#2 0000e3e8 in public OnPlayerDeath (0, 65535, 255) from TDM.amx
[09:25:17] [death] [H]e[R]o died 255 
PHP код:
[09:09:44] [debugAMX backtrace:
[
09:09:44] [debug#0 0016201c in public OnPlayerEnterCheckpoint (0) from TDM.amx
[09:11:27] [debugRun time error 4"Array index out of bounds"
[09:11:27] [debug]  Attempted to read/write array element at index 5 in array of size 5
[09:11:27] [debugAMX backtrace:
[
09:11:27] [debug#0 0016201c in public OnPlayerEnterCheckpoint (0) from TDM.amx
[09:12:15] [debugRun time error 4"Array index out of bounds"
[09:12:15] [debug]  Attempted to read/write array element at index 5 in array of size 5
[09:12:15] [debugAMX backtrace:
[
09:12:15] [debug#0 0016201c in public OnPlayerEnterCheckpoint (0) from TDM.amx 
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;

EDIT: Why i got those errors ?
Reply
#2

Fix the indentation, re-write the code and if the problem still persists, debug the code.
Reply
#3

For the OnPlayerDeath, you gotta check if killerid is != INVALID_PLAYER_ID and you should be done.

Can you show textstats & savestatus?

(You have a array with [4] )

PS: compile with -d3 to get exact line of error.
Reply
#4

Already do that.. but the error still
Why i got that error ?
EDIT: ok ilean
Reply
#5

IsCapturing[playerid][*team*]


This array could be used a lot more efficiently rather than having an array for each player, for each location to capture...


Probably nothing to do with the error, but just saying so you may find another way of doing it.



Like, you could track the locations as an array, and have the Team ID tracked via that, and it would be less arrays.

Could even have the playerid tracked in a Location[site][capper] and have capper reflect who is capturing via their playerid, and check the players team when they are capping as to which team is capping.
Reply
#6

then how to solve it ?
anyway
iLeane..
about onplayerdeath(my code that) and i'll give you errors
Quote:

public OnPlayerDeath(playerid, killerid, reason)
{

if(killerid != INVALID_PLAYER_ID)
DropPlayerWeapons(playerid); //here, we send that, when you die, you will drop your weaps (sorry da english)
gHelmet[playerid] = false;

if(PlayerHeadShot[playerid] == true)
PlayerHeadShot[playerid] = false;
..
..
..
..
..

Reply
#7

f(killerid != INVALID_PLAYER_ID)
i{
// code

}
Reply
#8

Okey i'll..
same errors:
PHP код:
[10:25:29] [debugRun time error 4"Array index out of bounds"
[10:25:29] [debug]  Attempted to read/write array element at index 5 in array of size 5
[10:25:29] [debugAMX backtrace:
[
10:25:29] [debug#0 0016201c in public OnPlayerEnterCheckpoint (3) from TDM.amx 
and i will edit onplayerdeath as yu said

PHP код:
[10:26:41] [debug]
[
10:24:29] [debugRun time error 4"Array index out of bounds"
[10:24:29] [debug]  Attempted to read/write array element at index 65535 in array of size 100
[10:24:29] [debugAMX backtrace:
[
10:24:29] [debug#0 00098364 in public FC_OnPlayerDeath (3, 65535, 54) from TDM.amx
[10:24:29] [debug#1 native CallLocalFunction () from samp03svr
[10:24:29] [debug#2 0000e3e8 in public OnPlayerDeath (3, 65535, 54) from TDM.amx
 
Run time error 4"Array index out of bounds"
[10:26:41] [debug]  Attempted to read/write array element at index 65535 in array of size 100
[10:26:41] [debugAMX backtrace:
[
10:26:41] [debug#0 00098364 in public FC_OnPlayerDeath (0, 65535, 255) from TDM.amx
[10:26:41] [debug#1 native CallLocalFunction () from samp03svr
[10:26:41] [debug#2 0000e3e8 in public OnPlayerDeath (0, 65535, 255) from TDM.amx 
PHP код:
[10:32:36] [debugRun time error 4"Array index out of bounds"
[10:32:36] [debug]  Attempted to read/write array element at index 5 in array of size 5
[10:32:36] [debugAMX backtrace:
[
10:32:36] [debug#0 0016201c in public OnPlayerEnterCheckpoint (0) from TDM.amx 
only those ?
about onplayerdeath i'll use ilean code.. but OnPlayerEnterCheckpoint?
Reply
#9

Did you compile with -d3?
Reply
#10

Quote:
Originally Posted by iLearner
Посмотреть сообщение
Did you compile with -d3?
Eh, mind explaining how can I use flags? They don't work on my compiler, maybe I am doing something wrong.

--

The OnVehicleDeath code is wrong.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)