SA-MP Forums Archive
Problem with OnPlayerConnect - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with OnPlayerConnect (/showthread.php?tid=584944)



Problem with OnPlayerConnect - sjames - 09.08.2015

So a bug started to happen, when players started coming into the server, at some point the login dialog didn't show. I uses Crashdetect plugin and this is what it showed me:

Код:
[08:53:52] [join] 7889 has joined the server (8:186.92.233.172)
[08:53:52] [debug] Run time error 4: "Array index out of bounds"
[08:53:52] [debug]  Accessing element at index 8 past array upper bound 7
[08:53:52] [debug] AMX backtrace:
[08:53:52] [debug] #0 00092fe4 in UpdateNewsBox (message[]=@005f48c0 "~g~[JOIN] ~w~7889(8) has ~g~joined ~w~the server.") at C:\Users\Risto\Desktop\samp\gamemodes\BFPR1.8.pwn:7136
[08:53:52] [debug] #1 00063118 in public ELC_AC_OnPlayerConnect (playerid=8) at C:\Users\Risto\Desktop\samp\gamemodes\BFPR1.8.pwn:2671
[08:53:52] [debug] #2 native CallLocalFunction () from samp03svr
[08:53:52] [debug] #3 00036864 in ?? (... <1 argument>) at C:\Users\Risto\Desktop\samp\pawno\include\ELC_AC_BASE.inc:930
[08:53:52] [debug] #4 0001a4ec in public SSCANF_OnPlayerConnect (playerid=8) at C:\Users\Risto\Desktop\samp\pawno\include\YSI\y_hooks/impl.inc:618
[08:53:52] [debug] #5 0000e788 in public Itter_OnPlayerConnect (playerid=8) at C:\Users\Risto\Desktop\samp\pawno\include\sscanf2.inc:236
[08:53:52] [debug] #6 0000cb40 in public FIXES_OnPlayerConnect (... <1 argument>)  at C:\Users\Risto\Desktop\samp\pawno\include\YSI\y_iterate.inc:646
[08:53:52] [debug] #7 00004578 in public OnPlayerConnect (playerid=8) at C:\Users\Risto\Desktop\samp\pawno\include\fixes.inc:3838
This is the newsbox stock:

Код:
stock UpdateNewsBox(message[])
{
	// Shifting the messages up by 1. The most upper news is NewsBox[1];
	TextDrawSetString(NewsBox[1], NewsBoxString[2]);
	NewsBoxString[1] = NewsBoxString[2];
	TextDrawSetString(NewsBox[2], NewsBoxString[3]);
	NewsBoxString[2] = NewsBoxString[3];
	TextDrawSetString(NewsBox[3], NewsBoxString[4]);
	NewsBoxString[3] = NewsBoxString[4];
	TextDrawSetString(NewsBox[4], NewsBoxString[5]);
	NewsBoxString[4] = NewsBoxString[5];
	TextDrawSetString(NewsBox[5], NewsBoxString[6]);
	NewsBoxString[5] = NewsBoxString[6];
	
	format(NewsBoxString[6], sizeof NewsBoxString[], "%s", message);
	TextDrawSetString(NewsBox[6], NewsBoxString[6]);
	for(new i = 1; i < sizeof NewsBox; i++)
	{
		foreach(new x: Player)
		{
			if(JustJoined[x] != 1) TextDrawShowForPlayer(x, NewsBox[x]);
		}
	}
}



Re: Problem with OnPlayerConnect - Jefff - 09.08.2015

TextDrawShowForPlayer(x, NewsBox[x]); change [x] to [i]