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

hello, i have a problem on the server that servers often have frozen and the player can not join to server, then I put crashdetect and I opened server_log.txt and there is an error, I am very confused as to fix the error such as this.

Код:
[06:17:23] [debug] Run time error 4: "Array index out of bounds"
[06:17:23] [debug]  Accessing element at index 65535 past array upper bound 1999
[06:17:23] [debug] AMX backtrace:
[06:17:23] [debug] #0 00073a8c in public zcmd_OnGameModeInit () from KGTDM.amx
[06:17:23] [debug] #1 native CallLocalFunction () from samp03svr
[06:17:23] [debug] #2 0000e834 in public moneyhax_OnGameModeInit () from KGTDM.amx
[06:17:23] [debug] #3 native CallLocalFunction () from samp03svr
[06:17:23] [debug] #4 0000e6a0 in public Itter_OnGameModeInit () from KGTDM.amx
[06:17:23] [debug] #5 native CallLocalFunction () from samp03svr
[06:17:23] [debug] #6 0000d838 in public SSCANF_OnGameModeInit () from KGTDM.amx
[06:17:23] [debug] #7 00007564 in public OnGameModeInit () from KGTDM.amx
Reply
#2

Update zcmd and incorporate it in your gamemode correctly:

pawn Код:
include <zcmd
Show us your OnGameModeInit callback aswell.
Reply
#3

Quote:
Originally Posted by Twizted
Посмотреть сообщение
Update zcmd and incorporate it in your gamemode correctly:

pawn Код:
include <zcmd
Show us your OnGameModeInit callback aswell.
I 've been using the latest zcmd,but same still appear debbug, this my OnGameModeInit:
Код:
public OnGameModeInit()
{
//------------------------------------Text Name---------------------------------
	Blank = TextDrawCreate(0, 0, "");

	KhususGaming = TextDrawCreate(499.000000, 96.000000, "~r~Khusus ~w~Gaming");
	TextDrawFont(KhususGaming, 0);
	TextDrawLetterSize(KhususGaming, 0.559999, 1.600000);
	TextDrawColor(KhususGaming, 255);
	TextDrawSetOutline(KhususGaming, 1);
	TextDrawSetProportional(KhususGaming, 1);

	SATDM = TextDrawCreate(499.000000, 111.000000, "~r~M~w~O~r~D~r~E ~w~S~r~A~w~T~r~D~w~M");
	TextDrawBackgroundColor(SATDM, 255);
	TextDrawFont(SATDM, 2);
	TextDrawLetterSize(SATDM, 0.350000, 1.200000);
	TextDrawColor(SATDM, -175963905);
	TextDrawSetOutline(SATDM, 1);
	TextDrawSetProportional(SATDM, 1);

	CMDS = TextDrawCreate(10,430.000000,"~w~Server Commands: /menucmds /help /commands /tele /rules /report /stats /top");
	TextDrawFont(CMDS, 2);
	TextDrawLetterSize(CMDS, 0.20000, 1.200000);
	TextDrawSetOutline(CMDS, 1);
	TextDrawSetProportional(CMDS, 1);

	text_Top5[0] = TextDrawCreate(79.000000, 135.000000, "Top 5");
	TextDrawAlignment(text_Top5[0], 2);
	TextDrawBackgroundColor(text_Top5[0], 255);
	TextDrawFont(text_Top5[0], 1);
	TextDrawLetterSize(text_Top5[0], 0.280000, 1.499999);
	TextDrawColor(text_Top5[0], -1);
	TextDrawSetOutline(text_Top5[0], 0);
	TextDrawSetProportional(text_Top5[0], 1);
	TextDrawSetShadow(text_Top5[0], 0);

	text_Top5[1] = TextDrawCreate(16.000000, 135.000000, " ");
	TextDrawBackgroundColor(text_Top5[1], 255);
	TextDrawFont(text_Top5[1], 1);
	TextDrawLetterSize(text_Top5[1], 0.200000, 0.999999);
	TextDrawColor(text_Top5[1], -1);
	TextDrawSetOutline(text_Top5[1], 0);
	TextDrawSetProportional(text_Top5[1], 1);
	TextDrawSetShadow(text_Top5[1], 0);
	TextDrawUseBox(text_Top5[1], 1);
	TextDrawBoxColor(text_Top5[1], 150);
	TextDrawTextSize(text_Top5[1], 143.000000, 20.000000);

	text_Level[0] = TextDrawCreate(79.000000, 135.000000, "Top Levels");
	TextDrawAlignment(text_Level[0], 2);
	TextDrawBackgroundColor(text_Level[0], 255);
	TextDrawFont(text_Level[0], 1);
	TextDrawLetterSize(text_Level[0], 0.280000, 1.499999);
	TextDrawColor(text_Level[0], -1);
	TextDrawSetOutline(text_Level[0], 0);
	TextDrawSetProportional(text_Level[0], 1);
	TextDrawSetShadow(text_Level[0], 0);

	text_Level[1] = TextDrawCreate(16.000000, 135.000000, " ");
	TextDrawBackgroundColor(text_Level[1], 255);
	TextDrawFont(text_Level[1], 1);
	TextDrawLetterSize(text_Level[1], 0.200000, 0.999999);
	TextDrawColor(text_Level[1], -1);
	TextDrawSetOutline(text_Level[1], 0);
	TextDrawSetProportional(text_Level[1], 1);
	TextDrawSetShadow(text_Level[1], 0);
	TextDrawUseBox(text_Level[1], 1);
	TextDrawBoxColor(text_Level[1], 150);
	TextDrawTextSize(text_Level[1], 143.000000, 20.000000);

	foreach(Player,i)
 	{
			TextDrawShowForPlayer(i, Blank);
			TextDrawShowForPlayer(i, KhususGaming);
			TextDrawShowForPlayer(i, SATDM);
			TextDrawShowForPlayer(i, CMDS);
	}
//-------------------------------Junk Buster------------------------------------
	dini_Remove(BAD_RCON_LOGIN_FILE);
	dini_Create(BAD_RCON_LOGIN_FILE);

	ConfigJunkBuster();
	SetTimer("JunkBuster",1000,true);
	SetTimer("GlobalUpdate",60*1000*4,true);// Every 4 minutes
	SetTimer("SpamUpdate",3500,true);
	SetTimer("TempBanUpdate",1000*60*60,true);// Every hour
	if(JB_Variables[WARN_PLAYERS])
	    SendRconCommand("mapname JunkBuster Anti-Cheat");
	JB_Log("JunkBuster has successfully been loaded.");
//---------------------------Gamemode Settings----------------------------------
	print("\nLoading Gamemode(SATDM~RP)");
	SetGameModeText("SATDM");
	ShowNameTags(1);
	ShowPlayerMarkers(1);
	SetWorldTime(12);
	UsePlayerPedAnims();
//----------------------------------Timers--------------------------------------
	SetTimer("load",2000,0);
	SetTimer("PayDay",3600000,1);
	SetTimer("PhoneCut",1010,1);
	SetTimer("VHPBarUpdate",1005,1);
	SetTimer("BackupInfo",120003,1);
	SetTimer("VehicleCleanup",600000,1);
    ORTimer = SetTimer("ORCheck",300,true);
	SetTimer("SendMSG", 60000*3, true);
	SetTimer("Bonus3Hours", 5400000*2, true);
    TimeReaction = SetTimer("NewReaction", 180000, 0);
   	startTimer = SetTimer("startLMS", 60*1000*4, 0);
	IsLMSactive = 0;
	lmsrank = 0;
	SetTimer("TimeU",1000,true);
    Servt=TextDrawCreate(545, 31, "00:00");
    TextDrawColor(Servt, COLOR_WHITE);
    Tsec= 0;
    THrs= 0;

	GGateTimer = SetTimer("GateTimer", TIMERSPEED, true);
//-------------------------------------------------------------------------------

	foreach(Player,i){ OnPlayerConnect(i);}
	for(new i = 1; i < MAX_CHAT_LINES; i++) Chat[i] = "<none>";
	for(new i = 1; i < MAX_REPORTS; i++) Reports[i] = "<none>";

	PingTimer = SetTimer("PingKick",10000,1);
	GodTimer = SetTimer("GodUpdate",2000,1);

	new year,month,day;	getdate(year, month, day);
	new hour,minute,second; gettime(hour,minute,second);

	print("________________________________________");
	print("           LAdmin Version 4.0           ");
	print("                Loaded                  ");
	print("________________________________________");
	printf("     Date: %d/%d/%d  Time: %d:%d :%d   ",day,month,year, hour, minute, second);
	print("________________________________________");
	print("________________________________________\n");
//--------------------------------Load Businesses-------------------------------
	for(new i = 0;i<3;i++) {
		CreateDynamicPickup(1239,B_ICON_TYPE,Pickup[i][0],Pickup[i][1],Pickup[i][2]);
	}
	bizcount = CountBusinesses(B_FILE_LOAD);
	LoadBusinesses();
	print(">--------------------------------------------------------------------------");
 	new bizmess[50];
 	format(bizmess,50,"%d Businesses Successfully loaded and created",bizcount);
 	printf(bizmess);
//--------------------------------Load Vehicles---------------------------------
    vehcount = CountVehicles(V_FILE_LOAD);
	LoadVehicles();
 	for(new c=1;c<=vehcount;c++)
	{
	 	ModVehicle©;
 	}
 	new vehmess[50];
 	format(vehmess,50,"%d Vehicles Successfully loaded and created",vehcount);
 	printf(vehmess);
	print(">--------------------------------------------------------------------------");
 	printf("");
	print(">--------------------------------------------------------------------------");
	print("Business and Vehicle Systems Status - 100% - Systems Ready...");
	print(">--------------------------------------------------------------------------");

//---------------------------Vehicle healthbar stuff----------------------------

 	vehiclehpbar[0] = TextDrawCreate(549.0, 50.0, "KABOOM!");
	TextDrawUseBox(vehiclehpbar[0], true);
	TextDrawBoxColor(vehiclehpbar[0], COLOR_BRIGHTRED);
	TextDrawSetShadow(vehiclehpbar[0],0);
	TextDrawTextSize(vehiclehpbar[0], 625, 0);

	vehiclehpbar[1] = TextDrawCreate(551.0, 59.0, " ");
	TextDrawUseBox(vehiclehpbar[1], true);
	TextDrawBoxColor(vehiclehpbar[1], COLOR_BRIGHTRED);
	TextDrawSetShadow(vehiclehpbar[1],0);
	TextDrawTextSize(vehiclehpbar[1], 551, 0);

	vehiclehpbar[2] = TextDrawCreate(551.0, 59.0, " ");
	TextDrawUseBox(vehiclehpbar[2], true);
	TextDrawBoxColor(vehiclehpbar[2], COLOR_BRIGHTRED);
	TextDrawSetShadow(vehiclehpbar[2],0);
	TextDrawTextSize(vehiclehpbar[2], 556, 0);

	vehiclehpbar[3] = TextDrawCreate(551.0, 59.0, " ");
	TextDrawUseBox(vehiclehpbar[3], true);
	TextDrawBoxColor(vehiclehpbar[3], COLOR_BRIGHTRED);
	TextDrawSetShadow(vehiclehpbar[3],0);
	TextDrawTextSize(vehiclehpbar[3], 561, 0);

	vehiclehpbar[4] = TextDrawCreate(551.0, 59.0, " ");
	TextDrawUseBox(vehiclehpbar[4], true);
	TextDrawBoxColor(vehiclehpbar[4], COLOR_YELLOW);
	TextDrawSetShadow(vehiclehpbar[4],0);
	TextDrawTextSize(vehiclehpbar[4], 566, 0);

	vehiclehpbar[5] = TextDrawCreate(551.0, 59.0, " ");
	TextDrawUseBox(vehiclehpbar[5], true);
	TextDrawBoxColor(vehiclehpbar[5], COLOR_YELLOW);
	TextDrawSetShadow(vehiclehpbar[5],0);
	TextDrawTextSize(vehiclehpbar[5], 571, 0);

	vehiclehpbar[6] = TextDrawCreate(551.0, 59.0, " ");
	TextDrawUseBox(vehiclehpbar[6], true);
	TextDrawBoxColor(vehiclehpbar[6], COLOR_YELLOW);
	TextDrawSetShadow(vehiclehpbar[6],0);
	TextDrawTextSize(vehiclehpbar[6], 576, 0);

	vehiclehpbar[7] = TextDrawCreate(551.0, 59.0, " ");
	TextDrawUseBox(vehiclehpbar[7], true);
	TextDrawBoxColor(vehiclehpbar[7], COLOR_YELLOW);
	TextDrawSetShadow(vehiclehpbar[7],0);
	TextDrawTextSize(vehiclehpbar[7], 581, 0);

	vehiclehpbar[8] = TextDrawCreate(551.0, 59.0, " ");
	TextDrawUseBox(vehiclehpbar[8], true);
	TextDrawBoxColor(vehiclehpbar[8], COLOR_GREEN);
	TextDrawSetShadow(vehiclehpbar[8],0);
	TextDrawTextSize(vehiclehpbar[8], 586, 0);

	vehiclehpbar[9] = TextDrawCreate(551.0, 59.0, " ");
	TextDrawUseBox(vehiclehpbar[9], true);
	TextDrawBoxColor(vehiclehpbar[9], COLOR_GREEN);
	TextDrawSetShadow(vehiclehpbar[9],0);
	TextDrawTextSize(vehiclehpbar[9], 591, 0);

	vehiclehpbar[10] = TextDrawCreate(551.0, 59.0, " ");
	TextDrawUseBox(vehiclehpbar[10], true);
	TextDrawBoxColor(vehiclehpbar[10], COLOR_GREEN);
	TextDrawSetShadow(vehiclehpbar[10],0);
	TextDrawTextSize(vehiclehpbar[10], 596, 0);

	vehiclehpbar[11] = TextDrawCreate(551.0, 59.0, " ");
	TextDrawUseBox(vehiclehpbar[11], true);
	TextDrawBoxColor(vehiclehpbar[11], COLOR_GREEN);
	TextDrawSetShadow(vehiclehpbar[11],0);
	TextDrawTextSize(vehiclehpbar[11], 602, 0);

	vehiclehpbar[12] = TextDrawCreate(549.0, 50.0, "EXTREME!");
	TextDrawUseBox(vehiclehpbar[12], true);
	TextDrawBoxColor(vehiclehpbar[12], COLOR_GREEN);
	TextDrawSetShadow(vehiclehpbar[12],0);
	TextDrawTextSize(vehiclehpbar[12], 625, 0);
//----------------------------------Speedo--------------------------------------
	SetTimer("LuX_SpeedoMeterUp", UpdateSpeed, 1);
	for(new v=0; v<MAX_VEHICLES; v++){
	LuX_ReadPosition(v);}
	for(new i=0; i<PLAYERS; i++){
		//---------------------------------------------------------->
		#if TextBox
		LBox[i] = TextDrawCreate(612.000000,342.000000,"C");
		TextDrawUseBox(LBox[i],1);
		TextDrawBoxColor(LBox[i],0x00000033);
		TextDrawTextSize(LBox[i],454.000000,9.000000);
		TextDrawAlignment(LBox[i],0);
		TextDrawBackgroundColor(LBox[i],0x000000ff);
		TextDrawFont(LBox[i],3);
		TextDrawLetterSize(LBox[i],-0.000000,8.700001);
		TextDrawColor(LBox[i],BoxColor);
		TextDrawSetOutline(LBox[i],1);
		TextDrawSetProportional(LBox[i],1);
		TextDrawSetShadow(LBox[i],1);
		#endif
		//---------------------------------------------------------->
		#if TextTopLines
		LLine1[i] = TextDrawCreate(609.000000,341.000000,"L");
		TextDrawUseBox(LLine1[i],1);
		TextDrawBoxColor(LLine1[i],0xffffff33);
		TextDrawTextSize(LLine1[i],457.000000,-1.000000);
		TextDrawAlignment(LLine1[i],0);
		TextDrawBackgroundColor(LLine1[i],0x000000ff);
		TextDrawFont(LLine1[i],3);
		TextDrawLetterSize(LLine1[i],-0.000000,-0.400000);
		TextDrawColor(LLine1[i],TopLinesColor);
		TextDrawSetOutline(LLine1[i],1);
		TextDrawSetProportional(LLine1[i],1);
		TextDrawSetShadow(LLine1[i],1);
		//---------------------------------------------------------->
		LLine2[i] = TextDrawCreate(609.000000,416.000000,"L");
		TextDrawUseBox(LLine2[i],1);
		TextDrawBoxColor(LLine2[i],0xffffff33);
		TextDrawTextSize(LLine2[i],457.000000,-9.000000);
		TextDrawBackgroundColor(LLine2[i],0x000000ff);
		TextDrawFont(LLine2[i],3);
		TextDrawLetterSize(LLine2[i],-0.000000,-0.400000);
		TextDrawColor(LLine2[i],TopLinesColor);
		TextDrawSetOutline(LLine2[i],1);
		TextDrawSetProportional(LLine2[i],1);
		TextDrawSetShadow(LLine2[i],1);
		#endif
		//---------------------------------------------------------->
		#if LogoName
		LCredits[i] = TextDrawCreate(487.000000,320.000000,SpeedoLogoText);
		TextDrawAlignment(LCredits[i],0);
		TextDrawBackgroundColor(LCredits[i],0x000000ff);
		TextDrawFont(LCredits[i],0);
		TextDrawLetterSize(LCredits[i],0.399999,1.400000);
		TextDrawColor(LCredits[i],LogoColor);
		TextDrawSetOutline(LCredits[i],1);
		TextDrawSetProportional(LCredits[i],1);
		TextDrawSetShadow(LCredits[i],1);
		#endif
		//---------------------------------------------------------->
		#if TextSideLines
		LLine3[i] = TextDrawCreate(466.000000,343.000000,"T");
		TextDrawUseBox(LLine3[i],1);
		TextDrawBoxColor(LLine3[i],0xffffff33);
		TextDrawTextSize(LLine3[i],457.000000,0.000000);
		TextDrawAlignment(LLine3[i],0);
		TextDrawBackgroundColor(LLine3[i],0x000000ff);
		TextDrawFont(LLine3[i],3);
		TextDrawLetterSize(LLine3[i],-0.000000,7.499998);
		TextDrawColor(LLine3[i],SideLinesColor);
		TextDrawSetOutline(LLine3[i],1);
		TextDrawSetProportional(LLine3[i],1);
		TextDrawSetShadow(LLine3[i],1);
		//---------------------------------------------------------->
		LLine4[i] = TextDrawCreate(607.000000,343.000000,"T");
		TextDrawUseBox(LLine4[i],1);
		TextDrawBoxColor(LLine4[i],0xffffff33);
		TextDrawTextSize(LLine4[i],603.000000,-6.000000);
		TextDrawAlignment(LLine4[i],0);
		TextDrawBackgroundColor(LLine4[i],0x000000ff);
		TextDrawFont(LLine4[i],3);
		TextDrawLetterSize(LLine4[i],-0.000000,7.499999);
		TextDrawColor(LLine4[i],SideLinesColor);
		TextDrawSetOutline(LLine4[i],1);
		TextDrawSetProportional(LLine4[i],1);
		TextDrawSetShadow(LLine4[i],1);
		#endif
		//---------------------------------------------------------->
		format(lstring, sizeof(lstring), "Initializing...");
		LFunc[i] = TextDrawCreate(466.000000,343.000000,lstring);
		TextDrawAlignment(LFunc[i],0);
		TextDrawBackgroundColor(LFunc[i],0x000000ff);
		TextDrawFont(LFunc[i],1);
		TextDrawLetterSize(LFunc[i],0.299999,1.200000);
		TextDrawColor(LFunc[i],0xffffffff);
		TextDrawSetOutline(LFunc[i],1);
		TextDrawSetProportional(LFunc[i],1);
		TextDrawSetShadow(LFunc[i],1);
		//---------------------------------------------------------->
		format(lstr, sizeof(lstr), "Initializing...");
		Lmph[i] = TextDrawCreate(466.000000,400.000000,lstr);
		TextDrawAlignment(Lmph[i],0);
		TextDrawBackgroundColor(Lmph[i],0x000000ff);
		TextDrawFont(Lmph[i],1);
		TextDrawLetterSize(Lmph[i],0.299999,1.000000);
		TextDrawColor(Lmph[i],0xffffffff);
		TextDrawSetOutline(Lmph[i],1);
		TextDrawSetProportional(Lmph[i],1);
		TextDrawSetShadow(Lmph[i],1);
	}

	new train1 = AddStaticVehicle(538,1462.0745,2630.8787,10.8203,200.0,-1,-1);
	VehicleInfo[train1][Temp] = 1;
	new train2 = AddStaticVehicle(538,1700.7551,-1953.6531,14.8756,200.0,-1,-1);
	VehicleInfo[train2][Temp] = 1;
	new train3 = AddStaticVehicle(538,-1948.4922,121.7808,25.7186,0.0,121,1);
	VehicleInfo[train3][Temp] = 1;

	for ( new playerid; playerid < MAX_PLAYERS; playerid++ )
	{
		if ( IsPlayerConnected( playerid ) )
			AntiFlood_InitPlayer( playerid );
	}
	return 1;
}
Reply
#4

Sorry bump because i confused
Reply
#5

Related to vehicles. An array with a size of MAX_VEHICLES (i.e. 2000) has accessible indices 0 through 1999. The value 65535 (or 0xFFFF in hexadecimal) is the definition of INVALID_VEHICLE_ID. AddStaticVehicle and CreateVehicle will return this value if you are over the limit.

Likely cause is the trains. Remove them and try again.
Reply
#6

Quote:
Originally Posted by Vince
Посмотреть сообщение
Related to vehicles. An array with a size of MAX_VEHICLES (i.e. 2000) has accessible indices 0 through 1999. The value 65535 (or 0xFFFF in hexadecimal) is the definition of INVALID_VEHICLE_ID. AddStaticVehicle and CreateVehicle will return this value if you are over the limit.

Likely cause is the trains. Remove them and try again.
I had to fix it by removing sscanf include and deleting train and debbug not reappear , but new problems arise , namely:
Код:
[00:43:17] [debug] Run time error 4: "Array index out of bounds"
[00:43:17] [debug]  Accessing element at index 4 past array upper bound 3
[00:43:17] [debug] AMX backtrace:
[00:43:17] [debug] #0 000d8320 in public PingKick () from KGTDM.amx
Код:
forward PingKick();
public PingKick()
{
	if(ServerInfo[MaxPing] != 0)
	{
	    PingPos++; if(PingPos > PING_MAX_EXCEEDS) PingPos = 0;

  		for(new i=0; i<MAX_PLAYERS; i++)
		{
			PlayerInfo[i][pPing][PingPos] = GetPlayerPing(i);

		    if(GetPlayerPing(i) > ServerInfo[MaxPing])
			{
				if(PlayerInfo[i][PingCount] == 0) PlayerInfo[i][PingTime] = TimeStamp();

	   			PlayerInfo[i][PingCount]++;
				if(TimeStamp() - PlayerInfo[i][PingTime] > PING_TIMELIMIT)
				{
	    			PlayerInfo[i][PingTime] = TimeStamp();
					PlayerInfo[i][PingCount] = 1;
				}
				else if(PlayerInfo[i][PingCount] >= PING_MAX_EXCEEDS)
				{
				    new Sum, Average, x, string[128];
					while (x < PING_MAX_EXCEEDS) {
						Sum += PlayerInfo[i][pPing][x];
						x++;
					}
					Average = (Sum / PING_MAX_EXCEEDS);
					format(string,sizeof(string),"%s has been kicked from the server. (Reason: High Ping (%d) | Average (%d) | Max Allowed (%d) )", PlayerName2(i), GetPlayerPing(i), Average, ServerInfo[MaxPing] );
  		    		SendClientMessageToAll(grey,string);
					SaveToFile("KickLog",string);
					Kick(i);
				}
			}
			else if(GetPlayerPing(i) < 1 && ServerInfo[AntiBot] == 1)
		    {
				PlayerInfo[i][BotPing]++;
				if(PlayerInfo[i][BotPing] >= 3) BotCheck(i);
		    }
		    else
			{
				PlayerInfo[i][BotPing] = 0;
			}
		}
	}

	#if defined ANTI_MINIGUN
	new weap, ammo;
  	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i) && PlayerInfo[i][Level] == 0)
		{
			GetPlayerWeaponData(i, 7, weap, ammo);
			if(ammo > 1 && weap == 38) {
				new string[128]; format(string,sizeof(string),"INFO: %s has a mingun with %d ammo", PlayerName2(i), ammo);
				MessageToAdmins(COLOR_WHITE,string);
			}
		}
	}
	#endif
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)