Loose indentation?
#1

Look here:
Quote:

public OnPlayerText(playerid, text[])
{
if (realchat)
{
new sendername[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, sendername, sizeof(sendername));
sendername[strfind(sendername,"_")] = ' ';
format(string, sizeof(string), "%s says: %s", sendername, text);
ProxDetector(30.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_F ADE4,COLOR_FADE5);
new lengthtime = strlen(text);
new time = lengthtime*50;
ApplyAnimation(playerid,"PED","IDLE_CHAT",4.0,0,0, 0,0,time);
return 0;
}
(LINE 19 return 1;
}

Warning:
Quote:

(19 : warning 217: loose indentation

I cannot understand - what is the problem with that? The command works, but I just don't want to warning.
Reply
#2

Show us your code on [ pawn ] [ /pawn ] tags, not quote.
O.T: Here you go.
pawn Код:
public OnPlayerText(playerid, text[])
{
    if (realchat)
    {
        new sendername[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        sendername[strfind(sendername,"_")] = ' ';
        format(string, sizeof(string), "%s says: %s", sendername, text);
        ProxDetector(30.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_F ADE4,COLOR_FADE5);
        new lengthtime = strlen(text);
        new time = lengthtime*50;
        ApplyAnimation(playerid,"PED","IDLE_CHAT",4.0,0,0, 0,0,time);
        return 0;
    }
    return 1;
}
Reply
#3

Thanks, and yeah I will add them in pawn instead from now on, but what did you edit? I mean like I cannot see anything different, but it worked.
Reply
#4

In case you are wondering what is the difference in the code, the code Necip gave you is tabbed correctly. This warning is not very important unless you want to understand the code better and make it look nicer.
Reply
#5

The code between two curly brackets (braces) should be tabbed in a level, for example:

pawn Код:
SomeFunction()
{
    if(contition)
    {
        if(some_other_condition)
        {
            // Code
        }
    }
}
It makes code easier to read and makes missing brackets easier to find (although, prevention is better than cure).
Reply
#6

Quote:
Originally Posted by Hargrave
Посмотреть сообщение
Thanks, and yeah I will add them in pawn instead from now on, but what did you edit? I mean like I cannot see anything different, but it worked.
Your "return 1;" was something like this I think.
WRONG:
pawn Код:
public OnPlayerText(playerid, text[])
{
    if (realchat)
    {
        new sendername[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        sendername[strfind(sendername,"_")] = ' ';
        format(string, sizeof(string), "%s says: %s", sendername, text);
        ProxDetector(30.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_F ADE4,COLOR_FADE5);
        new lengthtime = strlen(text);
        new time = lengthtime*50;
        ApplyAnimation(playerid,"PED","IDLE_CHAT",4.0,0,0, 0,0,time);
        return 0;
    }
return 1;
}
CORRECT:
pawn Код:
public OnPlayerText(playerid, text[])
{
    if (realchat)
    {
        new sendername[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        sendername[strfind(sendername,"_")] = ' ';
        format(string, sizeof(string), "%s says: %s", sendername, text);
        ProxDetector(30.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_F ADE4,COLOR_FADE5);
        new lengthtime = strlen(text);
        new time = lengthtime*50;
        ApplyAnimation(playerid,"PED","IDLE_CHAT",4.0,0,0, 0,0,time);
        return 0;
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)