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 , 20:51   Re: loop entitys
Reply With Quote #11

Quote:
Originally Posted by Celena Luna View Post
1. I disagree with this
What if the number of loop is smaller, for example, only 10 is required.
But it have to run 100 times every single time because you hardcode it to 100
Isn't that worse?
Not to mention, you are using a giantic array2D with the size of 3100+ (100 entity x 31 clients) so that would cost much more performen than that small check in for-loop is

2. The code feel really weird to me.
Tell me if I am wrong:
With this as example
PHP Code:
removeTransEntsClient, {0,1,2,100} ); 
You are trying to remove any entity at the index contain inside __int_Entitys[]
=> you want to get this
  • __int_TransEnts[Client][0]
  • __int_TransEnts[Client][1]
  • __int_TransEnts[Client][2]
  • __int_TransEnts[Client][100]

If that the case, what you want to loop is NOT the value insde the __int_Entitys[] but it size.

The code can change it into this
PHP Code:
removeTransEnts(Client__int_Entitys[], max sizeof __int_Entitys)  
{
        for( new 
0maxi++)
        { 
              if(
is_valid_ent(__int_TransEnts[Client][__int_Entitys[i]]))
              {
                    
remove_entity__int_TransEnts[Client][__int_Entitys[i]] );
                    
__int_TransEnts[Client][__int_Entitys[i]] = 0;
                    
client_printClientprint_chat"Entity Removed = [Client][%d]"__int_Entitys[i] );

              }
              
client_printClientprint_chat"Entity Checked = [Client][%d]"__int_Entitys[i] );             
        }

You are totally wrong, as I said you are not making a loop from 0 to 100, if so the condition would be i < 100, but it is __int_Entity[i], that is, it is checking and increasing each cell, until the value of that 100

that is

PHP Code:
            i
__int_Array
[0] = 2
__int_Array
[1] = 4
__int_Array
[2] = 6
__int_Array
[2] = 100 // __int_Array[i] = 100, oops this cell contains 100 
As I said, you are not counting from 0 to 100, try the small code above that they send with the prints and you will see that it does not go from 0 to 100

I don't think anyone will try this code with the print, there all doubts will be cleared up, i < 100 is not equal to __int_Entity[i] < 100

PHP Code:
public TestClient )
{
        
removeTransEntsClient, {2,8,15,100} ); 
        return 
1;
}
removeTransEnts(Client__int_Entitys[] )  
{
        for( new 
0__int_Entitys[i] < 100i++)
        { 
               
client_printClientprint_chat"The Cell [%d] have a value of  = %d"i__int_Entitys[i] );          
        }
        
client_printClientprint_chat"End of the Loop" );


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

Quote:
Originally Posted by MrPickles View Post
You are totally wrong, as I said you are not making a loop from 0 to 100, if so the condition would be i < 100, but it is __int_Entity[i], that is, it is checking and increasing each cell, until the value of that 100

that is

PHP Code:
                  i
__int_Array
[0] = 2
__int_Array
[1] = 4
__int_Array
[2] = 6
__int_Array
[2] = 100 // __int_Array[i] = 100, oops this cell contains 100 
As I said, you are not counting from 0 to 100, try the small code above that they send with the prints and you will see that it does not go from 0 to 100
OK
For example
PHP Code:
removeTransEntsClient, {100} ); 
You want to run it like this?
PHP Code:
remove_entity__int_TransEnts[Client][0] );
remove_entity__int_TransEnts[Client][1] );
remove_entity__int_TransEnts[Client][2] );
...
remove_entity__int_TransEnts[Client][99]);
remove_entity__int_TransEnts[Client][100]); 
or this?

PHP Code:
remove_entity__int_TransEnts[Client][100] ); 
If it is the first one, your code is correct. nothing to change
__________________
My plugin:

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

Quote:
Originally Posted by Celena Luna View Post
OK
For example
PHP Code:
removeTransEntsClient, {100} ); 
You want to run it like this?
PHP Code:
remove_entity__int_TransEnts[Client][0] );
remove_entity__int_TransEnts[Client][1] );
remove_entity__int_TransEnts[Client][2] );
...
remove_entity__int_TransEnts[Client][99]);
remove_entity__int_TransEnts[Client][100]); 
or this?

PHP Code:
remove_entity__int_TransEnts[Client][100] ); 
eh nope, if it's like you say {100}, the loop will end immediately, cause if must __int_Entity[i] < 100 you still think there is a [100], when I'm checking the value of that cell, not THAT cell, check the print in the game that i send u and tell me

and it is not any of the ones you sent, you are quite wrong

The Cell [%d] have a value of = %d", i, __int_Entitys[i]

its very simple...

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

Quote:
Originally Posted by MrPickles View Post
eh nope, if it's like you say {100}, the loop will end immediately, cause if must __int_Entity[i] < 100 you still think there is a [100], when I'm checking the value of that cell, not THAT cell, check the print in the game that i send u and tell me
then with your code if you change from this
PHP Code:
removeTransEntsClient, {0,1,2,100} ); 

PHP Code:
removeTransEntsClient, {100,0,1,2} ); 
Then isn't it also gonna end right away?
__________________
My plugin:

Last edited by Celena Luna; 11-16-2022 at 21:12.
Celena Luna is offline
Old 11-16-2022, 21:13
MrPickles
This message has been deleted by MrPickles.
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 11-16-2022 , 21:13   Re: loop entitys
Reply With Quote #15

Quote:
Originally Posted by Celena Luna View Post
then with your code if you change from this
PHP Code:
removeTransEntsClient, {0,1,2,100} ); 

PHP Code:
removeTransEntsClient, {100,0,1,2} ); 
Then isn't it also gonna end right away?
in the 2nd the loop will end immediately, that's why the 100 must go at the end, since you don't want to try with the print I will send some images

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

https://ibb.co/5skxXMd

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

https://ibb.co/b2gP8hK


PHP Code:
public CMDClient )
{
     
removeTransEntsClient, {2,8,15,100} ); 
     return 
1;
}
removeTransEnts(Client__int_Entitys[] )  
{                                                                                                                                                                      
//i
                              // i = 0,1,2,3..  if __int_Entitys[i] have a value of 100, the loop finish, in this case, __int_Entitys[3] = 100
        
for( new 0__int_Entitys[i] < 100i++)
        { 
               
client_printClientprint_chat"The Cell [%d] have a value of  = %d"i__int_Entitys[i] );          
        }
        
client_printClientprint_chat"End of the Loop" );

try by yourself...

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

and with my code it shown like this


PHP Code:
public TestClient )
{
        
removeTransEntsClient, {2,8,15,100} ); 
        return 
1;
}
removeTransEnts(Client__int_Entitys[], max sizeof __int_Entitys )  
{
        for( new 
0maxi++)
        { 
               
client_printClientprint_chat"The Cell [%d] have a value of  = %d"i__int_Entitys[i] );          
        }
        
client_printClientprint_chat"End of the Loop" );


and for removeTransEnts( Client, {100,8,15,0} );
__________________
My plugin:

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

Quote:
Originally Posted by Celena Luna View Post
and with my code it shown like this


PHP Code:
public TestClient )
{
        
removeTransEntsClient, {2,8,15,100} ); 
        return 
1;
}
removeTransEnts(Client__int_Entitys[], max sizeof __int_Entitys )  
{
        for( new 
0maxi++)
        { 
               
client_printClientprint_chat"The Cell [%d] have a value of  = %d"i__int_Entitys[i] );          
        }
        
client_printClientprint_chat"End of the Loop" );


and for removeTransEnts( Client, {100,8,15,0} );
because you modified it, I think you didn't understand how it works and you still touched it, try with the code that I sent you intact, the one I made works perfectly, as in the images I sent you, just change the values for you to try

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

Quote:
Originally Posted by MrPickles View Post
because you modified it, I think you didn't understand how it works and you still touched it, try with the code that I sent you intact, the one I made works perfectly, as in the images I sent you
my point is, it does the same thing. So what is your points?
__________________
My plugin:

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

Quote:
Originally Posted by Celena Luna View Post
my point is, it does the same thing. So what is your points?
you are obtaining and checking the size of the array at all times, in addition to adding another variable to it, instead I am checking the value of the cell only
but yes, now you managed to do it, in a less effective way in short

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

Quote:
Originally Posted by MrPickles View Post
you are obtaining and checking the size of the array at all times, in addition to adding another variable to it, instead I am checking the value of the array only
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
__________________
My plugin:
Celena Luna 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 05:44.


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