Raised This Month: $12 Target: $400
 3% 

Solved loop entitys


Post New Thread Reply   
 
Thread Tools Display Modes
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 11-16-2022 , 22:04   Re: loop entitys
Reply With Quote #21

Quote:
Originally Posted by Celena Luna View Post
IT-CALLED-ONLY-ONCE when the function is called.
You making a comparation between a loop run for 100 times and a loop run for 4 times and 1 variable
I think I have shown you with the images that it is not checking 100 times, it is checking if the value is 100, otherwise 100 prints would come out before the print "end of loop" anyway, I think you didn't end up understanding

Here are the images again so you can see that it does not check 100 times

removeTransEnts( Client, {2,8,15,100} );

3 prints(2,8,15) => end of the loop( the 100 is the trigger for end the loop )

https://ibb.co/5skxXMd

and I'm doing a single loop, I don't know where you got it, I'm doing 2, I'm increasing the value of the cells, and when the loop ends, it is because IN ONE OF THOSE CELLS it contains the value 100

you are inventing a problem where there is none, the way I did it is the most effective without extra variables

Last edited by MrPickles; 11-16-2022 at 22:12.
MrPickles is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 11-16-2022 , 22:40   Re: loop entitys
Reply With Quote #22

you are misunderstanding how For-loop actually work
what you did it still go through 100 loop without doing anything unless it reach the "value" in the array, it still take memories while doing so and take time to go though 100

Your code translate something like this
PHP Code:
        for( new 0100i++)
        { 
            if(
== || == || == 15 || == 100)
                    
client_printClientprint_chat"The Cell [%d] have a value of  = %d"i__int_Entitys[i] );          
        }
        
client_printClientprint_chat"End of the Loop" ); 
Of course, this is not what you wrote but it is actually how it run
__________________
My plugin:

Last edited by Celena Luna; 11-16-2022 at 22:47.
Celena Luna is offline
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 11-16-2022 , 22:42   Re: loop entitys
Reply With Quote #23

Quote:
Originally Posted by Celena Luna View Post
you are misunderstanding how For-loop actually work
what you did it still go through 100 loop without doing anything unless it reach the "value" in the array, it still take memories while doing so and take time to go though 100

What you actually con translate to this
PHP Code:
        for( new 0100i++)
        { 
            if(
== || == || == 15 || == 100)
                    
client_printClientprint_chat"The Cell [%d] have a value of  = %d"i__int_Entitys[i] );          
        }
        
client_printClientprint_chat"End of the Loop" ); 
Of course, this is not what you wrote but it is actually how it work
in the case of that code, if you are looping between 0 and 100, it's not the case that I did, because I'm not saying that i < 100, I'm saying that __int_Entitys[i] < 100, they are totally different things to buy

am checking the value of __int_Entitys[i], what is increased is the value of i, to go checking cell by cell until the value of 100 appears between them

I mean

i
[0] = 2
[1] = 8
[2] = 15
[3] = 100 // stop the loop cause it must be __int_Entitys[i] < 100

I think I have explained it 5 times and you still do not understand, you are giving an example that has nothing to do with what I did to try to deny something quite simple, I will put it again:

https://ibb.co/5skxXMd

"Your code translate something like this"
they are things that are too very different, it is not comparable

PHP Code:
        for( new 0100i++)
        { 
                    
client_printClientprint_chat"The Cell [%d] have a value of  = %d"i__int_Entitys[i] );    // 100 prints      
        
}
        
client_printClientprint_chat"End of the Loop" ); 
end when i == 100

PHP Code:
        for( new 0__int_Entitys[i] < 100i++)
        { 
                    
client_printClientprint_chat"The Cell [%d] have a value of  = %d"i__int_Entitys[i] );     // 3 prints     
        
}
        
client_printClientprint_chat"End of the Loop" ); 
=============== i
end when __int_Entitys[3] == 100

Last edited by MrPickles; 11-16-2022 at 23:04.
MrPickles is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 11-16-2022 , 22:52   Re: loop entitys
Reply With Quote #24

Fine, if you happy with what you wrote, you do you
I don't know what you want
I don't get what you want
I don't get your logic
so congratz on archiving whatever you was supposed to ask
__________________
My plugin:

Last edited by Celena Luna; 11-16-2022 at 22:56.
Celena Luna is offline
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 11-16-2022 , 22:55   Re: loop entitys
Reply With Quote #25

Quote:
Originally Posted by Celena Luna View Post
Fine, if you happy with what you wrote, you do you
I don't know what you want
I don't get what you want
I don't get your logic
so congratz on archiving whatever you was supposed to ask
It is something quite simple, you think that I am counting from 0 to 100, when it isnt so, I am increasing the cells to check that if any of those cells contains the value 100, it is something quite simple, above in the example I left you the differences

In theory I have already achieved it, so i dont want something that I have

"I wrote and said it is different"
So why put it if you know that what I wrote and your last loop work totally different, saying that they work the same

and it's not a matter of being happy if I achieved it or not, it's also to show what I've achieved, many times people try to help and they confuse more, but I hope you understand

Last edited by MrPickles; 11-16-2022 at 23:02.
MrPickles is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 11-16-2022 , 23:08   Re: loop entitys
Reply With Quote #26

PHP Code:
        for( new 0100i++)
        { 
                    
client_printClientprint_chat"The Cell [%d] have a value of  = %d"i__int_Entitys[i] );    // 100 prints      
        
}
        
client_printClientprint_chat"End of the Loop" ); 
PHP Code:
        for( new 0100i++)
        { 
            if(
== || == || == 15 || == 100)
                    
client_printClientprint_chat"The Cell [%d] have a value of  = %d"i__int_Entitys[i] ); //3 prints     
        
}
        
client_printClientprint_chat"End of the Loop" ); 
PHP Code:
        for( new 0__int_Entitys[i] < 100i++)
        { 
                    
client_printClientprint_chat"The Cell [%d] have a value of  = %d"i__int_Entitys[i] );     // 3 prints     
        
}
        
client_printClientprint_chat"End of the Loop" ); 
__________________
My plugin:

Last edited by Celena Luna; 11-16-2022 at 23:08.
Celena Luna is offline
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 11-16-2022 , 23:10   Re: loop entitys
Reply With Quote #27

let me give you another perspective if you want to use if so much

PHP Code:
        for( new 0100i++)
        { 
            
// 100 counts before end the loop

            
if(== || == || == 15 || == 100)
                    
client_printClientprint_chat"The Cell [%d] have a value of  = %d"i__int_Entitys[i] ); 
        }
        
client_printClientprint_chat"End of the Loop" ); 
PHP Code:
        for( new 0100i++)
        { 
            
// 100 counts before end the loop
                    
client_printClientprint_chat"The Cell [%d] have a value of  = %d"i__int_Entitys[i] ); 
        }
        
client_printClientprint_chat"End of the Loop" ); 
PHP Code:
        for( new 0__int_Entitys[i] < 100i++)
        { 
                    
// 3 counts before end the loop
                    
client_printClientprint_chat"The Cell [%d] have a value of  = %d"i__int_Entitys[i] );     
        }
        
client_printClientprint_chat"End of the Loop" ); 
i < 100 != __int_Entitys[i] < 100 , very simple

Last edited by MrPickles; 11-16-2022 at 23:12.
MrPickles is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-16-2022 , 23:20   Re: loop entitys
Reply With Quote #28

tl;dr

Quote:
Originally Posted by MrPickles View Post
nop, u are wrong, the loop doesnt count from 0 to 100, look:

if this is my array:
PHP Code:
{2,4,6,100
the loop do this:

PHP Code:
     // i        i++
Array[0] = // i = 0
Array[1] = // i = 1
Array[2] = // 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
PHP Code:
100 
, but isnt the case, u can check it by yourself with the prints that i setted
Indeed, you are correct, I misread that part. However, it relies on a specific input value that is not actually related to the purpose of the input to prevent the loop from causing the index out of bounds error which isn't really a good design. My method does not require this and will allow you to reliably iterate over the input array regardless of the values contained within the array.
__________________
fysiks is offline
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 11-16-2022 , 23:22   Re: loop entitys
Reply With Quote #29

Quote:
Originally Posted by fysiks View Post
tl;dr



Indeed, you are correct, I misread that part. However, it relies on a specific input value that is not actually related to the purpose of the input to prevent the loop from causing the index out of bounds error which isn't really a good design. My method does not require this and will allow you to reliably iterate over the input array regardless of the values contained within the array.
It doesn't actually cause the indexes outside the bones, because it's __int_Entity[i] < 100, if it were the case that error would be __int_Entity[i] <= 100 ( tested )

__int_Entity[i] < 100, when reading that it has the value of 100, it immediately stops the loop, when it is <= it includes that __int_TransEnts[Client][100] exists (even though it doesn't actually exist)

https://ibb.co/5skxXMd

if it were the case of an index error outside the bones, it would print the 100

Last edited by MrPickles; 11-16-2022 at 23:34.
MrPickles is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-16-2022 , 23:44   Re: loop entitys
Reply With Quote #30

Quote:
Originally Posted by MrPickles View Post
It doesn't actually cause the indexes outside the bones, because it's __int_Entity[i] < 100, if it were the case that error would be __int_Entity[i] <= 100 ( tested )
I know that. If you forget to include the 100 in the input array then you'll go out of bounds though.

My point is that you're relying on having to remember that you have to pass a 100 in the input array. It obfuscates the purpose of the input variable (e.g. the variables intent is to contain X's but you require it to include Y). Also, if you ever need to make that number some other value, it requires you to remember to update it in every location which makes it non-scalable.

At this point, I'm not really worried about the its core functionality and more giving suggestions for robustness and scalability. Regardless, you're free to ignore my suggestions and do it however you'd like. You've got the most important part worked out by using a function with a loop in it.

I also just noticed that you should validate that the values ("__int_Entitys[i]") in the array are less than "sizeof __int_TransEnts[]". But again, you're welcome to omit many of these types of checks if you're the only one that will ever use the function and you'll guarantee that the values will never exceed the appropriate limits.
__________________
fysiks is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:46.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode