Raised This Month: $ Target: $400
 0% 

Solved loop entitys


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-16-2022 , 00:16   Re: loop entitys
Reply With Quote #1

I'm not sure how you don't get any index out-of-bounds errors because you're trying to index an array from 0 to 99 where the array is much much smaller than 100 (in your case 4 or 5 depending on which function call you're using).

You can actually determine the size of the provided array by using the sizeof directive as the default for a "length" parameter:

PHP Code:
myFunction(myArray[], len sizeof myArray)
{
    
server_print("Array Size: %d"len)

where

PHP Code:
    myFunction({1,3,5})
    
myFunction({1})
    
myFunction({2,34,3.34,3.0,34.0,34,0.0}) 
results in:

Code:
Array Size: 3
Array Size: 1
Array Size: 7
__________________
fysiks is offline
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 11-16-2022 , 02:04   Re: loop entitys
Reply With Quote #2

Quote:
Originally Posted by fysiks View Post
I'm not sure how you don't get any index out-of-bounds errors because you're trying to index an array from 0 to 99 where the array is much much smaller than 100 (in your case 4 or 5 depending on which function call you're using).

You can actually determine the size of the provided array by using the sizeof directive as the default for a "length" parameter:

PHP Code:
myFunction(myArray[], len sizeof myArray)
{
    
server_print("Array Size: %d"len)

where

PHP Code:
    myFunction({1,3,5})
    
myFunction({1})
    
myFunction({2,34,3.34,3.0,34.0,34,0.0}) 
results in:

Code:
Array Size: 3
Array Size: 1
Array Size: 7

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

check it with this:

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 02:45.
MrPickles is offline
Reply



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 15:43.


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