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

Код:
[03:13:21] [debug] Run time error 4: "Array index out of bounds"
[03:13:21] [debug]  Accessing element at negative index -1
[03:13:21] [debug] AMX backtrace:
[03:13:21] [debug] #0 001168f4 in public OnPlayerStateChange (0x00000003, 0x00000003, 0x00000001) from egsrp.amx
Код:
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
	{
	    new CarIDs = GetPlayerVehicleID(playerid), BuyCarID = GetBuyCarId(playerid);
		new CarModel = GetVehicleModel(CarIDs);
		if(CarInfo[BuyCarID][cRadio] == 1 || CarInfo[BuyCarID][cRadio] == 2)
		{
		    switch(CarRadioWorks[CarIDs])
		    {
		        case 0: StopAudioStreamForPlayer(playerid);
		        case 1: PlayAudioStreamForPlayer(playerid, "http://radiopage2.com");
		        case 2: PlayAudioStreamForPlayer(playerid, "http://radiopage3.com");
		        case 3: PlayAudioStreamForPlayer(playerid, "http://radiopage4.com");
		    }
		}
		switch(CarModel)
		{
			case 592,577,511,512,520,593,553,476,519,460,513,548,425,417,487,488,497,563,447,469: PlayerInfo[playerid][pWeapons][46] = true;
			case 457: PlayerInfo[playerid][pWeapons][2] = true;
			case 596,597,598,599: PlayerInfo[playerid][pWeapons][25] = true;
		}
	}
Reply
#2

Quote:
Originally Posted by Porgand
Посмотреть сообщение
Код:
[03:13:21] [debug] Run time error 4: "Array index out of bounds"
[03:13:21] [debug]  Accessing element at negative index -1
[03:13:21] [debug] AMX backtrace:
[03:13:21] [debug] #0 001168f4 in public OnPlayerStateChange (0x00000003, 0x00000003, 0x00000001) from egsrp.amx
Код:
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
	{
	    new CarIDs = GetPlayerVehicleID(playerid), BuyCarID = GetBuyCarId(playerid);
		new CarModel = GetVehicleModel(CarIDs);
		if(CarInfo[BuyCarID][cRadio] == 1 || CarInfo[BuyCarID][cRadio] == 2)
		{
		    switch(CarRadioWorks[CarIDs])
		    {
		        case 0: StopAudioStreamForPlayer(playerid);
		        case 1: PlayAudioStreamForPlayer(playerid, "http://radiopage2.com");
		        case 2: PlayAudioStreamForPlayer(playerid, "http://radiopage3.com");
		        case 3: PlayAudioStreamForPlayer(playerid, "http://radiopage4.com");
		    }
		}
		switch(CarModel)
		{
			case 592,577,511,512,520,593,553,476,519,460,513,548,425,417,487,488,497,563,447,469: PlayerInfo[playerid][pWeapons][46] = true;
			case 457: PlayerInfo[playerid][pWeapons][2] = true;
			case 596,597,598,599: PlayerInfo[playerid][pWeapons][25] = true;
		}
	}
hmmm try to check oldstate before the new state might help
Reply
#3

When i leave the vehicle then the server log don't show nothing. But when i enter the car and close the door then will come that errors. Passenger as well as driver.
Reply
#4

Why don't you use "print" to know the exact point that the console shows that message?
Reply
#5

What u mean? Make some example.
Reply
#6

This:
pawn Код:
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
|| means that there is an or statement in the script, so the seconds newstate must be removed.

pawn Код:
if((newstate == PLAYER_STATE_DRIVER || PLAYER_STATE_PASSENGER) && !(oldstate == PLAYER_STATE_DRIVER || PLAYER_STATE_PASSENGER))
Reply
#7

Yeah, now it's ok. Ty all.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)