SA-MP Forums Archive
How to get for() looping to return 0 - 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: How to get for() looping to return 0 (/showthread.php?tid=451601)



How to get for() looping to return 0 - serj009 - 17.07.2013

Basically I am having a hard time how to get for looping posted below to return 0 or 1 while it still loops through i
Код:
for(new i = 0; i < 17; i++)
{
	if(List[i][Position] < 16) 
	{
		if(List[i][Number] == -1) 
		{
			//code
			List[i][Position] ++;
		}
		else
		{
			//code
			List[i][Position] ++;			
		}
		return 0;
	}
}
right now this code only goes to i = 0. nothing else.
I have tried break; but that also keeps i at 0


Re: How to get for() looping to return 0 - thimo - 17.07.2013

Why would you put return 0; there? if theres nothing there and doesnt meet requierments for the next if statement it just doesnt excecute anything


Re: How to get for() looping to return 0 - serj009 - 17.07.2013

Well basically this is under OnPlayerText. I want this to be executed and NO text to be returned to the chat box. However. Taking away return 0; will make the text a player inputs to show up in the chat box.


Re: How to get for() looping to return 0 - thimo - 17.07.2013

So you dont want OnPlayerText returning anything and only your code? If so then just put return 0 at onplayertext like this:
pawn Код:
public OnPlayerText
{
    return 0;
}



Re: How to get for() looping to return 0 - serj009 - 17.07.2013

Quote:
Originally Posted by ******
Посмотреть сообщение
Put it AFTER the loop.
Thank's for your input ******, Unfortunately putting the return after the loop did not solve the issue and allowed the text to appear in the chat box. Just as if I didn't have return 0; there at all. I have tried both return 0; and return 1;


Quote:
Originally Posted by thimo
Посмотреть сообщение
So you dont want OnPlayerText returning anything and only your code? If so then just put return 0 at onplayertext like this:
pawn Код:
public OnPlayerText
{
    return 0;
}
Well it's a little more complicated than that. This code in my OP is under a function that is under OnPlayerText. There is plenty more code under OnPlayerText that all works fine, however executing the function containing the loop in my OP causes the text to appear in the main chat box.

I hope i am making myself understandable, It's a bit complicated for me to find a way to explain it. I have been working on this for a few hours now.


Re: How to get for() looping to return 0 - MP2 - 18.07.2013

Please post your entire callback.