warning 217: loose indentation
#1

what's wrong with this code??
Код:
d:\SAMPSERVER\samp03\gamemodes\a.pwn(98547) : warning 217: loose indentation
d:\SAMPSERVER\samp03\gamemodes\a.pwn(98549) : warning 217: loose indentation
d:\SAMPSERVER\samp03\gamemodes\a.pwn(98549) : warning 217: loose indentation
d:\SAMPSERVER\samp03\gamemodes\a.pwn(98551) : warning 217: loose indentation
d:\SAMPSERVER\samp03\gamemodes\a.pwn(98551) : warning 217: loose indentation
d:\SAMPSERVER\samp03\gamemodes\a.pwn(98553) : warning 217: loose indentation
d:\SAMPSERVER\samp03\gamemodes\a.pwn(98553) : warning 217: loose indentation
d:\SAMPSERVER\samp03\gamemodes\a.pwn(98555) : warning 217: loose indentation
d:\SAMPSERVER\samp03\gamemodes\a.pwn(98555) : warning 217: loose indentation
d:\SAMPSERVER\samp03\gamemodes\a.pwn(98557) : warning 217: loose indentation
d:\SAMPSERVER\samp03\gamemodes\a.pwn(98557) : warning 217: loose indentation
d:\SAMPSERVER\samp03\gamemodes\a.pwn(98559) : warning 217: loose indentation
d:\SAMPSERVER\samp03\gamemodes\a.pwn(98559) : warning 217: loose indentation
d:\SAMPSERVER\samp03\gamemodes\a.pwn(98561) : warning 217: loose indentation
d:\SAMPSERVER\samp03\gamemodes\a.pwn(98561) : warning 217: loose indentation
PHP код:
if( dialogid == 15786) { if(strval(inputtext) < 1) { SendClientMessageEx(playerid,COLOR_WHITE,"EROR: Tidak boleh menggunakan - .")
(
LINE 98547)if(response) { BizzInfo[PlayerInfo[playerid][pPBiskey]][bProductPrice1] = strval(inputtext); } return 1; }
if( 
dialogid == 15787) { if(strval(inputtext) < 1) { SendClientMessageEx(playerid,COLOR_WHITE,"EROR: Tidak boleh menggunakan - .")
(
LINE 98549)if(response) { BizzInfo[PlayerInfo[playerid][pPBiskey]][bProductPrice2] = strval(inputtext); } return 1; }
if( 
dialogid == 15788) { if(strval(inputtext) < 1) { SendClientMessageEx(playerid,COLOR_WHITE,"EROR: Tidak boleh menggunakan - .")
(
LINE 98551)if(response) { BizzInfo[PlayerInfo[playerid][pPBiskey]][bProductPrice3] = strval(inputtext); } return 1; }
if( 
dialogid == 15789) { if(strval(inputtext) < 1) { SendClientMessageEx(playerid,COLOR_WHITE,"EROR: Tidak boleh menggunakan - .")
(
LINE 98553)if(response) { BizzInfo[PlayerInfo[playerid][pPBiskey]][bProductPrice4] = strval(inputtext); } return 1; }
if( 
dialogid == 15790) { if(strval(inputtext) < 1) { SendClientMessageEx(playerid,COLOR_WHITE,"EROR: Tidak boleh menggunakan - .")
(
LINE 98555)if(response) { BizzInfo[PlayerInfo[playerid][pPBiskey]][bProductPrice5] = strval(inputtext); } return 1; }
if( 
dialogid == 15791) { if(strval(inputtext) < 1) { SendClientMessageEx(playerid,COLOR_WHITE,"EROR: Tidak boleh menggunakan - .")
(
LINE 98557)if(response) { BizzInfo[PlayerInfo[playerid][pPBiskey]][bProductPrice6] = strval(inputtext); } return 1; }
if( 
dialogid == 15792) { if(strval(inputtext) < 1) { SendClientMessageEx(playerid,COLOR_WHITE,"EROR: Tidak boleh menggunakan - .")
(
LINE 98559)if(response) { BizzInfo[PlayerInfo[playerid][pPBiskey]][bProductPrice7] = strval(inputtext); } return 1; }
if( 
dialogid == 15793) { if(strval(inputtext) < 1) { SendClientMessageEx(playerid,COLOR_WHITE,"EROR: Tidak boleh menggunakan - .")
(
LINE 98561)if(response) { BizzInfo[PlayerInfo[playerid][pPBiskey]][bProductPrice8] = strval(inputtext); } return 1; } 
Reply
#2

The problem with the code above is readability. If you indent your code, you will notice that you never close bracket for each dialog so your current code indented is like this:
pawn Код:
if( dialogid == 15786)
{
    if( dialogid == 15787)
    {
        if( dialogid == 15788)
        {
            ...
If I were you, I would get rid of bProductPriceN constant in enumerator and it would be like this:
pawn Код:
new gBizz_ProductPrice[MAX_BIZZ][8];
pawn Код:
if (15786 <= dialogid <= 15793)
{
    if (response)
    {
        // check if value of PlayerInfo[playerid][pPBiskey] is not out of bounds (0 <= value < sizeof BizzInfo)
        // before you use it in BizzInfo array
     
        new product_price = strval(inputtext);
     
        if (product_price < 1) return SendClientMessageEx(playerid, COLOR_WHITE, "EROR: Tidak boleh menggunakan - .");
     
        gBizz_ProductPrice[PlayerInfo[playerid][pPBiskey]][dialogid - 15786] = product_price;
    }
    return 1;
}
Much simpler.
Reply
#3

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
The problem with the code above is readability. If you indent your code, you will notice that you never close bracket for each dialog so your current code indented is like this:
pawn Код:
if( dialogid == 15786)
{
    if( dialogid == 15787)
    {
        if( dialogid == 15788)
        {
            ...
If I were you, I would get rid of bProductPriceN constant in enumerator and it would be like this:
pawn Код:
new gBizz_ProductPrice[MAX_BIZZ][8];
pawn Код:
if (15786 <= dialogid <= 15793)
{
    if (response)
    {
        // check if value of PlayerInfo[playerid][pPBiskey] is not out of bounds (0 <= value < sizeof BizzInfo)
        // before you use it in BizzInfo array
     
        new product_price = strval(inputtext);
     
        if (product_price < 1) return SendClientMessageEx(playerid, COLOR_WHITE, "EROR: Tidak boleh menggunakan - .");
     
        gBizz_ProductPrice[PlayerInfo[playerid][pPBiskey]][dialogid - 15786] = product_price;
    }
    return 1;
}
Much simpler.
Oohhh niceee very very much simpler!! XD lol.. thanks
Reply
#4

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
PHP код:
(15786 <= dialogid <= 15793
Is this allowed in PAWN? If it is, then THANKS, I didn't know
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)