Raised This Month: $51 Target: $400
 12% 

blockmaker "ELSE IF" "IF" ELSE?"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
infek
Senior Member
Join Date: May 2009
Location: Behind you
Old 02-16-2010 , 01:47   blockmaker "ELSE IF" "IF" ELSE?"
Reply With Quote #1

Got my self confused dont know what i did wrong, I tryed adding Pole but got confused on this part with else, else if, if and yah..
Code:
  //if its a valid block type
  if (blockType >= 0 && blockType < gBlockMax)
  {
   if(fScale == SCALE_NORMAL) {
    entity_set_model(ent, gszBlockModels[blockType]);
   } else if(fScale == SCALE_LARGE) {
    entity_set_model(ent, gszBlockLargeModels[blockType]);
   } else  if {
    entity_set_model(ent, gszBlockSmallModels[blockType]);
   } else if {
                                entity_set_model(ent, gszBlockPoleModels[blockType]);
                        }  
  }
  else
  {
   entity_set_model(ent, gszBlockModelDefault);
  }
__________________
"Domo Arigato, Mr. Roboto!"
PM me if you want to know a secret
infek is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 02-16-2010 , 01:54   Re: blockmaker "ELSE IF" "IF" ELSE?"
Reply With Quote #2

First off, use indentation properly and use PHP Tags for highlighting.

Secondly, else if statements require a condition to work off of.
ex:
PHP Code:
// GOOD
if( cs_get_user_teamid ) == CS_TEAM_T )
{
    
// Code for T
}
else if( 
cs_get_user_teamid ) == CS_TEAM_CT )
{
    
// Code for CT
}
else
{
    
// Code for SPEC or UNASSIGNED

PHP Code:
// BAD
if( cs_get_user_teamid ) == CS_TEAM_T )
{
    
// Code for T
}
else if 
// REQUIRES CONDITION
{
    
// ???

You're not specifying the condition, therefore you aren't getting any results. Control Structures are the same in pretty much every other programming language out there.



EDIT: Most of the time, when you're in need of so many else if statements, you might want to perform a switch.
ex:
Instead of
PHP Code:
if( cs_get_user_teamid ) == CS_TEAM_T )
{
    
// Code for T
}
else if( 
cs_get_user_teamid ) == CS_TEAM_CT )
{
    
// Code for CT
}
else
{
    
// Code for SPEC or UNASSIGNED

You might want to do
PHP Code:
switch( cs_get_user_teamid ) )
{
    case 
CS_TEAM_T:
   {
        
// Code for T
    
}
    case 
CS_TEAM_CT:
    {
        
// Code for CT
    
}
    default:
    {
        
// Code for SPECTATOR or UNASSIGNED
    
}

__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT

Last edited by wrecked_; 02-16-2010 at 02:17.
wrecked_ 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 17:08.


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