|
Senior Member
Join Date: Aug 2022
Location: Colombia
|
11-16-2022
, 14:59
Re: loop entitys
|
#9
|
Quote:
Originally Posted by MrPickles
nop, u are wrong, the loop doesnt count from 0 to 100, look:
if this is my array: the loop do this:
PHP Code:
// i i++ Array[0] = 2 // i = 0 Array[1] = 4 // i = 1 Array[2] = 6 // i = 2 Array[3] = 100 // i = 3, oops this cell contain 100, so we can stop
thats why the condition,
PHP Code:
__int_Entitys[i] < 100
if it was counting from 0 to 100, it will be , but isnt the case, u can check it by yourself with the prints that i setted
check it with this:
PHP Code:
public Test( Client ) { removeTransEnts( Client, {2,8,15,100} ); return 1; } removeTransEnts(Client, __int_Entitys[] ) { for( new i = 0; __int_Entitys[i] < 100; i++) { client_print( Client, print_chat, "The Cell [%d] have a value of = %d", i, __int_Entitys[i] ); } client_print( Client, print_chat, "End of the Loop" ); }
|
Quote:
Originally Posted by Natsheh
Why don't you make the loop as following it will be rather than using 100 to stop the loop.
PHP Code:
for( new i = 0; __int_Entitys[i] < 100; i++)[
PHP Code:
for( new i = 0, maxloop = strlen(__int_Entitys) - 1; i < maxloop; i++)
|
it is more simple to set 100, thats all, more operations are saved
in a loop the simpler is better, think that each time you will be checking and obtaining the length of the array (-1), instead with 100, it only checks if it is the cell contain 100
Last edited by MrPickles; 11-16-2022 at 15:08.
|
|
|
|