debug???
#1

i try to debug my script but what does this means:

Quote:

[21:01:12] [debug] #0 00009184 in public CheckPlayerState () from NR_G_AS.amx
[21:01:12] [debug] Run time error 4: "Array index out of bounds"
[21:01:12] [debug] Accessing element at index 500 past array upper bound 499

This is CheckPlayerState:

Код:
public CheckPlayerState()
{ //by Abhinav
	new i,cs;
	for(i=0;i<=MAX_PLAYERS;i++){
	    cs=GetPlayerState(i);
	    if(DriftMode[i] && cs==PLAYER_STATE_DRIVER && DriftPointsNow[i]>70){
	        new Float:h;
	        GetVehicleHealth(GetPlayerVehicleID(i),h);
	        if(h<HealthInit[i]){
	        	KillTimer(DriftTimer[i]);
	        	DriftExit(i);
	        	GameTextForPlayer(i,"~n~~n~~n~~n~~n~~n~~n~~r~Boom",800,5);
	        	DriftMode[i]=false;
			}
		}
	    if(cs==PLAYER_STATE_DRIVER && DriftMode[i]==false){
	        if(GetVType(GetPlayerVehicleID(i))){
		        DriftMode[i]=true;
		        GetVehicleHealth(GetPlayerVehicleID(i),HealthInit[i]);
		        AutoFixBool[i]=false;
		        DriftTimer[i]=SetTimerEx("Drift", 200, true, "i", i);
			}
		}
		else if(cs!=PLAYER_STATE_DRIVER && DriftMode[i]==true){
		    KillTimer(DriftTimer[i]);
		    DriftMode[i]=false;
		    AutoFixBool[i]=true;
		}
		else{}
	}
	return 1;
}
But what does the problem means and how do i fix it in the script
Reply
#2

pawn Код:
for(i=0;i<=MAX_PLAYERS;i++){
Common and stupid mistake.

pawn Код:
for(i = 0; i < MAX_PLAYERS; i++){
Reply
#3

oh, so it is just the spaces xD
Reply
#4

No. You had

i <= MAX_PLAYERS


It's supposed to be

i < MAX_PLAYERS



If you did it your way, it will try to access player 501 (or whatever your max players is + 1), which is above the array size.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)