AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Quick for-loop question.. (https://forums.alliedmods.net/showthread.php?t=11860)

Bugsy 03-30-2005 00:53

Quick for-loop question..
 
Just wondering if my mind serves me correctly from my past C++ experience.

Code:
for( new chk2=1; chk2<=get_maxplayers(); ++chk2)

That would Loop from 2 through maxplayers and

Code:
for( new chk2=1; chk2<=get_maxplayers(); chk2++)

would loop from 1 to maxplayers... correct?

thanks

Freecode 03-30-2005 00:54

yes

Bugsy 03-30-2005 01:26

Thanks, chief.

BAILOPAN 03-30-2005 01:39

Optimization tip of the day: store get_maxplayers in a variable before the for loop, that way it's not called every time.

XxAvalanchexX 03-30-2005 23:00

Didn't PM or someone also say something against declaring a variable in the syntax of a for loop (chk2 in this case)?

xeroblood 03-31-2005 00:16

I believe that was because breaking out of the loop before the condition is met results in the memory of the variable (declared within the for-loop using 'new') fails to get released/freed properly..

But wasn't that an issue with the old compiler released by CompuPhase and addressed properly in the newer compiler released with AMXX??


All times are GMT -4. The time now is 09:56.

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