Server Crashes. Rep+ !
#1

Help me please.
EDIT:
Code:
[12:02:59] [debug] Run time error 4: "Array index out of bounds"
[12:02:59] [debug]  Accessing element at index 65535 past array upper bound 1999
[12:02:59] [debug] AMX backtrace:
[12:02:59] [debug] #0 003167a4 in ?? (0, 65535, 2) from Gamemode.amx
[12:02:59] [debug] #1 00268178 in public OnVehicleSpawn (132) from Gamemode.amx
[12:02:59] [debug] #2 native SetVehicleToRespawn () from samp-server.exe
[12:02:59] [debug] #3 0023f0d0 in public Audio_OnGameModeInit () from Gamemode.amx
[12:02:59] [debug] #4 native CallLocalFunction () from samp-server.exe
[12:02:59] [debug] #5 00011650 in public SSCANF_OnGameModeInit () from Gamemode.amx
[12:02:59] [debug] #6 0000b7f8 in public Timers_OnScriptInit () from Gamemode.amx
[12:02:59] [debug] #7 native CallLocalFunction () from samp-server.exe
[12:02:59] [debug] #8 0000b5e8 in public YVers_OnScriptInit () from Gamemode.amx
[12:02:59] [debug] #9 native CallLocalFunction () from samp-server.exe
[12:02:59] [debug] #10 0000a308 in public zcmd_OnGameModeInit () from Gamemode.amx
[12:02:59] [debug] #11 native CallLocalFunction () from samp-server.exe
[12:02:59] [debug] #12 00009d00 in public CB_OnGameModeInit () from Gamemode.amx
[12:02:59] [debug] #13 0000455c in public Itter_OnGameModeInit () from Gamemode.amx
[12:02:59] [debug] #14 native CallLocalFunction () from samp-server.exe
[12:02:59] [debug] #15 00001264 in public OnGameModeInit () from Gamemode.amx
Reply
#2

[06:49:10] [debug] Run time error 4: "Array index out of bounds"

Meaning that you are trying to access an array element that does not exist.

Say, you have created an array like this:
Code:
new myArray = [0, 1, 2]; // not representative code
Now, the array has three positions: 0, 1 and 2 (arrays start at position 0). If you are calling the array like this:
Code:
myArray[3];
Then you will get an array index out of bounds. You are getting this error during server runtime, so it is probably a dynamic field that you are accessing.
Reply
#3

You call a function inside OnVehicleSpawn with index 65535. Even if the code is not too much in this callback and you can find the function (it has 3 parameters), it's still better to compile with -d3 flag and get the name of the function and the exact line: https://github.com/Zeex/samp-plugin-...ith-debug-info
Reply
#4

This is my OnVehicleSpawn code

Code:
public OnVehicleSpawn(vehicleid)
{
    VehicleStatus{vehicleid} = 0;
   	TruckContents[vehicleid] = 0;
	VehicleRadioStation[vehicleid] = 0;
	new Float:X, Float:Y, Float:Z;
	GetDynamicObjectPos(Carrier[0], X, Y, Z);
	if(vehicleid == NGVehicles[0]) SetVehiclePos(vehicleid, (X-40.586371), (Y-5.692918), 11.5239);
	else if(vehicleid == NGVehicles[1]) SetVehiclePos(vehicleid, (X-50.758971), (Y-5.817918), 11.5200);
	else if(vehicleid == NGVehicles[2]) SetVehiclePos(vehicleid, (X-60.754871), (Y-5.590818), 11.5239);
	else if(vehicleid == NGVehicles[3]) SetVehiclePos(vehicleid, (X-89.337771), (Y-8.558118) ,-0.6940);
	else if(vehicleid == NGVehicles[4]) SetVehiclePos(vehicleid, (X-88.546371), (Y-3.55761), -0.7851);
	else if(vehicleid == NGVehicles[5]) SetVehiclePos(vehicleid, (X-83.861371), (Y+9.010282),0.2197);
	else if(vehicleid == NGVehicles[6]) SetVehiclePos(vehicleid, (X-83.788371), (Y+3.149882), -0.2992);
	else if(vehicleid == NGVehicles[7]) SetVehiclePos(vehicleid, (X-66.975571), (Y+2.436018), 2.8996);
	else if(vehicleid == NGVehicles[8]) SetVehiclePos(vehicleid, (X-66.928571), (Y+8.720218), 2.9000);
	else if(vehicleid == NGVehicles[9]) SetVehiclePos(vehicleid, (X-37.527971), (Y-5.000518), 19.5374);
	else if(vehicleid == NGVehicles[10]) SetVehiclePos(vehicleid, (X-49.288871), (Y-4.466818), 19.5374);
	else if(vehicleid == NGVehicles[11]) SetVehiclePos(vehicleid, (X-61.408771), (Y-4.106418), 19.5374);
	else if(vehicleid == NGVehicles[12]) SetVehiclePos(vehicleid, (X+50.462929), (Y-7.469218), 19.5374);
	else if(vehicleid == NGVehicles[13]) SetVehiclePos(vehicleid, (X+62.036429), (Y-7.419918), 19.5374);
	else if(vehicleid == NGVehicles[14]) SetVehiclePos(vehicleid, (X+73.444929), (Y-7.391618), 19.5374);
	else if(vehicleid == NGVehicles[15]) SetVehiclePos(vehicleid, (X+84.864529), (Y-7.157718), 19.5374);
	else if(vehicleid == NGVehicles[16]) SetVehiclePos(vehicleid, (X-75.592971), (Y-7.861318), 20.4642);
	else if(vehicleid == NGVehicles[17]) SetVehiclePos(vehicleid, (X+95.951729), (Y-7.315918), 19.3947);
	else if(vehicleid == NGVehicles[18]) SetVehiclePos(vehicleid, (X+62.937929), (Y+7.680682), 12.5242);
	else if(vehicleid == NGVehicles[19]) SetVehiclePos(vehicleid, (X+62.937929), (Y-2.632818), 12.5242);
	else if(vehicleid == NGVehicles[20]) SetVehiclePos(vehicleid, (X+18.567629), (Y-6.059118), 11.3398);
	else if(vehicleid == NGVehicles[21]) SetVehiclePos(vehicleid, (X+18.567629), (Y-8.597918), 11.3398);
	else if(vehicleid == NGVehicles[22]) SetVehiclePos(vehicleid, (X+18.567629), (Y-11.244118), 11.3398);
	for(new i = 0; i < sizeof(FamilyInfo); i++)
	{
		for(new d = 0 ; d < MAX_GANG_VEHICLES; d++)
		{
			if(FamilyVehicleInfo[i][d][fvLocked] != 0 && FamilyVehicleInfo[i][d][fvLock] > 0)
			{
			    LockGangVehicle(i, FamilyVehicleInfo[i][d][fvId], FamilyVehicleInfo[i][d][fvLock]);
			}
		}
	}
	switch(GetVehicleModel(vehicleid))
	{
		case 427, 428, 432, 601, 528: SetTimerEx("DelayedVehHealth", 1000, false, "d", vehicleid);
	}
    new v;
	foreach(Player, i)
	{
	    v = GetPlayerVehicle(i, vehicleid);
	    if(v != -1)
	    {
 			if(PlayerVehicleInfo[i][v][pvId] == vehicleid && GetVehicleModel(vehicleid) != PlayerVehicleInfo[i][v][pvModelId])
	  		{
	   			DestroyVehicle(vehicleid);
	   			VehicleRadioStation[vehicleid] = 0;
				PlayerVehicleInfo[i][v][pvId] = CreateVehicle(PlayerVehicleInfo[i][v][pvModelId], PlayerVehicleInfo[i][v][pvPosX], PlayerVehicleInfo[i][v][pvPosY], PlayerVehicleInfo[i][v][pvPosZ], PlayerVehicleInfo[i][v][pvPosAngle],PlayerVehicleInfo[i][v][pvColor1], PlayerVehicleInfo[i][v][pvColor2], -1);
				if(PlayerVehicleInfo[i][v][pvLocked] == 1) LockPlayerVehicle(i, PlayerVehicleInfo[i][v][pvId], PlayerVehicleInfo[i][v][pvLock]);
	            ChangeVehiclePaintjob(PlayerVehicleInfo[i][v][pvId], PlayerVehicleInfo[i][v][pvPaintJob]);
				ChangeVehicleColor(PlayerVehicleInfo[i][v][pvId], PlayerVehicleInfo[i][v][pvColor1], PlayerVehicleInfo[i][v][pvColor2]);
				for(new m = 0; m < MAX_MODS; m++)
	   			{
	   			    if(PlayerVehicleInfo[i][v][pvMods][m] >= 1000 && PlayerVehicleInfo[i][v][pvMods][m] <= 1193)
	   			    {
		   				if(InvalidModCheck(GetVehicleModel(vehicleid), PlayerVehicleInfo[i][v][pvMods][m]))
		      			{
		      				AddVehicleComponent(PlayerVehicleInfo[i][v][pvId], PlayerVehicleInfo[i][v][pvMods][m]);
		      			}
		      			else
		      			{
		      			    //printf("Removing invalid mod %d from %d of %s", PlayerVehicleInfo[i][v][pvMods][m], GetVehicleModel(vehicleid), GetPlayerNameEx(i));
		      			    PlayerVehicleInfo[i][v][pvMods][m] = 0;
		      			}
					}
	      		}
 			}
 			else
			{
                ChangeVehiclePaintjob(vehicleid, PlayerVehicleInfo[i][v][pvPaintJob]);
				ChangeVehicleColor(vehicleid, PlayerVehicleInfo[i][v][pvColor1], PlayerVehicleInfo[i][v][pvColor2]);
				for(new m = 0; m < MAX_MODS; m++)
	            {
	                if(PlayerVehicleInfo[i][v][pvMods][m] >= 1000 && PlayerVehicleInfo[i][v][pvMods][m] <= 1193)
	   			    {
			            if(InvalidModCheck(GetVehicleModel(vehicleid), PlayerVehicleInfo[i][v][pvMods][m]))
		                {
		    	            AddVehicleComponent(PlayerVehicleInfo[i][v][pvId], PlayerVehicleInfo[i][v][pvMods][m]);
			            }
			            else
			            {
			                //printf("Removing invalid mod %d from %d of %s", PlayerVehicleInfo[i][v][pvMods][m], GetVehicleModel(vehicleid), GetPlayerNameEx(i));
			                PlayerVehicleInfo[i][v][pvMods][m] = 0;
			            }
					}
	            }
	            if(PlayerVehicleInfo[i][v][pvLocked] == 1) LockPlayerVehicle(i, PlayerVehicleInfo[i][v][pvId], PlayerVehicleInfo[i][v][pvLock]);
			}
			if(IsATruckerCar(vehicleid))
			{
			    TruckPackages[vehicleid] = -1;
			}
			new string[128];
			format(string,sizeof(string),"Your %s has been sent to the location at which you last parked it.",GetVehicleName(vehicleid));
			SCM(i, COLOR_GRAD1, string);
		}
	}
	if(LockStatus[vehicleid])
	{
		foreach(Player, i)
		{
			if(PlayerInfo[i][pLockCar] == vehicleid)
			{
				PlayerInfo[i][pLockCar] = INVALID_VEHICLE_ID;
			}
		}
	}
	if(VehicleBomb{vehicleid} == 1)
	{
		foreach(Player, i)
		{
			if(PlayerInfo[i][pFaction] == 4 || PlayerInfo[i][pLeader] == 4)
			{
				if(PlacedVehicleBomb[i] == vehicleid)
				{
					VehicleBomb{vehicleid} = 0;
  					PlacedVehicleBomb[i] = INVALID_VEHICLE_ID;
					PickUpC4(i);
					PlayerInfo[i][pC4Used] = 0;
					PlayerInfo[i][pC4Get] = 1;
				}
			}
		}
	}
	return 1;
}
Reply
#5

pawn Code:
for(new i = 0; i < sizeof(FamilyInfo); i++)
{
    for(new d = 0 ; d < MAX_GANG_VEHICLES; d++)
    {
        if(FamilyVehicleInfo[i][d][fvLocked] != 0 && FamilyVehicleInfo[i][d][fvLock] > 0)
        {
            LockGangVehicle(i, FamilyVehicleInfo[i][d][fvId], FamilyVehicleInfo[i][d][fvLock]);
        }
    }
}
FamilyVehicleInfo[i][d][fvId] is INVALID_VEHICLE_ID. You could check if it's not before calling LockGangVehicle:
pawn Code:
if(FamilyVehicleInfo[i][d][fvLocked] != 0 && FamilyVehicleInfo[i][d][fvLock] > 0 && FamilyVehicleInfo[i][d][fvId] != INVALID_VEHICLE_ID)
or in case the reset value is changed to be more accurate:
pawn Code:
if(FamilyVehicleInfo[i][d][fvLocked] != 0 && FamilyVehicleInfo[i][d][fvLock] > 0 && 1 <= FamilyVehicleInfo[i][d][fvId] <= 1999)
That will prevent the run time error from OnPlayerSpawn but if LockGangVehicle is called elsewhere and carid is still a valid, you'll need to modify that function as well.
Reply
#6

I change from

Code:
	for(new i = 0; i < sizeof(FamilyInfo); i++)
	{
		for(new d = 0 ; d < MAX_GANG_VEHICLES; d++)
		{
			if(FamilyVehicleInfo[i][d][fvLocked] != 0 && FamilyVehicleInfo[i][d][fvLock] > 0)
			{
			    LockGangVehicle(i, FamilyVehicleInfo[i][d][fvId], FamilyVehicleInfo[i][d][fvLock]);
			}
		}
	}
to

Code:
	for(new i = 0; i < sizeof(FamilyInfo); i++)
	{
		for(new d = 0 ; d < MAX_GANG_VEHICLES; d++)
		{
			if(FamilyVehicleInfo[i][d][fvLocked] != 0 && FamilyVehicleInfo[i][d][fvLock] > 0 && 0 <= FamilyVehicleInfo[i][d][fvId] <= 1999)
			{
			    LockGangVehicle(i, FamilyVehicleInfo[i][d][fvId], FamilyVehicleInfo[i][d][fvLock]);
			}
		}
	}
like you said and still having the same error..

Code:
[11:34:17] [debug] Run time error 4: "Array index out of bounds"
[11:34:17] [debug]  Accessing element at index 65535 past array upper bound 1999
[11:34:17] [debug] AMX backtrace:
[11:34:17] [debug] #0 003167a4 in ?? (0, 65535, 2) from Gamemode.amx
[11:34:17] [debug] #1 00268178 in public OnVehicleSpawn (132) from Gamemode.amx
[11:34:17] [debug] #2 native SetVehicleToRespawn () from samp-server.exe
[11:34:17] [debug] #3 0023f0d0 in public Audio_OnGameModeInit () from Gamemode.amx
[11:34:17] [debug] #4 native CallLocalFunction () from samp-server.exe
[11:34:17] [debug] #5 00011650 in public SSCANF_OnGameModeInit () from Gamemode.amx
[11:34:17] [debug] #6 0000b7f8 in public Timers_OnScriptInit () from Gamemode.amx
[11:34:17] [debug] #7 native CallLocalFunction () from samp-server.exe
[11:34:17] [debug] #8 0000b5e8 in public YVers_OnScriptInit () from Gamemode.amx
[11:34:17] [debug] #9 native CallLocalFunction () from samp-server.exe
[11:34:17] [debug] #10 0000a308 in public zcmd_OnGameModeInit () from Gamemode.amx
[11:34:17] [debug] #11 native CallLocalFunction () from samp-server.exe
[11:34:17] [debug] #12 00009d00 in public CB_OnGameModeInit () from Gamemode.amx
[11:34:17] [debug] #13 0000455c in public Itter_OnGameModeInit () from Gamemode.amx
[11:34:17] [debug] #14 native CallLocalFunction () from samp-server.exe
[11:34:17] [debug] #15 00001264 in public OnGameModeInit () from Gamemode.amx
Reply
#7

The above is not compiled with -d3 so we can get the exact line, that's why I told you to compile with that flag. Also I told you to the other thread you made to post LockGangVehicle because it's no use to try to prevent the places it gets called instead the function itself to prevent the run time errors.

The above is caused by this:
pawn Code:
if(PlayerVehicleInfo[i][v][pvLocked] == 1) LockPlayerVehicle(i, PlayerVehicleInfo[i][v][pvId], PlayerVehicleInfo[i][v][pvLock]);
Post the LockPlayerVehicle function because if there are more places it's called with INVALID_VEHICLE_ID, it will keep giving the run time error.
Reply
#8

Code:
LockGangVehicle(family, carid, type)
{
	new v = GetGangVehicle(family, carid);
	if(FamilyVehicleInfo[family][v][fvId] == carid && type == 2)
	{
	    LockStatus[carid] = 1;
		vehicle_lock_doors(carid);
	}
}
Reply
#9

pawn Code:
LockGangVehicle(family, carid, type)
{
    if (!GetVehicleModel(carid)) return 0;

    new v = GetGangVehicle(family, carid);
    if(FamilyVehicleInfo[family][v][fvId] == carid && type == 2)
    {
        LockStatus[carid] = 1;
        vehicle_lock_doors(carid);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)