Raised This Month: $ Target: $400
 0% 

[HELP] Getting num from const depending on condition - easy way


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 06-15-2014 , 20:40   Re: [HELP] Getting num from const depending on condition - easy way
Reply With Quote #1

Correct-me if i am wrong,

PHP Code:
new g_iCount;

public 
MyFunction()
{
    do
    {
        
g_iCount++; // or g_iCount += 1
    
}
    while(
g_iCount <= 10)

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 06-15-2014 , 21:34   Re: [HELP] Getting num from const depending on condition - easy way
Reply With Quote #2

Quote:
Originally Posted by Flick3rR View Post
Is that correct enough?
PHP Code:
new num 
for(new 1sizeof Tagsi++)
{
    if(
Flag Tags[i][flag])
    {
        
num i
        
break
    }

This looks correct and will achieve what you outlined in your first post. Using break will immediately exit out of the loop and num will contain the first index at which your desired condition became true.

The only issue I see is that array indexes usually start at 0, but I don't know precisely what kind of array structure/layout you are working with here.

Quote:
Originally Posted by ^SmileY View Post
Correct-me if i am wrong,

PHP Code:
new g_iCount;

public 
MyFunction()
{
    do
    {
        
g_iCount++; // or g_iCount += 1
    
}
    while(
g_iCount <= 10)

While this is a correct do-while loop (and a do-while can also be used to solve this problem), this code piece is irrelevant to the question.
__________________
In Flames we trust!
Nextra is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-15-2014 , 22:18   Re: [HELP] Getting num from const depending on condition - easy way
Reply With Quote #3

I definitely do NOT recommend a while loop in this case since you know the maximum number of times the loop will execute.
__________________
fysiks 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 21:04.


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