Quote:
Originally Posted by MrPickles
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
|
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 anwser code feel really weird to me.
Tell me if I am wrong:
With this as example
PHP Code:
removeTransEnts( Client, {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
__int_Entitys[]'s size
NOT the value insde it.
The code can change it into this
PHP Code:
removeTransEnts(Client, __int_Entitys[], max = sizeof __int_Entitys)
{
for( new i = 0; i < max; i++)
{
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_print( Client, print_chat, "Entity Removed = [Client][%d]", __int_Entitys[i] );
}
client_print( Client, print_chat, "Entity Checked = [Client][%d]", __int_Entitys[i] );
}
}
__________________