[Pomoc] Debug


Započeo Scripter Braun, Januar 10, 2016, 16:24:51 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 1 gost pregledaju ovu temu.

Skripta koju koristim: Ne bitno
Detaljan opis problema: Ne znam zasto debug izbacuje ovo kada umrem.
Dio skripte:
[16:06:03] [debug] Run time error 4: "Array index out of bounds"
[16:06:03] [debug]  Accessing element at index 65535 past array upper bound 14
[16:06:03] [debug] AMX backtrace:
[16:06:03] [debug] #0 0020b3a0 in ?? (... <3 arguments>) at C:\Users\Zvezda\Downloads\optimizacija\All Stars RolePlay v1.0.0\gamemodes\ASRP.pwn:23044
[16:06:03] [debug] #1 00009818 in public OnPlayerDeath (playerid=0, killerid=65535, reason=255) at C:\Users\Zvezda\Downloads\optimizacija\All Stars RolePlay v1.0.0\pawno\include\YSI\y_hooks/impl.inc:753

Neke slike/video za lakse dobivanje pomoci(neobavezno): //
    ~ Member since: 09.13.2013. - 15:30 ~

daj onplayerdeath
valjda nije dugačak puno :D
ja msm da moras provjerit da li je killderid = INVALID_PLAYER_ID

nesto ovako
  if(killerid != INVALID_PLAYER_ID)
    {
        //Tvoj kod(npr.)
SCM(killerid, COLOR_RED, "Ubili ste igraca!");
    }


EDIT:
Izgleda da sam u pravu, evo sta kaze samp wiki

You MUST check whether 'killerid' is valid (not INVALID_PLAYER_ID) before using it in an array (or really anywhere), as it will cause the OnPlayerDeath script to crash (not the entire script). This is because INVALID_PLAYER_ID is defined as 65535, and if an array only has 'MAX_PLAYERS' elements, e.g. 500, you're trying to access an index that is above 499, which is out of bounds.
Poslednja Izmena: Januar 10, 2016, 16:47:47 POSLE PODNE od MEDO

"They have computers, and they may have other weapons of mass destruction."

Evo onplayerdeath
public OnPlayerDeath(playerid, killerid, reason)
{
    ResetPlayerWeaponsEx(playerid);
    for(new i = 0; i < sizeof OruzjeOtkriveno; i++) OruzjeOtkriveno[i][playerid] = -1;
   	AntiFakekill[playerid]++;
	SetTimerEx("AntiFakeKillTimer_H", 600,false,"i",playerid);
    DisablePlayerCheckpoint(playerid);
	PosaoGPS[playerid] = 0;
    KosiDrogu[playerid] = 0;
    SvercaMats[playerid] = 0;
    SvercaMunicije[playerid] = 0;
	HealthSynced[playerid] = 0;
	IgracSpawnan[playerid] = 0;
    PrikaziSmrtTD(playerid);
    KillTimer_H(ZauzimanjeAC[playerid]);
	AttachObjectRemove(playerid);
   	new th,tm,ts, ty, tm1, td;
   	gettime(th, tm, ts);
   	getdate(ty, tm1, td);
   	if(killerid == IPI)
   	{
		printf("[%d/%d/%d].[%d:%d:%d] | %s je umro!",td,tm1,ty,th,tm,ts,Ime_Igraca(playerid));
	}
	else
	{
		printf("[%d/%d/%d].[%d:%d:%d] | %s je umro, ubio ga je %s!",td,tm1,ty,th,tm,ts,Ime_Igraca(playerid),Ime_Igraca(killerid));
	}
	if(RonilacOprema[playerid] == 1)
	{
		DestroyPlayerProgressBar(playerid, oxygen[playerid]);
		TextDrawHideForPlayer(playerid, OxygenTD0);
		TextDrawHideForPlayer(playerid, OxygenTD1);
		oxygen[playerid] = INVALID_PLAYER_BAR_ID;
	 	hRonilac[playerid] = 0;
 	}
		if(AdminUbio[playerid] == 0 && IgracNaEventu[playerid] == 0 && Uwaru[playerid] == 0)
	    {
	    new kllstring[128];
		if(killerid != INVALID_PLAYER_ID)
	    {
	    format(kllstring, sizeof(kllstring),"[!] LA-AC: [%d]%s je ubio gradjanina [%d]%s!",killerid,Ime_Igraca(killerid),playerid,Ime_Igraca(playerid));
	    StaffPoruka(0xC96666FF, kllstring);
	    }
	    else
	    {
	    new text[30];
	    if(reason == 51) { text = "Explosion"; }
	    else if(reason == 53) { text = "Drowned"; }
	    else if(reason == 54) { text = "Collision"; }
	    else { text = "Death"; }
	    format(kllstring, sizeof(kllstring),"[!] AS-AC: %s[ID:%d] je ubijen. [%s]", Ime_Igraca(playerid), playerid, text);
	    StaffPoruka(0xC96666FF, kllstring);
    	}
	    if(killerid != INVALID_PLAYER_ID)
	    {
	    	PI[killerid][Ubistava]++; PI[playerid][Smrti]++;
			ResetujVar(playerid);
			if(IgracPolicajac(killerid))
			{
				PI[killerid][TrazeniNivo] = 0;
				SetPlayerWantedLevel_Ex(killerid,PI[playerid][TrazeniNivo]);
		 	}
	    }
	    if(killerid != INVALID_PLAYER_ID)
	    {
			if(!IgracPolicajac(killerid) && IsPlayerConnected(playerid))
			{
				if(PI[killerid][Zatvor] == 0)
				{
					PostaviWanted(killerid, "Ubistvo", "Nepoznat");
				}
			}
		}
		if(killerid != INVALID_PLAYER_ID)
	    {
			if(GetPlayerWantedLevel_Ex(killerid) > 6)
			{
				PI[killerid][TrazeniNivo] += 6;
				SetPlayerWantedLevel_Ex(killerid, PI[playerid][TrazeniNivo]);
			}
		}
		if(killerid != INVALID_PLAYER_ID)
	    {
			if(IsPlayerConnected(killerid) && GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
			{
				format(nellys,sizeof(nellys), "![WARNING]: %s[ID:%d] je uradio Drive By nad igracem %s[ID:%d]!", Ime_Igraca(killerid), killerid, Ime_Igraca(playerid), playerid);
			    StaffPoruka(COLOR_YELLOW, nellys);
			}
		}
		if(WantedPoint[playerid] > 0)
		{
			new wanted = WantedPoint[playerid];
			new diecash = 0;
		    while(WantedPoint[playerid] > 0)
		    {
		        diecash += 150;
		        WantedPoint[playerid] --;
		    }
		    SCMF(playerid, COLOR_YELLOW, ""COL_RED"* "BELA"(( Izgubili ste $%d zbog umiranja sa %d trazenih poena.", diecash, wanted);
		  	g_NovacMinus(playerid, diecash);
			format(nellys, sizeof(nellys), ""COL_RED"DEATH | "BELA"%s [ID:%d] je umro sa wanted level-om: %d.", ImeIgraca(playerid),playerid,PI[playerid][TrazeniNivo]);
	 		StaffPoruka(COLOR_YELLOW, nellys);
	 		strmid(PI[playerid][pZlocinText], "Nema", 0, strlen("Nema"), 255);
	        strmid(PI[playerid][pPrijavioText], "Nema", 0, strlen("Nema"), 255);
	        strmid(PI[playerid][pPocinioText], "Nema", 0, strlen("Nema"), 255);
			format(nellys,sizeof(nellys),"[HQ]: Zlocinac %s je umro sa wanted levelom(%d).", ImeIgraca(playerid),PI[playerid][TrazeniNivo]);
			FamilyPoruka(1, TEAM_BLUE_COLOR, nellys);
			FamilyPoruka(2, TEAM_BLUE_COLOR, nellys);
			PI[playerid][TrazeniNivo] = 0;
			SetPlayerWantedLevel_Ex(playerid, PI[playerid][TrazeniNivo]);
			SavePlayer(playerid);
		}
		WantedPoint[playerid] = 0;
	}
	if(Uwaru[killerid] == 1)
	{
	    new str[64];
		if(PI[killerid][pAlfa] == 1)
		{
		    alfa++;
 			format(str,sizeof(str),"~b~ALFA TIM: ~w~ %d",alfa);
			TextDrawSetString(warTD7, str);
			SetTimerEx("WarRespawn", 4000, false, "i", playerid);
		}
		else if(PI[killerid][pBeta] == 1)
		{
		    beta++;
 			format(str,sizeof(str),"~w~%d ~r~:BETA TIM",beta);
			TextDrawSetString(warTD8, str);
			SetTimerEx("WarRespawn", 4000, false, "i", playerid);
		}
	}
	AdminUbio[playerid] = 0;
	IgracNaEventu[playerid] = 0;
	if(IgracVojnik[playerid] == 1)
 	{
 	    Vojska--;
 	    EventSlotovi--;
 	    IgracVojnik[playerid] = 0;
 	}
 	if(PlayerBlind[playerid] == true)
	{
		PlayerBlind[playerid] = false;
		PlayerTextDrawHide(playerid, poveztd[playerid][0]);
		PlayerTextDrawHide(playerid, poveztd[playerid][1]);
	}
	if(TrakaStavljena[playerid] == true)
	{
		TrakaStavljena[playerid] = false;
	}
 	if(IgracTerorista[playerid] == 1)
 	{
 	    Teroristi--;
 	    EventSlotovi--;
 	    IgracTerorista[playerid] = 0;
 	}
 	if(IgracNaBaseball[playerid] == 1)
	{
		IgracNaBaseball[playerid] = 0;
		palicaekipa--;
		EventSlotovi--;
	}
	if(IgracNaMaraton[playerid] == 1)
	{
		IgracNaMaraton[playerid] = 0;
		Maratonci--;
		EventSlotovi--;
	}
	if(hSmetlar[playerid] == true)
	{
		DestroyPlayerObject(playerid,hSmece[playerid]);
	 	hSmetlar[playerid] = false;
	 	hVreca[playerid] = 0;
		hSmece[playerid] = -255;
	  	DisablePlayerCheckpoint(playerid);
	}
	if(EventVozilo[playerid] != -1)
 	{
 	    for(new sl = 0; sl < sizeof(MestoKartTrka); sl++)
		{
		    if(MestoKartTrka[sl] == EventVozilo[playerid])
			{
				MestoKartTrka[sl] = INVALID_VEHICLE_ID;
				break;
 			}
		}
		for(new sf = 0; sf < sizeof(MestoSFTrka); sf++)
		{
		    if(MestoSFTrka[sf] == EventVozilo[playerid])
   			{
				MestoSFTrka[sf] = INVALID_VEHICLE_ID;
				break;
 			}
		}
		for(new sc = 0; sc < sizeof(MestoInfTrka); sc++)
		{
		    if(MestoInfTrka[sc] == EventVozilo[playerid])
	  		{
				MestoInfTrka[sc] = INVALID_VEHICLE_ID;
				break;
 			}
		}
		for(new sq = 0; sq < sizeof(MestoGliserTrka); sq++)
		{
		    if(MestoGliserTrka[sq] == EventVozilo[playerid])
	  		{
				MestoGliserTrka[sq] = INVALID_VEHICLE_ID;
				break;
 			}
		}
		DestroyVehicle(EventVozilo[playerid]);
 	    EventVozilo[playerid] = -1;
 	}
	if(gPlayerUsingLoopingAnim[playerid])
	{
		gPlayerUsingLoopingAnim[playerid] = 0;
	}
	if(Vucen[playerid] != 9999)
	{
		KillTimer_H(VuciTimer[Vucen[playerid]]);
		IDVucenogIgraca[Vucen[playerid]] = 9999;
		Vucen[playerid] = 9999;
	}
	if(IDVucenogIgraca[playerid] != 9999)
	{
		KillTimer_H(VuciTimer[playerid]);
		IDVucenogIgraca[playerid] = 9999;
		Vucen[IDVucenogIgraca[playerid]] = 9999;
	}
    return 1;
}
    ~ Member since: 09.13.2013. - 15:30 ~

Rekao sam ti gore u cemu je problem, preleti kroz kod i eto..

"They have computers, and they may have other weapons of mass destruction."

A gde bih to trebao da stavim jel u svakoj komandi gde ima killerid i playerid?
    ~ Member since: 09.13.2013. - 15:30 ~

Moze pomoć? :-D
    ~ Member since: 09.13.2013. - 15:30 ~

BUMP!
    ~ Member since: 09.13.2013. - 15:30 ~

Ajd evo sjeo sam malo pa rpegledao tvoj kod, probaj zamjenit ovo
if(killerid == IPI)
   	{
		printf("[%d/%d/%d].[%d:%d:%d] | %s je umro!",td,tm1,ty,th,tm,ts,Ime_Igraca(playerid));
	}

Za ovo
if(killerid != INVALID_PLAYER_ID)
   	{
		printf("[%d/%d/%d].[%d:%d:%d] | %s je umro!",td,tm1,ty,th,tm,ts,Ime_Igraca(playerid));
	}

"They have computers, and they may have other weapons of mass destruction."

Hvala na vremenu ali i dalje mi izbacuje debug.
    ~ Member since: 09.13.2013. - 15:30 ~

Ne znam stvarno.Reći ću ti jedno, a to je da je lakše ponovo napisati taj kod nego naci gresku i ispraviti je :D

"They have computers, and they may have other weapons of mass destruction."

Kako ??
    ~ Member since: 09.13.2013. - 15:30 ~

BUMP!
    ~ Member since: 09.13.2013. - 15:30 ~

ae probaj da izbrises ovo da vidimo dal ce tada pistai to.
   if(killerid != INVALID_PLAYER_ID)
	    {
	    	PI[killerid][Ubistava]++; PI[playerid][Smrti]++;
			ResetujVar(playerid);
			if(IgracPolicajac(killerid))
			{
				PI[killerid][TrazeniNivo] = 0;
				SetPlayerWantedLevel_Ex(killerid,PI[playerid][TrazeniNivo]);
		 	}
	    }
	    if(killerid != INVALID_PLAYER_ID)
	    {
			if(!IgracPolicajac(killerid) && IsPlayerConnected(playerid))
			{
				if(PI[killerid][Zatvor] == 0)
				{
					PostaviWanted(killerid, "Ubistvo", "Nepoznat");
				}
			}
		}
		if(killerid != INVALID_PLAYER_ID)
	    {
			if(GetPlayerWantedLevel_Ex(killerid) > 6)
			{
				PI[killerid][TrazeniNivo] += 6;
				SetPlayerWantedLevel_Ex(killerid, PI[playerid][TrazeniNivo]);
			}
		}
		if(killerid != INVALID_PLAYER_ID)
	    {
			if(IsPlayerConnected(killerid) && GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
			{
				format(nellys,sizeof(nellys), "![WARNING]: %s[ID:%d] je uradio Drive By nad igracem %s[ID:%d]!", Ime_Igraca(killerid), killerid, Ime_Igraca(playerid), playerid);
			    StaffPoruka(COLOR_YELLOW, nellys);
			}
		}