AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to avoid the "loose indentation"? (https://forums.alliedmods.net/showthread.php?t=146866)

keyblade 01-02-2011 10:02

How to avoid the "loose indentation"?
 
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

Arkshine 01-02-2011 10:12

Re: How to avoid the "loose indentation"?
 
When you indent your code, either you use Tabs or spaces but not both at the same time.

keyblade 01-02-2011 10:22

Re: How to avoid the "loose indentation"?
 
I always use spaces but it still warn me...

Arkshine 01-02-2011 10:26

Re: How to avoid the "loose indentation"?
 
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!")
            } 
        }


rhelgeby 01-02-2011 10:31

Re: How to avoid the "loose indentation"?
 
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.

keyblade 01-02-2011 10:34

Re: How to avoid the "loose indentation"?
 
Thank you very much!

no WARNINGs any more~~

I will use this writing style.


All times are GMT -4. The time now is 01:59.

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