Server Crashed
#1

Hy Guys,

I have a problem with a plugins (audioplugins) which reboot or stop my server.

This is the error:

Код:
[20:41:04] [debug] Run time error 4: "Array index out of bounds"
[20:41:04] [debug]  Accessing element at index 4 past array upper bound 3
[20:41:04] [debug] AMX backtrace:
[20:41:04] [debug] #0 000835e8 in ?? () from gamemode.amx
[20:41:04] [debug] #1 00040444 in public OPJV_OnPlayerStateChange () from gamemode.amx
[20:41:04] [debug] #2 00009770 in public OnPlayerStateChange () from gamemode.amx
offer a cold beer, the one who help me :P

Thanks in Advance,

Jericho
Reply
#2

Can you show us these publics from gamemode.pwn?

[20:41:04] [debug] #1 00040444 in public OPJV_OnPlayerStateChange () from gamemode.amx
[20:41:04] [debug] #2 00009770 in public OnPlayerStateChange () from gamemode.amx
Reply
#3

I'll get a cold beer, thanks!

Anyways, can you post OnPlayerStateChange callback?

PS: Compile the mode with the debug options >> http://forum.sa-mp.com/showpost.php?...32&postcount=7
Reply
#4

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{

	if(oldstate == PLAYER_STATE_DRIVER)
	{

		TextDrawHideForPlayer(playerid,speedo_txt[playerid]);

	}
	if(newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_PASSENGER)
	{

	    if(seatbelt[playerid]) { PutPlayerInVehicle(playerid,old_vehicle[playerid],old_veh_seat[playerid]); return 1; }

	}
	if(newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_PASSENGER)
	{

		if(Audio_IsClientConnected(playerid))
		{

		 	Audio_SetVolume(playerid,radio_handle[playerid],0);

		}

	}
	if(newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_DRIVER)
	{

	    if(derby_sys_driver[playerid]) { PutPlayerInVehicle(playerid,old_vehicle[playerid],0); SendClientMessage(playerid,COLOR_LIGHTRED,"You cannot exit the vehicle during a DERBY."); }
        if(nascar_sys_driver[playerid]) { PutPlayerInVehicle(playerid,old_vehicle[playerid],0); SendClientMessage(playerid,COLOR_LIGHTRED,"You cannot exit the vehicle during a NASCAR race."); }
	    if(Audio_IsClientConnected(playerid))
		{

			Audio_SetVolume(playerid,radio_handle[playerid],0);

		}

	}
	if(newstate == PLAYER_STATE_PASSENGER)
	{

	    if(Audio_IsClientConnected(playerid))
		{

			Audio_SetVolume(playerid,radio_handle[playerid],vehicle_radio_volume[GetPlayerVehicleID(playerid)]);

		}
	    if(InBus(playerid))
	    {

	        if(CharacterInfo[playerid][active_character[playerid]][cMoney] >= 10)
	        {

	        	CharacterInfo[playerid][active_character[playerid]][cMoney] -= 10;
		        SendEmote(playerid,"pays the driver $10 to board the bus");

			}
			else
			{

				RemovePlayerFromVehicle(playerid);
				SendClientMessage(playerid,COLOR_LIGHTRED,"You cannot afford to ride the bus.");

			}

	    }

	}
	if(newstate == PLAYER_STATE_DRIVER)
	{

	    if(IsPushbike(GetVehicleModel(GetPlayerVehicleID(playerid))) && !AccountInfo[playerid][aBikePerm])
	    {

	        SendClientMessage(playerid,COLOR_LIGHTRED,"You need permission from an administrator to use this type of vehicle.");
	        RemovePlayerFromVehicle(playerid);
			new Float:X, Float:Y, Float:Z;
			GetPlayerPos(playerid,X,Y,Z);
			SetPlayerPos(playerid,X,Y,(Z + 2.5));

	    } else if(IsPushbike(GetVehicleModel(GetPlayerVehicleID(playerid)))) { StartEngine(GetPlayerVehicleID(playerid)); }
	    player_vehicle_speed[playerid] = 0;
	    Audio_SetVolume(playerid,radio_handle[playerid],radio_volume[playerid]);
	    GetPlayerPos(playerid, SpeedPos[playerid][3], SpeedPos[playerid][4], SpeedPos[playerid][5]);
	    if(!IsPushbike(GetVehicleModel(GetPlayerVehicleID(playerid)))) { TextDrawShowForPlayer(playerid,speedo_txt[playerid]); }
	    if(InUtility(playerid))
	    {

	    	if(CharacterInfo[playerid][active_character[playerid]][cJob] != JOB_ENG)
	        {

	            RemovePlayerFromVehicle(playerid);
	            SendClientMessage(playerid,COLOR_LIGHTRED,"Only Engineers can drive this vehicle.");

	        }
	        else
	        {

	            SendClientMessage(playerid,COLOR_GREEN,"Use /startengineer to begin.");

	        }

	    }
	    if(InSweeper(playerid))
	    {

	        if(CharacterInfo[playerid][active_character[playerid]][cJob] != JOB_SWEEPER)
	        {

	            RemovePlayerFromVehicle(playerid);
	            SendClientMessage(playerid,COLOR_LIGHTRED,"Only Street Cleaners can drive this vehicle.");

	        }
	        else
	        {

	            SendClientMessage(playerid,COLOR_GREEN,"Use /startsweep to begin a sweeping run.");

	        }

	    }
	    if(InPizzaBoy(playerid))
	    {

	        if(CharacterInfo[playerid][active_character[playerid]][cJob] != JOB_PIZZA)
	        {

	            RemovePlayerFromVehicle(playerid);
	            SendClientMessage(playerid,COLOR_LIGHTRED,"Only Pizza Boys may drive this vehicle.");

	        }
	        else
	        {

	            SendClientMessage(playerid,COLOR_GREEN,"Use /startpizza to begin a pizza run. The faster you deliver the pizzas, the more money you will recieve.");

	        }

	    }
	    if(InTruck(playerid))
	    {

	        if(CharacterInfo[playerid][active_character[playerid]][cJob] != JOB_TRUCKER)
	        {

	            RemovePlayerFromVehicle(playerid);
	            SendClientMessage(playerid,COLOR_LIGHTRED,"Only truckers may drive this vehicle.");

	        }
	        else
	        {

	            SendClientMessage(playerid,COLOR_GREEN,"Use /starttrucking to begin a trucking run. (You will be awarded more money for taking a trailer)");

	        }

	    }
	    if(InDeliveryVan(playerid))
	    {

	        if(CharacterInfo[playerid][active_character[playerid]][cJob] != JOB_DELIVER)
	        {

	            RemovePlayerFromVehicle(playerid);
	            SendClientMessageA(playerid,COLOR_LIGHTRED,"Only delivery men may drive this vehicle");

	        }
			else
			{

			    SendClientMessageA(playerid,COLOR_GREEN,"Use /startdelivery to begin a delivery chain");

			}

	    }
	  	if(InRentCar(playerid))
		{
			if(renting_car[playerid] != GetPlayerVehicleID(playerid))
			{

				TextDrawSetString(infotxt[playerid],"~p~Rentable Vehicle~n~ ~n~~w~~p~Price: ~w~$300~n~ ~n~use ~p~/rentcar~w~ to rent this vehicle.");
				TextDrawShowForPlayer(playerid,infotxt[playerid]);
				infotxt_expire[playerid] = 10;

			}

		}
		if(InTaxi(playerid))
		{

		    if(CharacterInfo[playerid][active_character[playerid]][cJob] != JOB_TAXI)
		    {

				RemovePlayerFromVehicle(playerid);
				SendClientMessageA(playerid,COLOR_LIGHTRED,"Only taxi drivers may drive this vehicle");
				return 1;

		    }
		    else
		    {

				SendClientMessageA(playerid,COLOR_GREEN,"Use /fare when someone is in your vehicle to begin charging the player fare.");
				SendTaxiNotification(playerid);

		    }

		}
		if(InBus(playerid))
		{

			if(CharacterInfo[playerid][active_character[playerid]][cJob] != JOB_BUS)
		    {

				RemovePlayerFromVehicle(playerid);
				SendClientMessageA(playerid,COLOR_LIGHTRED,"Only bus drivers may drive this vehicle");
				return 1;

		    }
		    else
		    {

				SendClientMessageA(playerid,COLOR_GREEN,"Use /startroute to start a bus route.");

		    }
		}
		if(InGarbage(playerid))
		{

			if(CharacterInfo[playerid][active_character[playerid]][cJob] != JOB_GARBAGE)
			{

				RemovePlayerFromVehicle(playerid);
				SendClientMessageA(playerid,COLOR_LIGHTRED,"Only garbage men may drive this vehicle");
				return 1;

		    }
		    else
		    {

		        if(garbage_run[playerid] == -1)
		        {

					SendClientMessageA(playerid,COLOR_GREEN,"Use /startrun to start a garbage run.");

				}

		    }
		}
		if(InFish(playerid))
		{

			if(CharacterInfo[playerid][active_character[playerid]][cJob] != JOB_FISH)
			{

				RemovePlayerFromVehicle(playerid);
				SendClientMessageA(playerid,COLOR_LIGHTRED,"Only fisher men may drive this vehicle");
				return 1;

		    }
		    else
		    {

		        if(fish_run[playerid] == -1)
		        {

					SendClientMessageA(playerid,COLOR_GREEN,"Use /startfish to start a fishing run.");

				}

		    }
		}
	}
	return 1;
}
Reply
#5

pawn Код:
GetPlayerPos(playerid, SpeedPos[playerid][3], SpeedPos[playerid][4], SpeedPos[playerid][5]);
How did you declare SpeedPos?
Reply
#6

Quote:
Originally Posted by _Zeus
Посмотреть сообщение
pawn Код:
GetPlayerPos(playerid, SpeedPos[playerid][3], SpeedPos[playerid][4], SpeedPos[playerid][5]);
How did you declare SpeedPos?
Код:
new Float:SpeedPos[MAX_PLAYERS][6];
Reply
#7

Hm, so that's not the problem. It's really hard to find it like that. Did you compile with the debug options? We may get lines.

Anyways, the other that's suspicious is this one:
pawn Код:
CharacterInfo[playerid][active_character[playerid]][cMoney]
What's the max index the 2nd array has (after [MAX_PLAYERS])?
active_character[playerid]'s value at the index might be out of bounds.
Reply
#8

Код:
new active_character[MAX_PLAYERS];
Reply
#9

Not that, I meant how did you declare CharacterInfo because active_character[playerid] might pass at the index a higher element that its max.
Reply
#10

new CharacterInfo[MAX_PLAYERS][25][cInfo];
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)