SA-MP Forums Archive
Foreach question. - 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: Foreach question. (/showthread.php?tid=601327)



Foreach question. - [eLg]elite - 19.02.2016

Код:
	foreach(new i : Player)
	{
	    if(Data[i][Sr] == 1)
	    {
	        if(Data[i][pPower] < 150)
			{
		 		SendClientMessage(playerid, COLOR_RED, "Error: You do not have enough energy!");
		 		Data[i][Sr] = 0;
		 		Data[i][trans] = 0;
		 		Data[i][pPower] = Data[i][sPower];
		 		return 1;
			}
So basically, if I use 'i' after I have determined who it's not talking about, will it still effect everyone?


Re: Foreach question. - LovelySoomro - 20.02.2016

Quote:

foreach(new i : Player)
{
if(Data[i][Sr] == 1)
{
if(Data[i][pPower] < 150)
{
SendClientMessage(i, COLOR_RED, "Error: You do not have enough energy!");
Data[i][Sr] = 0;
Data[i][trans] = 0;
Data[i][pPower] = Data[i][sPower];
}}}
return 1;
}

try this