SA-MP Forums Archive
[Ajuda] [debug] Run time error 4: "Array index out of bounds" - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] [debug] Run time error 4: "Array index out of bounds" (/showthread.php?tid=596732)



[debug] Run time error 4: "Array index out of bounds" - adilon - 21.12.2015

Log:

Код:
[19:27:48] [debug] Run time error 4: "Array index out of bounds"
[19:27:48] [debug]  Accessing element at index 1214716 past array upper bound 999
[19:27:48] [debug] AMX backtrace:
[19:27:48] [debug] #0 0012d4d8 in public ChecarAfk (playerid=1214716) at C:\Users\Windows 7\Desktop\E.L.H (Intro-Logo)\samp 0.3z\gamemodes\cok.pwn:12806
Funзгo:

Код:
public ChecarAfk(playerid)
{
	if(AFK[playerid]==1 && AfkCount[playerid] > 10) {
		SendClientMessage(playerid, vermelho, "[COK] Vocк foi kickado por estar AFK por muito tempo!");
		KickarPlayer(playerid);
		format(string, sizeof string, "[COK] %s foi kickado por estar AFK por 10 minutos.", pnome(playerid));
		SendClientMessageToAll(vermelho, string);
	}
	return 1;
}



Re: [debug] Run time error 4: "Array index out of bounds" - EditPawn - 21.12.2015

Coloque isso na verificaзгo:

IsPlayerConnected


Re: [debug] Run time error 4: "Array index out of bounds" - adilon - 21.12.2015

Continua a mesma coisa


Re: [debug] Run time error 4: "Array index out of bounds" - EditPawn - 21.12.2015

O erro estб onde vocк estб chamando essa callback.


O que estб acontecendo й, quando a callback estб sendo chamada o valor de playerid estб sendo 1214716, ou seja, estб chamando a callback dessa forma:

PHP код:
ChecarAfk(1214716); 



Re: [debug] Run time error 4: "Array index out of bounds" - adilon - 21.12.2015

Quote:
Originally Posted by EditPawn
Посмотреть сообщение
O erro estб onde vocк estб chamando essa callback.


O que estб acontecendo й, quando a callback estб sendo chamada o valor de playerid estб sendo 1214716, ou seja, estб chamando a callback dessa forma:

PHP код:
ChecarAfk(1214716); 
Sou novato.
Eu entendi mais...
Como arrumo isso


Re: [debug] Run time error 4: "Array index out of bounds" - EditPawn - 21.12.2015

Quote:
Originally Posted by adilon
Посмотреть сообщение
Sou novato.
Eu entendi mais...
Como arrumo isso
Verifique em seu gamemode onde estб sendo chamada essa callback, de um Ctrl + F e procure onde estб o cуdigo e poste.


Re: [debug] Run time error 4: "Array index out of bounds" - adilon - 21.12.2015

Quote:
Originally Posted by EditPawn
Посмотреть сообщение
Verifique em seu gamemode onde estб sendo chamada essa callback, de um Ctrl + F e procure onde estб o cуdigo e poste.
Nгo entendi bem mais acho que й isso...


Код:
public OnGameModeInit()
{
    SetTimerEx("ChecarAfk", 1000, true, "s", "afk");



Re: [debug] Run time error 4: "Array index out of bounds" - EditPawn - 21.12.2015

Quote:
Originally Posted by adilon
Посмотреть сообщение
Si eu entendi й isso...


Код:
public OnGameModeInit()
{
    SetTimerEx("ChecarAfk", 1000, true, "s", "afk");

Por isso estб ocorrendo o erro.

Remova o Timer dessa callback e faзa da seguinte forma.

PHP код:
public OnPlayerConnect(playerid) {
    
ChecarAfk(playerid);
    return 
1;
}
public 
ChecarAfk(playerid) {
    if(
AFK[playerid] == && AfkCount[playerid] > 10) {
        
SendClientMessage(playeridvermelho"[COK] Vocк foi kickado por estar AFK por muito tempo!");
        
KickarPlayer(playerid);
        
format(stringsizeof string"[COK] %s foi kickado por estar AFK por 10 minutos."pnome(playerid));
        
SendClientMessageToAll(vermelhostring);
    }
    else 
SetTimerEx("ChecarAfk"1000false"i"playerid);
    return 
1;