Server log strange errors
#1

i found that on server log, what its all means?


Код:
] Run time error 4: "Array index out of bounds"
[22:40:27] [debug]  Accessing element at index 65535 past array upper bound 499
[22:40:27] [debug] AMX backtrace:
[22:40:27] [debug] #0 004353c8 in public @yT_1000_ServerHeartbeatTwo () from CGRP.amx
[22:40:28] [debug] Run time error 4: "Array index out of bounds"
[22:40:28] [debug]  Accessing element at index 65535 past array upper bound 499
[22:40:28] [debug] AMX backtrace:
[22:40:28] [debug] #0 004353c8 in public @yT_1000_ServerHeartbeatTwo () from CGRP.amx
[22:40:30] [debug] Run time error 4: "Array index out of bounds"
[22:40:30] [debug]  Accessing element at index 65535 past array upper bound 499
[22:40:30] [debug] AMX backtrace:
[22:40:30] [debug] #0 004353c8 in public @yT_1000_ServerHeartbeatTwo () from CGRP.amx
[22:40:30] [zcmd] [Jack Carter]: /enter
[22:40:31] [debug] Run time error 4: "Array index out of bounds"
[22:40:31] [debug]  Accessing element at index 65535 past array upper bound 499
[22:40:31] [debug] AMX backtrace:
[22:40:31] [debug] #0 004353c8 in public @yT_1000_ServerHeartbeatTwo () from CGRP.amx
[22:40:32] [debug] Run time error 4: "Array index out of bounds"
[22:40:32] [debug]  Accessing element at index 65535 past array upper bound 499
[22:40:32] [debug] AMX backtrace:
[22:40:32] [debug] #0 004353c8 in public @yT_1000_ServerHeartbeatTwo () from CGRP.amx
[22:40:32] [zcmd] [Adi Bruner]: /awtihdraw 20000
[22:40:33] [debug] Run time error 4: "Array index out of bounds"
Reply
#2

Check if the player is valid first.
Reply
#3

What do you mean if the player valid first?
Reply
#4

Is ServerHeartbeatTwo a timer from y_timers? Anyways, let's say you pass a playerid in an array. Check if the playerid is valid first, because it passes 65535 (INVALID_PLAYER_ID) when the max is MAX_PLAYERS (0-499).

It's better to show us that public in order to explain you better and fix it. I can't guess what your code would be.
Reply
#5

Here's the ServerHeartbeatTwo timer, Konstantinos i scripter beginner plus on pawn so if you can tell me what's the problem here and explain me...

Код:
// Timer Name: ServerHeartbeatTwo()
// TickRate: 1 secs.
Timer:ServerHeartbeatTwo[1000]()
{
	new Float:oldposx, Float:oldposy, Float:oldposz;
	foreach(Player, i)
	{
		if(IsPlayerInAnyVehicle(i)) {
			if(GetPlayerState(i) == PLAYER_STATE_DRIVER) SetPlayerArmedWeapon(i, 0);
			else if(PlayerInfo[i][pGuns][4] == 0) SetPlayerArmedWeapon(i, 0);
			else SetPlayerArmedWeapon(i, 29);
		}
		if(GetPlayerSpecialAction(i) == SPECIAL_ACTION_USEJETPACK && JetPack[i] == 0 && PlayerInfo[i][pAdmin] < 4)
		{
			new string[74 + MAX_PLAYER_NAME];
		    format( string, sizeof( string ), "{AA3333}AdmWarning{FFFF00}: %s (ID %d) may possibly be jetpack hacking.", GetPlayerNameEx(i), i);
			ABroadCast( COLOR_YELLOW, string, 2 );
			format(string, sizeof(string), "%s (ID %d) may possibly be jetpack hacking.", GetPlayerNameEx(i), i);
			Log("logs/hack.log", string);
		}
		if( IsPlayerInRangeOfPoint( i, 2, 1544.2, -1353.4, 329.4 ) )
		{
		    GivePlayerValidWeapon( i, 46, 9 );
		}
		if(GetPlayerState(i) == PLAYER_STATE_ONFOOT) for(new h = 0; h < sizeof(FamilyInfo); h++)
		{
			if(IsPlayerInRangeOfPoint(i, 2.0, FamilyInfo[h][FamilySafe][0], FamilyInfo[h][FamilySafe][1], FamilyInfo[h][FamilySafe][2]))
			{
				if(FamilyInfo[h][FamilyUSafe] == 1)
				{
					GameTextForPlayer(i, "~y~gang safe~w~~n~Type ~r~/safehelp~w~ for more information", 5000, 3);
				}
			}
		}
		for(new h = 0; h < sizeof(Points); h++)
		{
			if(IsPlayerInRangeOfPoint(i, 2.0, Points[h][Pointx], Points[h][Pointy], Points[h][Pointz]))
			{
				if(Points[h][Type] == 1 && GetPVarInt(i, "Packages") == 0)
				{
					GameTextForPlayer(i, "~w~Type /getmats to purchase a ~n~~r~materials package", 5000, 5);
				}
				else if(Points[h][Type] == 3 && PlayerInfo[i][pPot] < 3)
				{
					GameTextForPlayer(i, "~w~Type /getseeds to purchase some ~r~pot seeds", 5000, 5);
				}
				else if(Points[h][Type] == 4)
				{
					GameTextForPlayer(i, "~w~Type /getcrack to purchase some ~r~crack", 5000, 5);
				}
				else if(Points[h][Type] == 5)
				{
					GameTextForPlayer(i, "~w~Type /getcrate to purchase a ~r~crate", 5000, 5);
				}
			}
		}
		if(SafeTime[i] > 0) {
			if(--SafeTime[i] == 1 && gPlayerAccount[i] == 1 && gPlayerLogged{i} == 0) {
				SendClientMessageEx(i, COLOR_WHITE, "HINT: You can now login by typing your password below.");
			}
		}
		if(PlayerInfo[i][pLocal] != 255 && PlayerInfo[i][pInt] != 0)
		{
			new house = PlayerInfo[i][pLocal];
			GetPlayerPos(i, oldposx, oldposy, oldposz);
			if(oldposz != 0.0)
			{
				if(oldposz < 600.0)
				{
					if(house == 242)
					{
						SetPlayerInterior(i,0);
						SetPlayerPos(i,1073.0619,-344.5148,73.9922);
						PlayerInfo[i][pInt] = 0;
						PlayerInfo[i][pLocal] = 255;
					}
				}
			}
		}
		if(CellTime[i] > 0)
		{
			if (CellTime[i] == cchargetime)
			{
				CellTime[i] = 1;
				if(Mobile[Mobile[i]] == i)
				{
					CallCost[i] += callcost;
				}
			}
			CellTime[i]++;
			if (Mobile[Mobile[i]] == INVALID_PLAYER_ID && CellTime[i] == 5)
			{
				if(IsPlayerConnected(Mobile[i]))
				{
				    new Float:rX, Float:rY, Float:rZ;
				    GetPlayerPos(i, rX, rY, rZ);
					new string[18 + MAX_PLAYER_NAME];
					format(string, sizeof(string), "* %s's phone rings.", GetPlayerNameEx(Mobile[i]));
					PlayerPlaySound(i, 1002, 0.0, 0.0, 0.0);
					RingTone[Mobile[i]] = 10;
					ProxDetector(30.0, Mobile[i], string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				}
			}
		}
		if(CellTime[i] == 0 && CallCost[i] > 0)
		{
			new string[28];
			format(string, sizeof(string), "~w~The call cost~n~~r~$%d",CallCost[i]);
			GivePlayerCash(i, -CallCost[i]);
			GameTextForPlayer(i, string, 5000, 1);
			CallCost[i] = 0;
		}
		if(TransportDriver[i] < 999)
		{
			if(GetPlayerVehicleID(i) != GetPlayerVehicleID(TransportDriver[i]) || !TransportDuty[TransportDriver[i]])
			{
				if(IsPlayerConnected(TransportDriver[i]))
				{
					TransportMoney[TransportDriver[i]] += TransportCost[i];
					TransportTime[TransportDriver[i]] = 0;
					TransportCost[TransportDriver[i]] = 0;
					new string[36];
					format(string, sizeof(string), "~w~Passenger left~n~~g~Earned $%d",TransportCost[i]);
					GameTextForPlayer(TransportDriver[i], string, 5000, 1);
					TransportDriver[i] = 999;
				}
			}
			else if(TransportTime[i] >= 16)
			{
				TransportTime[i] = 1;
				if(TransportDriver[i] < 999)
				{
					if(IsPlayerConnected(TransportDriver[i]))
					{
	  					TransportCost[i] += TransportValue[TransportDriver[i]];
						TransportCost[TransportDriver[i]] = TransportCost[i];
					}
				}
			}
			TransportTime[i] += 1;
			new string[24];
			format(string, sizeof(string), "~r~%d ~w~: ~g~$%d",TransportTime[i],TransportCost[i]);
			GameTextForPlayer(i, string, 15000, 6);
			if(TransportCost[i] > GetPlayerCash(i))
			{
			    RemovePlayerFromVehicle(i);
			    new Float:slx, Float:sly, Float:slz;
				GetPlayerPos(i, slx, sly, slz);
				SetPlayerPos(i, slx, sly, slz + 2);
			    GameTextForPlayer(i, "~r~You're flat out of cash!", 4000, 4);
			}
		}
		if(GetPVarInt(i, "rccam") == 0)
 		{
			if(GetVehicleModel(GetPlayerVehicleID(i)) != 594)
			{
	 			DestroyVehicle(GetPVarInt(i, "rcveh"));
	     		KillTimer(GetPVarInt(i, "rccamtimer"));
			}
		}
	}
}
Reply
#6

I believe it's from here:
pawn Код:
// code:
if (CellTime[i] == cchargetime)
{
    CellTime[i] = 1;
    if(Mobile[Mobile[i]] == i) // this line .. OR
    {
        CallCost[i] += callcost;
    }
}
CellTime[i]++;
if (Mobile[Mobile[i]] == INVALID_PLAYER_ID && CellTime[i] == 5) // this line
{
    if(IsPlayerConnected(Mobile[i]))
    {
        new Float:rX, Float:rY, Float:rZ;
        GetPlayerPos(i, rX, rY, rZ);
        new string[18 + MAX_PLAYER_NAME];
        format(string, sizeof(string), "* %s's phone rings.", GetPlayerNameEx(Mobile[i]));
        PlayerPlaySound(i, 1002, 0.0, 0.0, 0.0);
        RingTone[Mobile[i]] = 10;
        ProxDetector(30.0, Mobile[i], string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    }
}

TransportDriver[i] was suspicious too but you check if it's less than 999 so it wouldn't be 65535.

I'm sure the one it gives the index out of bounds is Mobile[i]. One of the lines above causes the problem. Do a debugging to be sure. Change to:
pawn Код:
// code:
if (CellTime[i] == cchargetime)
{
    CellTime[i] = 1;
    if(Mobile[Mobile[i]] == i) // this line .. OR
    {
        CallCost[i] += callcost;
    }
}
CellTime[i]++;
printf("DEBUG: Mobile[Mobile[i]] is %d", Mobile[Mobile[i]]);
printf("DEBUG: Mobile[i] is %d", Mobile[i]);
if (Mobile[Mobile[i]] == INVALID_PLAYER_ID && CellTime[i] == 5) // this line
{
    if(IsPlayerConnected(Mobile[i]))
    {
        new Float:rX, Float:rY, Float:rZ;
        GetPlayerPos(i, rX, rY, rZ);
        new string[18 + MAX_PLAYER_NAME];
        format(string, sizeof(string), "* %s's phone rings.", GetPlayerNameEx(Mobile[i]));
        PlayerPlaySound(i, 1002, 0.0, 0.0, 0.0);
        RingTone[Mobile[i]] = 10;
        ProxDetector(30.0, Mobile[i], string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    }
}
If it gets crashed again, show us what it prints. If I guessed correct, you'll need to check if it's not INVALID_PLAYER_ID and continue your code.
Reply
#7

Here you go, copied from server log:
i called to person in game so that happend...


Код:
[21:03:01] [zcmd] [Joker]: /number 1
[21:03:12] [zcmd] [Paulo Calimani]: /cmute
[21:03:14] [zcmd] [Joker]: /call 9039
[21:03:15] DEBUG: Mobile[Mobile[i]] is 65535
[21:03:15] DEBUG: Mobile[i] is 1
[21:03:16] DEBUG: Mobile[Mobile[i]] is 65535
[21:03:16] DEBUG: Mobile[i] is 1
[21:03:16] [zcmd] [Paulo Calimani]: /p
[21:03:17] DEBUG: Mobile[Mobile[i]] is 0
[21:03:17] DEBUG: Mobile[i] is 1
[21:03:17] [chat] [Paulo_Calimani]: Gay
[21:03:18] DEBUG: Mobile[Mobile[i]] is 0
[21:03:18] DEBUG: Mobile[i] is 1
[21:03:19] DEBUG: Mobile[Mobile[i]] is 0
[21:03:19] DEBUG: Mobile[i] is 1
[21:03:20] [chat] [Joker]: Ya naor
[21:03:20] DEBUG: Mobile[Mobile[i]] is 0
[21:03:20] DEBUG: Mobile[i] is 1
Reply
#8

Okay, Mobile[Mobile[i]] became 65535 but it is not used in an array index. Did the server get crashed? Because if Mobile[i] was 65535, I'd agree more.
Reply
#9

You mean if the server immediately crashed after the i called to the person? if you do it didn't crash, its just show up the lines on server log.
BTW, what is the next step to fix that?
Reply
#10

No, no. That's debugging. I only need to show me what it printed the time your server crashed. Otherwise, the messages are pointless.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)