SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 27/07/2017, 01:23 AM   #1
Xleone
Little Clucker
 
Join Date: Apr 2017
Posts: 9
Reputation: 0
Default [debug] Run time error 4: "Array index out of bounds"

Code:
[21:05:03] [debug] Run time error 4: "Array index out of bounds"
[21:05:03] [debug]  Attempted to read/write array element at index 65535 in array of size 100
[21:05:03] [debug] AMX backtrace:
[21:05:03] [debug] #0 002d82d0 in public OnPlayerTakeDamage (0, 65535, 1084122727, 54, 3) from Cleveland.amx
[21:07:11] [debug] Server crashed while executing Cleveland.amx
[21:07:11] [debug] AMX backtrace:
[21:07:11] [debug] #0 native KillTimer () from fixes2.so
[21:07:11] [debug] #1 00263760 in public FC_OnPlayerDisconnect (0, 2) from Cleveland.amx
[21:07:11] [debug] #2 native CallLocalFunction () from samp03svr
[21:07:11] [debug] #3 00014e34 in public Itter_OnPlayerDisconnect (0, 2) from Cleveland.amx
[21:07:11] [debug] #4 0000d8d4 in public FIXES_OnPlayerDisconnect (0, 2) from Cleveland.amx
[21:07:11] [debug] #5 000088f8 in public SSCANF_OnPlayerDisconnect (0, 2) from Cleveland.amx
[21:07:11] [debug] #6 00000b04 in public OnPlayerDisconnect (0, 2) from Cleveland.amx
[21:07:11] [debug] #7 native Kick () from samp03svr
[21:07:11] [debug] #8 0000c014 in ?? (0) from Cleveland.amx
[21:07:11] [debug] #9 00360f2c in public KickFix () from Cleveland.amx
[21:07:11] [debug] Native backtrace:
[21:07:11] [debug] #0 f6671180 in _Z13GetStackTraceRSt6vectorI10StackFrameSaIS0_EEPv () from plugins/crashdetect.so
[21:07:11] [debug] #1 f6669064 in _ZN11CrashDetect20PrintNativeBacktraceERSoRKN2os7ContextE () from plugins/crashdetect.so
[21:07:11] [debug] #2 f6669d64 in _ZN11CrashDetect20PrintNativeBacktraceERKN2os7ContextE () from plugins/crashdetect.so
[21:07:11] [debug] #3 f666bcdb in _ZN11CrashDetect7OnCrashERKN2os7ContextE () from plugins/crashdetect.so
[21:07:11] [debug] #4 f66704d5 in ?? () from plugins/crashdetect.so
[21:07:11] [debug] #5 f7795420 in ?? ()
[21:07:11] [debug] #6 f74695af in ?? () from plugins/fixes2.so
[21:07:11] [debug] #7 080950e4 in ?? () from ./samp03svr
[21:07:11] [debug] #8 f666aad3 in _ZN11CrashDetect17HandleAMXCallbackEiPiS0_ () from plugins/crashdetect.so
[21:07:11] [debug] #9 0917d888 in ?? () from ▒^Yv▒H^Wv▒         ▒▒▒     ▒▒▒     ▒▒▒     X▒     ▒▒     ^ԡv▒^X
[21:07:11] [debug] Registers:
[21:07:11] [debug] EAX: 00000000 EBX: f746ea48 ECX: f7469590 EDX: f5854a88
[21:07:11] [debug] ESI: 00001080 EDI: 0917d888 EBP: ffa6c9d8 ESP: ffa6c9c0
[21:07:11] [debug] EIP: f74695af EFLAGS: 00010246
[21:07:11] [debug] Stack:
[21:07:11] [debug] ESP+00000000: 00000100 0041723c 00000044 f66621e4
[21:07:11] [debug] ESP+00000020: 0917d888 f5854a88 ffffffff f666214a
[21:07:11] [debug] ESP+00000040: 0917d888 08f0d598 ffa6ce1c f666aad3
Code:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid){
    new Float:danio, string[128];
    new fuerza = JugadorInfo[issuerid][jFuerza];
	if(issuerid != INVALID_PLAYER_ID){
        if(amount == 2.64){
            switch(fuerza){
	            case 0..10: danio = 5.0;
	            case 11..20: danio = 5.5;
	            case 21..30: danio = 6.0;
	            case 31..40: danio = 6.5;
	            case 41..50: danio = 7.0;
	            case 51..60: danio = 7.5;
	            case 61..70: danio = 8.0;
	            case 71..80: danio = 8.5;
	            case 81..90: danio = 9.0;
	            case 91..10000: danio = 9.5;
           	}
        }
        else{
	        switch(weaponid){
		        case 0:{
		            if(EsPolicia(issuerid) && PuedeEmbestir[issuerid] == 1){
			       		if(Embestido[playerid] == 0 && Paralizado[playerid] == 0){
			          		new embestida = random(4)+1;
			               	if(embestida == 1){
			                	format(string, sizeof(string), "* %s intentó tirar bruscamente a %s en forma de embestida pero no consiguió embestirlo.", NombreIC(issuerid), NombreIC(playerid));
			                 	ProxDetector(30.0, playerid, string, COLOR_ACCIONES, COLOR_ACCIONES, COLOR_ACCIONES, COLOR_ACCIONES, COLOR_ACCIONES);
			                }
			                else{
			                	format(string, sizeof(string), "* %s intentó tirar bruscamente a %s en forma de embestida y consiguió hacerlo.", NombreIC(issuerid), NombreIC(playerid));
			                 	ProxDetector(30.0, playerid, string, COLOR_ACCIONES, COLOR_ACCIONES, COLOR_ACCIONES, COLOR_ACCIONES, COLOR_ACCIONES);
			                  	GameTextForPlayer(playerid, "Embestido", 3000, 3);
			                   	TogglePlayerControllable(playerid, 0);
			                    ApplyAnimation(playerid,"PED","BIKE_fallR",4.0,0,1,1,1,0);
			                    ApplyAnimation(playerid,"PED","BIKE_fallR",4.0,0,1,1,1,0);
			                    Embestido[playerid] = 1;
			                    SetTimerEx("LevantarseEmbestido", 3000, false, "i", playerid);
			        		}
			            }
		            }
					switch(fuerza){
		                case 0..10: danio = 2.0;
		                case 11..20: danio = 2.5;
		                case 21..30: danio = 3.0;
		                case 31..40: danio = 3.5;
		                case 41..50: danio = 4.0;
		                case 51..60: danio = 4.5;
		                case 61..70: danio = 5.0;
		                case 71..80: danio = 5.5;
		                case 81..90: danio = 6.0;
		                case 91..10000: danio = 6.5;
					}
			 	}
			 	case 1:{
					switch(fuerza){
		                case 0..10: danio = 2.5;
		                case 11..20: danio = 3.0;
		                case 21..30: danio = 3.5;
		                case 31..40: danio = 4.0;
		                case 41..50: danio = 4.5;
		                case 51..60: danio = 5.0;
		                case 61..70: danio = 5.5;
		                case 71..80: danio = 6.0;
		                case 81..90: danio = 6.5;
		                case 91..10000: danio = 7.0;
              		}
			 	}
			 	case 2,3,5,6,7,15:{
					switch(fuerza){
		                case 0..10: danio = 5.0;
		                case 11..20: danio = 5.5;
		                case 21..30: danio = 6.0;
		                case 31..40: danio = 6.5;
		                case 41..50: danio = 7.0;
		                case 51..60: danio = 7.5;
		                case 61..70: danio = 8.0;
		                case 71..80: danio = 8.5;
		                case 81..90: danio = 9.0;
		                case 91..10000: danio = 9.5;
              		}
			 	}
			 	case 4:{
					switch(fuerza){
		                case 0..10: danio = 6.0;
		                case 11..20: danio = 6.5;
		                case 21..30: danio = 7.0;
		                case 31..40: danio = 7.5;
		                case 41..50: danio = 8.0;
		                case 51..60: danio = 8.5;
		                case 61..70: danio = 9.0;
		                case 71..80: danio = 9.5;
		                case 81..90: danio = 10.0;
		                case 91..10000: danio = 10.5;
              		}
			 	}
			 	case 8:{
		            switch(fuerza){
		               	case 0..10: danio = 8.0;
		                case 11..20: danio = 8.5;
		                case 21..30: danio = 9.0;
		                case 31..40: danio = 9.5;
		                case 41..50: danio = 10.0;
		                case 51..60: danio = 10.5;
		                case 61..70: danio = 11.0;
		                case 71..80: danio = 11.5;
		                case 81..90: danio = 12.0;
		                case 91..10000: danio = 12.5;
					}
				}
			 	case 22: danio = 40.0;
			 	case 23:{
			 	    if(EsPolicia(issuerid) && Taser[issuerid] == 1){
          				if(Paralizado[playerid] == 0){
				 		    danio = 0.0;
 							format(string, sizeof(string), "* %s le efectuó un disparo con un táser disparador de cables a %s, paralizándolo.", NombreIC(issuerid), NombreIC(playerid));
      						ProxDetector(30.0, playerid, string, COLOR_ACCIONES, COLOR_ACCIONES, COLOR_ACCIONES, COLOR_ACCIONES, COLOR_ACCIONES);
            				Mensaje(issuerid, COLOR_BLANCO, "Ha logrado paralizarlo con su táser, para quitarle el parálisis, utilice el comando '/q(uitar)cables' [ID Jugador].");
                			Mensaje(playerid, COLOR_BLANCO, "Usted ha sido paralizado, para que se le quite el parálisis, debe esperar a que le quiten los cables.");
							GameTextForPlayer(playerid, "Paralizado", 3000, 3);
     						TogglePlayerControllable(playerid, 0);
           					ApplyAnimation(playerid,"PED","KO_shot_face",4.0,0,1,1,1,0);
           					ApplyAnimation(playerid,"PED","KO_shot_face",4.0,0,1,1,1,0);
                   			Paralizado[playerid] = 1;
                   		}
			 	    }
					else{
					    danio = 40.0;
                    }
			 	}
	    		case 24: danio = 70.0;
	        	case 25:{
			 	    if(EsPolicia(issuerid) && BalasDeGoma[issuerid] == 1){
          				if(Paralizado[playerid] == 0){
				 		    danio = 0.0;
 							format(string, sizeof(string), "* %s le efectuó un disparo con una escopeta de balas de goma %s, paralizándolo.", NombreIC(issuerid), NombreIC(playerid));
      						ProxDetector(30.0, playerid, string, COLOR_ACCIONES, COLOR_ACCIONES, COLOR_ACCIONES, COLOR_ACCIONES, COLOR_ACCIONES);
            				Mensaje(issuerid, COLOR_BLANCO, "Ha logrado paralizarlo con su escopeta de balas de goma, se le quitará su parálisis en 15 segundos.");
                			Mensaje(playerid, COLOR_BLANCO, "Usted ha sido paralizado, se le quitará el parálisis en 15 segundos.");
							GameTextForPlayer(playerid, "Paralizado", 3000, 3);
     						TogglePlayerControllable(playerid, 0);
       						ApplyAnimation(playerid, "SWEET", "LaFin_Sweet", 4.0, 0, 1, 1, 1, 0);
       						ApplyAnimation(playerid, "SWEET", "LaFin_Sweet", 4.0, 0, 1, 1, 1, 0);
                 			Paralizado[playerid] = 1;
                 			SetTimerEx("LevantarseParalizado", 15000, false, "i", playerid);
                    	}
			 	    }
					else{
					    danio = 80.0;
                    }
			 	}
	         	case 26: danio = 83.0;
	          	case 27: danio = 85.0;
	          	case 28,32: danio = 20.0;
	          	case 29: danio = 40.0;
	         	case 30: danio = 45.0;
	         	case 31: danio = 44.0;
	         	case 33: danio = 25.0;
	         	case 34: danio = 90.0;
		        default: danio = amount;
	        }
        }
        if(weaponid >= 22 && weaponid <= 34){
            new aviso = random(4)+1;
            if(aviso == 1){
				//
			}
			else{
			    if(GetPlayerInterior(playerid) == 0){
			    	new zona[128];
					GetPlayer2DZone(playerid, zona, 128);
		        	format(string, sizeof(string), "** [CENTRAL] Un sujeto denuncia que se oyen disparos en la zona de %s. **", zona);
	            	MensajeRadioIC(1, COLOR_RADIO, string);
                }
			}
    	}
		TextDrawShowForPlayer(playerid, TextDrawFlashDanio);
        SetPlayerDrunkLevel(playerid, 60000);
        TFlash[playerid] = SetTimerEx("Flash", 250, 1, "i", playerid);
		TMareo[playerid] = SetTimerEx("Mareo", 5000, 1, "i", playerid);
        GetPlayerHealth(playerid, JugadorInfo[playerid][jVida]);
        GetPlayerArmour(playerid, JugadorInfo[playerid][jChaleco]);
        if(JugadorInfo[playerid][jChaleco]){
            if(JugadorInfo[playerid][jChaleco] > danio) EstablecerChaleco(playerid, JugadorInfo[playerid][jChaleco]-danio);
            else{
                EstablecerChaleco(playerid, 0.0);
                JugadorInfo[playerid][jChaleco] = danio-JugadorInfo[playerid][jChaleco];
                if(JugadorInfo[playerid][jChaleco] >= JugadorInfo[playerid][jVida]) EstablecerVida(playerid, 0.0);
                else EstablecerVida(playerid, JugadorInfo[playerid][jVida]-JugadorInfo[playerid][jChaleco]);
            }
        }
        else{
            if(JugadorInfo[playerid][jVida] > danio) EstablecerVida(playerid, JugadorInfo[playerid][jVida]-danio);
            else EstablecerVida(playerid, 0.0);
        }
    }
    return 1;
}
Xleone is offline   Reply With Quote
Old 27/07/2017, 01:36 AM   #2
Kane
Gangsta
 
Kane's Avatar
 
Join Date: Sep 2012
Posts: 822
Reputation: 130
Default Re: [debug] Run time error 4: "Array index out of bounds"

Your codes an actual cluster fuck. You need to find the line it's originating from.

65535 is INVALID_PLAYER_ID.

Compile your script with -d3. Make a pawn.cfg and put it in pawno/.

https://github.com/Zeex/samp-plugin-...ith-debug-info

Restart the server and check server_log. The line it's originating from should display.
Kane is offline   Reply With Quote
Old 27/07/2017, 01:50 AM   #3
Xleone
Little Clucker
 
Join Date: Apr 2017
Posts: 9
Reputation: 0
Default Re: [debug] Run time error 4: "Array index out of bounds"

Code:
[21:35:54] [debug] Server crashed while executing Cleveland.amx
[21:35:54] [debug] AMX backtrace:
[21:35:54] [debug] #0 native KillTimer () from fixes2.so
[21:35:54] [debug] #1 0030786c in public FC_OnPlayerDisconnect (playerid=0, reason=0) at C:\Users\Luis\Desktop\AoTTG\Cleveland RP\gamemodes\Cleveland.pwn:2523
[21:35:54] [debug] #2 native CallLocalFunction () from samp03svr
[21:35:54] [debug] #3 00019158 in public Itter_OnPlayerDisconnect (playerid=0, reason=0) at C:\Users\Luis\Desktop\AoTTG\Cleveland RP\pawno\include\fuckCleo.inc:219
[21:35:54] [debug] #4 0001030c in public FIXES_OnPlayerDisconnect (playerid=0, reason=0) at C:\Users\Luis\Desktop\AoTTG\Cleveland RP\pawno\include\YSI\y_iterate.inc:906
[21:35:54] [debug] #5 0000a23c in public SSCANF_OnPlayerDisconnect (playerid=0, reason=0) at C:\Users\Luis\Desktop\AoTTG\Cleveland RP\pawno\include\fixes.inc:2211
[21:35:54] [debug] #6 00000cc0 in public OnPlayerDisconnect (playerid=0, reason=0) at C:\Users\Luis\Desktop\AoTTG\Cleveland RP\pawno\include\sscanf2.inc:260
[21:35:54] [debug] Native backtrace:
[21:35:54] [debug] #0 f62cb180 in _Z13GetStackTraceRSt6vectorI10StackFrameSaIS0_EEPv () from plugins/crashdetect.so
[21:35:54] [debug] #1 f62c3064 in _ZN11CrashDetect20PrintNativeBacktraceERSoRKN2os7ContextE () from plugins/crashdetect.so
[21:35:54] [debug] #2 f62c3d64 in _ZN11CrashDetect20PrintNativeBacktraceERKN2os7ContextE () from plugins/crashdetect.so
[21:35:54] [debug] #3 f62c5cdb in _ZN11CrashDetect7OnCrashERKN2os7ContextE () from plugins/crashdetect.so
[21:35:54] [debug] #4 f62ca4d5 in ?? () from plugins/crashdetect.so
[21:35:54] [debug] #5 f76f9420 in ?? ()
[21:35:54] [debug] #6 f73cc5af in ?? () from plugins/fixes2.so
[21:35:54] [debug] #7 080950e4 in ?? () from ./samp03svr
[21:35:54] [debug] #8 f62c4ad3 in _ZN11CrashDetect17HandleAMXCallbackEiPiS0_ () from plugins/crashdetect.so
2523:
Code:
KillTimer(TimerBarraAgua[playerid]);
Xleone is offline   Reply With Quote
Old 27/07/2017, 01:53 AM   #4
Kane
Gangsta
 
Kane's Avatar
 
Join Date: Sep 2012
Posts: 822
Reputation: 130
Default Re: [debug] Run time error 4: "Array index out of bounds"

Add a check to make sure playerid isn't an INVALID_PLAYER_ID. See if that fixes it.
Kane is offline   Reply With Quote
Old 27/07/2017, 01:54 AM   #5
Xleone
Little Clucker
 
Join Date: Apr 2017
Posts: 9
Reputation: 0
Default Re: [debug] Run time error 4: "Array index out of bounds"

How do i make that?

Forgive me, I'm something new in this.
Xleone is offline   Reply With Quote
Old 27/07/2017, 01:57 AM   #6
Kane
Gangsta
 
Kane's Avatar
 
Join Date: Sep 2012
Posts: 822
Reputation: 130
Default Re: [debug] Run time error 4: "Array index out of bounds"

Code:
if(playerid != INVALID_PLAYER_ID)
{
     KillTimer(TimerBarraAgua[playerid]);
}
Kane is offline   Reply With Quote
Old 27/07/2017, 01:59 AM   #7
Xleone
Little Clucker
 
Join Date: Apr 2017
Posts: 9
Reputation: 0
Default Re: [debug] Run time error 4: "Array index out of bounds"

Need to put that in OnPlayerTakeDamage?
Xleone is offline   Reply With Quote
Old 27/07/2017, 02:01 AM   #8
Kane
Gangsta
 
Kane's Avatar
 
Join Date: Sep 2012
Posts: 822
Reputation: 130
Default Re: [debug] Run time error 4: "Array index out of bounds"

Put it at the line where the error came from.
Kane is offline   Reply With Quote
Old 27/07/2017, 12:02 PM   #9
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,828
Reputation: 1401
Default Re: [debug] Run time error 4: "Array index out of bounds"

Those two are not related. The run time error is here:
pawn Code:
new fuerza = JugadorInfo[issuerid][jFuerza];
if(issuerid != INVALID_PLAYER_ID){
You need to make sure that issuer is a valid player BEFORE accessing JugadorInfo array.

The crash is caused from fixes2 plugin. All I can do is suggest another timerfix plugin: https://github.com/udan11/samp-plugin-timerfix/releases
__________________
Life is like riding a bicycle. To keep your balance, you must keep moving.

[Tutorial] How to use SQLite
[FilterScript] Tune System
Konstantinos is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[debug] Run time error 4: "Array index out of bounds" SH0x Scripting Help 4 20/02/2017 10:26 AM
debug] Run time error 4: "Array index out of bounds" skiplovebra Scripting Help 1 01/05/2016 04:03 PM
debug] Run time error 4: "Array index out of bounds" skiplovebra Scripting Help 5 13/04/2016 05:49 PM
[debug] Run time error 4: "Array index out of bounds" lulo356 Scripting Help 15 16/01/2016 03:52 PM
[debug] Run time error 4: "Array index out of bounds" and many more errors :P ntmp Scripting Help 2 11/08/2014 02:10 PM


All times are GMT. The time now is 11:14 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.