Commands random bugs
#1

Hi guys, in my GM afther few hours of working, i get this error:
Код:
[16:27:06] [debug] Run time error 4: "Array index out of bounds"
[16:27:06] [debug]  Accessing element at negative index -1
[16:27:06] [debug] AMX backtrace:
[16:27:06] [debug] #0 004c7158 in public cmd_port (2, 50974840) from LSRP.amx
[16:27:06] [debug] #1 native CallLocalFunction () from samp03svr
[16:27:06] [debug] #2 00036bdc in ?? (2, 50974816) from LSRP.amx
[16:27:06] [debug] #3 0002b62c in public OnPlayerCommandText (2, 50974816) from LSRP.amx
here is my port command:
Код:
CMD:port(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] > 0 || PlayerInfo[playerid][pSupporter] > 0 || PlayerInfo[playerid][pDonator] > 0 || PlayerInfo[playerid][pPromoter] > 0)
	{
	if(sduty[playerid] == 0)
	{
	if(PlayerInfo[playerid][pSupporter] > 0)
	{
	SCM(playerid,GRAD2,"Morate biti na duznosti kao Supporter, da biste koristili ovu komandu. (/sduty)");
	return 1;
	}
	}
	if(PlayerInfo[playerid][pDonator] > 0 || PlayerInfo[playerid][pPromoter] > 0)
	{
	if(Vanredno == 1)
	{
	SCM(playerid,GRAD2,"U toku je vanredno stanje, ne mozete se portati.");
	return 1;
	}
	}
	if(PlayerInfo[playerid][pDonator] > 0 || PlayerInfo[playerid][pPromoter] > 0)
	{
	foreach(Player, i)
	{
	if(IsACop(i)) //if(IsPlayerInRangeOfPoint(playerid, 30.0, 2860.9873,-1956.1809,11.2027))
	{
	GetPlayerPos(i, X,Y,Z);
	if(IsPlayerInRangeOfPoint(playerid, 20.0, X,Y,Z) && PlayerInfo[i][pDuty] == 1)
	{
	if(playerid != i)
	{
	SCM(playerid,GRAD2,"Ne mozete se portati dok je u vasoj blizini policajac.");
	return 1;
	}
	}
	}
	}
	}
	if(pint[playerid] > 0 || GetPlayerInterior(playerid) > 0) return SCM(playerid,GRAD2,"Ne mozete se Teleportovati jer se nalazite u enterijeru.");
	if(Prisustvuje[playerid] == true) return SCM(playerid,GRAD2,"Ne mozete se Teleportovati jer ste na eventu.");
	if(hZavezan[playerid] == 1) return SCM(playerid, GRAD2, "Ne mozete se Teleportovati jer ste vezani.");
	if(PlayerInfo[playerid][pDonator] > 0)
	{
	if(portgotot[playerid] == 1) return SCM(playerid,GRAD2,"Morate sacekati 20 sekundi pre sledeceg teleportovanja.");
	}
	portgotot[playerid] = 1;
	SetTimerEx("PortPonovo", 20000, false, "i", playerid);
	if(PlayerInfo[playerid][pDuty] == 1) return SCM(playerid,GRAD2,"Ne mozete koristiti tu komandu dok ste na duznosti kao Policajac.");
	if(matslvl[playerid] > 0 || hSecenje[playerid] > 0 || kamenklese[playerid] > 0 || pizzalvl[playerid] > 0 || ribalvl[playerid] > 0 || gradnja[playerid] > 0 || kokicarlvl[playerid] > 0 || sladoledlvl[playerid] > 0 ||
	naftalvl[playerid] > 0 || arhlvl[playerid] > 0) return SCM(playerid,GRAD2,"Ne mozete koristiti tu komandu dok radite posao.");
	if(frizovan[playerid] == 1) return SCM(playerid,GRAD2,"Ne mozete to, zaledjeni ste.");
	if(PlayerInfo[playerid][pAlcatraz] > 0 || PlayerInfo[playerid][pZatvorTime] > 0 || PlayerInfo[playerid][pMaraton] > 0) return SCM(playerid, SIVA, "Ne mozete to, zatvoreni ste.");
	if(PlayerCuffed[playerid] > 0) return SCM(playerid,GRAD2,"Ne mozes to dok imas lisice!");
	if(WantedLevel[playerid] > 0) return SCM(playerid,GRAD2,"Ne mozete koristiti ovu komandu, imate wanted level.");
        if(PlayerInfo[playerid][pMaraton] > 0) return SCM(playerid,SIVA,"Ne mozete to kod sten a maratonu!");
        if(DmIgrac[playerid] == 1) return SCM(playerid, GRAD2, "Ne mozete to dok ste na eventu!");
        if(GetPlayerVehicleID(playerid) == NP[PlayerInfo[playerid][pKljucNaftno]][nVozilo]) return SCM(playerid,SIVA,"Ne mozete koristiti tu komandu dok vozite naftu!");
	    SPD(playerid,DIALOG_PORT,DIALOG_STYLE_LIST,"Port","Los Santos Lokacije\nSan Fiero Lokacije\nLas Venturas Lokacije\nOrganizacije","Port","Izadji");
	}
	else return SCM(playerid, GRAD2, "  Niste ovlasceni da koristite ovu komandu.");
	return 1;
}
I Dont know what is wrong here, and its not only on this command, its randomly on all commands....
Reply
#2

Check out your defined arrays, you'll find an array whose index is lesser than it should be.

For example, an array "new Job[10]" with an index 10, can not store more than 10 values, but somehow a function/loop or anything in your script manage to cross the 10, so look out for it.
Reply
#3

Ahh, i found what caused that,
Код:
NP[PlayerInfo[playerid][pKljucNaftno]][nVozilo]
the
Код:
PlayerInfo[playerid][pKljucNaftno]
was seted to -1;

TNX!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)