Loop wont run more than 4 times
I have this very weird problem, my loop wont run for more than 4 times. Sometimes it runs just once and other times it runs 4 times. Completely random how it runs.
PHP Code:
I have replaced 32 with "playerCount" to try and force it to run 32 times, but no luck there either. How can this be happening? EDIT: Oh, now it just ran 6 times and apparently I did have one of those id's, and the only thing I got was bonus HP and AP, no gravity for me, nor did I get any debug message. |
Re: Loop wont run more than 4 times
return stops the whole function from executing anything after it.
Therefore, if a player is a zombie or nemesis, all other players after it won't be checked. You should use continue to go to the next loop iteration. |
Re: Loop wont run more than 4 times
So:
PHP Code:
|
Re: Loop wont run more than 4 times
continue stops executing the loop for that 1 iteration and goes to the next one.
Also, continue can be used in all types of loops. Example: Code:
This would be the process: Code:
create and initialize i to 0Code:
0 |
Re: Loop wont run more than 4 times
Oh, thank you for that!
I have tested it and it works as I want it to, awesome. |
Re: Loop wont run more than 4 times
Also, client_print(0, print_chat, "[Debug] loop is running %d", player) would only print the player id that the current iteration is using. Use client_print(0, print_chat, "[Debug] loop is running %d", i)to print the actual loop iteration number.
|
Re: Loop wont run more than 4 times
Also for sure add:
PHP Code:
|
Re: Loop wont run more than 4 times
Quote:
|
Re: Loop wont run more than 4 times
But loop is for 1 to 32.
|
Re: Loop wont run more than 4 times
Quote:
|
| All times are GMT -4. The time now is 19:57. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.