AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Getting num from const depending on condition - easy way (https://forums.alliedmods.net/showthread.php?t=242205)

Flick3rR 06-15-2014 16:45

[HELP] Getting num from const depending on condition - easy way
 
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 


fysiks 06-15-2014 16:51

Re: [HELP] Getting num from const depending on condition - easy way
 
A loop is the only alternative that I can think of.

Flick3rR 06-15-2014 17:01

Re: [HELP] Getting num from const depending on condition - easy way
 
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).

fysiks 06-15-2014 17:04

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

Originally Posted by Flick3rR (Post 2152277)
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.

Flick3rR 06-15-2014 17:27

Re: [HELP] Getting num from const depending on condition - easy way
 
Is that correct enough? :D
PHP Code:

new num 
for(new 1sizeof Tagsi++)
{
    if(
Flag Tags[i][flag])
    {
        
num i
        
break
    }



fysiks 06-15-2014 17:30

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

Originally Posted by Flick3rR (Post 2152291)
Is that correct enough? :D

What happens when you run it?

Flick3rR 06-15-2014 17:32

Re: [HELP] Getting num from const depending on condition - easy way
 
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.

^SmileY 06-15-2014 19:00

Re: [HELP] Getting num from const depending on condition - easy way
 
You can use do while

Flick3rR 06-15-2014 19:14

Re: [HELP] Getting num from const depending on condition - easy way
 
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.

^SmileY 06-15-2014 20:40

Re: [HELP] Getting num from const depending on condition - easy way
 
Correct-me if i am wrong,

PHP Code:

new g_iCount;

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




All times are GMT -4. The time now is 21:04.

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