Raised This Month: $ Target: $400
 0% 

[help]How many else can i do in case?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
2reason2kill
Senior Member
Join Date: Feb 2011
Old 06-17-2011 , 04:15   [help]How many else can i do in case?
Reply With Quote #1

How many else can i do in case or normal?
2reason2kill is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 06-17-2011 , 05:05   Re: [help]How many else can i do in case?
Reply With Quote #2

Explain what you're trying to do
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
2reason2kill
Senior Member
Join Date: Feb 2011
Old 06-17-2011 , 05:20   Re: [help]How many else can i do in case?
Reply With Quote #3

Quote:
Originally Posted by drekes View Post
Explain what you're trying to do


PHP Code:
case 1:
    {
        if(
g_bBoght[id][silver_lighet])
        {
            
ColorChat(idGREEN,"%s You Cant Buy This Item 2 Time's!",PREFIX)
        }
        else
        {
            new 
cost get_pcvar_num(silver_lighet_cost);
            
            if(
money >= cost)
            {
                
cs_set_weapon_ammo(give_item(id,"weapon_deagle")
                
g_bBoght[id][silver_lighet] = true
                cs_set_user_bpammo
(idCSW_DEAGLE1)
                
cs_set_user_money(idmoney -cost)
                
                
ColorChat(idGREEN,"%s You Just Bought a ^x04 silver Light!"PREFIX);
            }
            else
            {
                if(!
is_user_alive(id)
                {
                    
Colorchat(.....)
        }
    }

Im trying to Get how many else u can have


other example

PHP Code:
case 1:
    {
        if(
somting)
        {
            
//somting
        
}
        else
        {
            
//somting
        
}
        else
        {
            
//somting
        
}
        else
        {
            
//somting
        
}
        
    }

can i do it like that?

Last edited by 2reason2kill; 06-17-2011 at 05:23.
2reason2kill is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 06-17-2011 , 05:40   Re: [help]How many else can i do in case?
Reply With Quote #4

Code:
if( ) {     // ... } else if( ) {     // ... } else if( ) {     // ... } else {     // ... }
__________________
You can do anything you set your mind to, man.


Last edited by Devil259; 06-17-2011 at 11:37.
Devil259 is offline
2reason2kill
Senior Member
Join Date: Feb 2011
Old 06-17-2011 , 05:45   Re: [help]How many else can i do in case?
Reply With Quote #5

Quote:
Originally Posted by Devil259 View Post
Code:
if( ) { // ... } else if( ) { // ... } else if( ) { // ... } else( ) { // ... }
So the last 1 will be "else"

and the other "else if()"?
2reason2kill is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 06-17-2011 , 06:23   Re: [help]How many else can i do in case?
Reply With Quote #6

Quote:
Originally Posted by 2reason2kill View Post
So the last 1 will be "else"

and the other "else if()"?
Yes.
__________________
You can do anything you set your mind to, man.

Devil259 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-17-2011 , 10:59   Re: [help]How many else can i do in case?
Reply With Quote #7

Quote:
Originally Posted by Devil259 View Post
Code:
else {     // ... }
FTFY. The "else" does not have parenthesis.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 06-17-2011 , 11:16   Re: [help]How many else can i do in case?
Reply With Quote #8

Quote:
Originally Posted by Exolent[jNr] View Post
FTFY. The "else" does not have parenthesis.
What ?
__________________
You can do anything you set your mind to, man.

Devil259 is offline
johnally
Member
Join Date: May 2011
Location: Mauritius
Old 06-17-2011 , 11:37   Re: [help]How many else can i do in case?
Reply With Quote #9

A good replacement for if..else if..else IS case1..case2..default

But as Exolent[jNr] said else(like the default in 'case') you don't need the parenthesis!
__________________
No allowed!

johnally is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-17-2011 , 11:50   Re: [help]How many else can i do in case?
Reply With Quote #10

Quote:
Originally Posted by johnally View Post
A good replacement for if..else if..else IS case1..case2..default
That's only if you are checking a variable for multiple values.
In that case, then a switch() should be used instead of multiple if else if.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 23:30.


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