Raised This Month: $ Target: $400
 0% 

How to avoid the "loose indentation"?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
keyblade
Member
Join Date: Nov 2010
Location: China
Old 01-02-2011 , 10:02   How to avoid the "loose indentation"?
Reply With Quote #1

Here is my codes which are warned.

PHP Code:
    switch(key)
    {
        case 
1:
        if (
pweapon == CSW_M4A1)
    {
        
client_print(idprint_chat"[Ice-Action] aaa!")
    } else if (
pmoney >= 3100)
    {
        
cs_set_user_money(idpmoney 31001)
        
give_item(id"weapon_m4a1")
    } else if (
pmoney << 3100)
    { 
        
client_print(idprint_chat"[Ice-Action] bbb!")
    } 
It warned at this line:
PHP Code:
    } else if (pmoney >= 3100
I know WARNINGs do not affect compiling but I don't want to get these.

Thx
keyblade is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-02-2011 , 10:12   Re: How to avoid the "loose indentation"?
Reply With Quote #2

When you indent your code, either you use Tabs or spaces but not both at the same time.
__________________
Arkshine is offline
keyblade
Member
Join Date: Nov 2010
Location: China
Old 01-02-2011 , 10:22   Re: How to avoid the "loose indentation"?
Reply With Quote #3

I always use spaces but it still warn me...
keyblade is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-02-2011 , 10:26   Re: How to avoid the "loose indentation"?
Reply With Quote #4

Is that hard to indent properly ?

Code:
    switch(key)
    {
        case 1:
        {
            if ( pweapon == CSW_M4A1 )
            {
                client_print(id, print_chat, "[Ice-Action] aaa!")
            } 
            else if ( pmoney >= 3100 )
            {
                cs_set_user_money(id, pmoney - 3100, 1)
                give_item(id, "weapon_m4a1")
            } 
            else if ( pmoney < 3100 )
            { 
                client_print(id, print_chat, "[Ice-Action] bbb!")
            }  
        }
__________________
Arkshine is offline
rhelgeby
Veteran Member
Join Date: Oct 2008
Location: 0x4E6F72776179
Old 01-02-2011 , 10:31   Re: How to avoid the "loose indentation"?
Reply With Quote #5

With proper indentation it will also be easier to see your missing braces (assuming you showed us a complete code block). Though it should allow "else if" on the same line as the ending brace.
__________________
Richard Helgeby

Zombie:Reloaded | PawnUnit | Object Library
(Please don't send private messages for support, they will be ignored. Use the forum.)
rhelgeby is offline
Send a message via MSN to rhelgeby
keyblade
Member
Join Date: Nov 2010
Location: China
Old 01-02-2011 , 10:34   Re: How to avoid the "loose indentation"?
Reply With Quote #6

Thank you very much!

no WARNINGs any more~~

I will use this writing style.
keyblade 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 01:59.


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