23.05.2011, 08:51
(
Последний раз редактировалось Mean; 20.06.2013 в 12:23.
)
How to fix warning 217: loose indentation
Introduction
Recently, I saw A LOT of people asking WHY do they get the warning 217, well, I always had to write examples, and I got sick of wasting my time in doing that, so now I'll just write a tutorial and post the thread link if someone asks. Why do we get warning 217?
If your code is not properly indented, your compiler will tell you. To fix the warning, all you have to do is properly indent your code.I have had problems with this in my scripting beginnings. I couldn't see some obvious errors in my code, but once I indented them, I could easily spot issues.
Good indentation is important. If you want some scripter to help you and you give him messy code, don't be surprised if he ignores you.
To indent your code, all you need to do is press the tab key few times, or only one time, depends.
After every "{" (if we open a statement), you need to go one tab forward, by the standards, and if we do "}" (if we close a statement), then we go one tab back. The default tab size in a_samp is 4 spaces (so tab is equal to 4 spaces).
So, here's an example of GOOD indentation:
pawn Код:
if( !strcmp( cmdtext, "/lol", true ) )
{
// There's a "{" so we moved 4 spaces (one tab) forward.
if( !strcmp( cmdtext[ 5 ], "rofl", true ) )
{
//ANOTHER "{" so we move 4 spaces (one tab) forward
SendClientMessage( playerid, -1, "Your parameter after the /lol command is 'rofl'." );
}
//We closed the bracket, so we go 4 spaces (one tab) back.
return 1;
}
pawn Код:
if( !strcmp( cmdtext, "/lol", true ) )
{
if( !strcmp( cmdtext[ 5 ], "rofl", true ) )
{
SendClientMessage( playerid, -1, "Your parameter after the /lol command is 'rofl'." );
}
return 1;
}
pawn Код:
if( !strcmp( cmdtext, "/lol", true ) )
{
if( !strcmp( cmdtext[ 5 ], "rofl", true ) )
{
SendClientMessage( playerid, -1, "Your parameter after the /lol command is 'rofl'." );
}
return 1;
}
That's about it.