Raised This Month: $32 Target: $400
 8% 

loose indentation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GlobalPlague
Senior Member
Join Date: Feb 2016
Location: Pluto
Old 11-23-2017 , 07:52   loose indentation
Reply With Quote #1

Hi. This is the code:

Code:
    // Add ability health to Zombies
    if(is_user_alive(id) && zp_get_user_zombie(id) || get_pcvar_num(pcv_darkness_zombie_ability)) {
        set_user_health(id, get_user_health(id)+get_pcvar_num(pcv_darkness_give_health))
    }
}
This is the error:

dark.sma(223) : warning 217: loose indentation

I just can't see how to fix this error...

It's about zombie server.

I will be very thankful if I get help.
GlobalPlague is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 11-23-2017 , 08:01   Re: loose indentation
Reply With Quote #2

By indenting your code properly.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 11-23-2017 , 08:09   Re: loose indentation
Reply With Quote #3

It's not error ,it's a warning that tells you that code is not indented properly, it doesn't affect the functionality of your plugin.
Anyway if you want to hide that warning then add this line to your plugin:

#pragma tabsize 0

Last edited by siriusmd99; 11-23-2017 at 08:10.
siriusmd99 is offline
TheWhitesmith
Senior Member
Join Date: Oct 2017
Location: Morocco :c
Old 11-23-2017 , 12:31   Re: loose indentation
Reply With Quote #4

CTRL+I
TheWhitesmith is offline
GlobalPlague
Senior Member
Join Date: Feb 2016
Location: Pluto
Old 11-23-2017 , 12:34   Re: loose indentation
Reply With Quote #5

OciXCrom, thanks. A few days ago I used the same function, but then it destroyed the code and gave too many errors. Now I used it again, and this time it worked and the problem is solved.

siriusmd99, thanks but I prefer to fix the problems, not to hide them

thanks to both of you
GlobalPlague is offline
GlobalPlague
Senior Member
Join Date: Feb 2016
Location: Pluto
Old 11-23-2017 , 12:34   Re: loose indentation
Reply With Quote #6

Quote:
Originally Posted by TheWhitesmith View Post
CTRL+I
thanks
already done
GlobalPlague is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-23-2017 , 23:53   Re: loose indentation
Reply With Quote #7

Quote:
Originally Posted by TheWhitesmith View Post
CTRL+I
You need to clarify what that even means because that is not true in many source code editors.

@GlobalPlague, The proper way to prevent the indentation warning is to learn to properly indent your code as you write it. If you make this a habit, you'll never need a function to do it for you.
__________________

Last edited by fysiks; 11-23-2017 at 23:54.
fysiks is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 11-24-2017 , 02:46   Re: loose indentation
Reply With Quote #8

here's a more universal way to do it:
select the "area" or function with loose indentation
hold left shift, press tab until all tabs / spaces are gone from beginnings of line
now add the tabs back where needed (remember you can select multiple lines and press tab to move them all together)
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 11-24-2017 , 03:35   Re: loose indentation
Reply With Quote #9

You are not fixing any problem by indenting code, you are just arranging code how Compiler wants, not how you want.
For instance your code is OK but compiler gives warning because he doesn't understand spaces and you must use tabs, but in reality the blocks are arranged properly visually for you but not physically for Compiler. You are not fixing anything except that senseless message from Compiler. It would be better if developers turned off that warning by default so there won't be like hundred of threads "my plugin is getting error". I think everyone is sick of these questions over years.
siriusmd99 is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 11-24-2017 , 06:39   Re: loose indentation
Reply With Quote #10

Quote:
Originally Posted by siriusmd99 View Post
You are not fixing any problem by indenting code, you are just arranging code how Compiler wants, not how you want.
For instance your code is OK but compiler gives warning because he doesn't understand spaces and you must use tabs, but in reality the blocks are arranged properly visually for you but not physically for Compiler. You are not fixing anything except that senseless message from Compiler. It would be better if developers turned off that warning by default so there won't be like hundred of threads "my plugin is getting error". I think everyone is sick of these questions over years.
It's not senseless, here's an explanation from the pawn features page
Quote:
Forgetting to encapsulate multiple statements (of an "if" or a loop) in a compound block - pawn is a free format language, but it warns if the indentation level of statements in the same block changes. This catches most instances of this kind of error.

besides, if you see this warning then it's a sign that your code is ugly (from either a human or editor's point of view) and in both cases it's better to just fix the issue and not have it bite you in the ass later
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever 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 10:41.


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