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
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-15-2014 , 16:45   [HELP] Getting num from const depending on condition - easy way
Reply With Quote #1

So, I won't explain much, because I simply don't know how to explain it properly. Will just give you an example and ask you - is there some better way to get the same result, because I want to make this for pretty huge numbers.
PHP Code:
new num
    
if(Flag Tags[1][flag])    num 1
    
else if(Flag Tags[2][flag])    num 2
    
else if(Flag Tags[3][flag])    num 3
    
else if(Flag Tags[4][flag])    num 4
    
else if(Flag Tags[5][flag])    num 5
    
else if(Flag Tags[6][flag])    num 
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-15-2014 , 16:51   Re: [HELP] Getting num from const depending on condition - easy way
Reply With Quote #2

A loop is the only alternative that I can think of.
__________________

Last edited by fysiks; 06-15-2014 at 16:51.
fysiks is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-15-2014 , 17:01   Re: [HELP] Getting num from const depending on condition - easy way
Reply With Quote #3

Yes, but the loop returns all of the numbers inside the const... And in that case, it always returns the last number (because I can use only one number - in other case all of them are returned and used).
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-15-2014 , 17:04   Re: [HELP] Getting num from const depending on condition - easy way
Reply With Quote #4

Quote:
Originally Posted by Flick3rR View Post
Yes, but the loop returns all of the numbers inside the const... And in that case, it always returns the last number (because I can use only one number - in other case all of them are returned and used).
Not if you program it correctly. Simply use a break or use a subfunction and return the value.
__________________

Last edited by fysiks; 06-15-2014 at 17:05.
fysiks is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-15-2014 , 17:27   Re: [HELP] Getting num from const depending on condition - easy way
Reply With Quote #5

Is that correct enough?
PHP Code:
new num 
for(new 1sizeof Tagsi++)
{
    if(
Flag Tags[i][flag])
    {
        
num i
        
break
    }

__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-15-2014 , 17:30   Re: [HELP] Getting num from const depending on condition - easy way
Reply With Quote #6

Quote:
Originally Posted by Flick3rR View Post
Is that correct enough?
What happens when you run it?
__________________
fysiks is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-15-2014 , 17:32   Re: [HELP] Getting num from const depending on condition - easy way
Reply With Quote #7

Can't test right now.... If I could, I would test it and post the results. And that's why I posted it here withouth knowing.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 06-15-2014 , 19:00   Re: [HELP] Getting num from const depending on condition - easy way
Reply With Quote #8

You can use do while
__________________
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
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-15-2014 , 19:14   Re: [HELP] Getting num from const depending on condition - easy way
Reply With Quote #9

Well, I've never experienced this types of looping. Will search something to learn, but I mostly can't understand nothing from the explanations found, because I can't understand the language itself, with all the termins and that official style of speach... One simple explanation will always be welcome.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
^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 #10

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
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