Can i do it like that?
#1

Код:
foreach(new allplayerqq : Player)
{
if(cache_num_rows())
				{
					for(new r=0; r < cache_get_row_count(); ++r)
					{
					    cache_get_row(r, 0, internetplayername);

						format( createstring,25,"%s", internetplayername );
						SendClientMessage( allplayerqq,COLOR_YELLOW,createstring );
					}
				}
			
}
What i have mean, can i do foreach and then do a for(new and get a information from mysql for everone player?
Reply
#2

Yes. You can put loops inside loops inside loops inside loops (x infinity).

I recommend putting the cache_num_rows check outside the first loop, otherwise it would check to all players and stop if it's missing all the times.
Reply
#3

But i mean, when i will do it for first player

for(new r=0; r < cache_get_row_count(); ++r)
{
And then when will be other player, i too can get

for(new r=0; r < cache_get_row_count(); ++r)
{

?
Reply
#4

Quote:
Originally Posted by audriuxxx
Посмотреть сообщение
But i mean, when i will do it for first player

for(new r=0; r < cache_get_row_count(); ++r)
{
And then when will be other player, i too can get

for(new r=0; r < cache_get_row_count(); ++r)
{

?
Loops are run X amount times as you specified. Foreach will run one time per player, and within that one time per player run, the second loop will run X amount of times as you specified it (in this case, cache_get_row_count() amount of times).
Код:
Run(10 times)
{
     run(20 times)
     {
         //code
     }
}
That's just an example, that code would be run 200 amount of times, whatever is first will be run 10 times and inside those 10 times a new code will be run 20 times each run the first one haves.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)