Going Crazy ^^
#1

Hello, i got an extremly annoying loose idention warning. It dosent matter where i move it. It still stays there.


This is the code

pawn Код:
if(strcmp(cmd, "/sellhouse", true) == 0) - Loose indention here
    {
        for(new i; i<MAX_HOUSES; i++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][PickupX], HouseInfo[i][PickupY], HouseInfo[i][PickupZ]))
            {
                new Pname[24]; GetPlayerName(playerid, Pname, 24);
                if(strcmp(Pname, HouseInfo[i][HouseOwner])) return SendClientMessage(playerid, 0xF60000AA, "You don't own this house!");
                GivePlayerMoney(playerid, HouseInfo[i][HouseSell]);
                GameTextForPlayer(playerid, "~r~House Sold!", 2000, 3);
                HouseInfo[i][Owned] = 0;
                format(HouseInfo[i][HouseOwner], 24, "0943jt3u9*egjlfd");
                dini_Unset("Owners.ini", HouseInfo[i][HouseNames]);
                return 1;
            }
        }
        SendClientMessage(playerid, 0xF60000AA, "You are not close enough to a house");
        return 1;
    }
    return 0;
}
Код:
(1181) : warning 217: loose indentation
The code is marked with - loose indention so you can see.

I also got another warning.

Код:
(1178) : warning 225: unreachable code
pawn Код:
if(strcmp(cmd, "/buyhouse", true) == 0)
    {
        for(new i; i<MAX_HOUSES; i++)
        {
            if(!IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][PickupX], HouseInfo[i][PickupY], HouseInfo[i][PickupZ])) continue;
            {
                new Pname[24]; GetPlayerName(playerid, Pname, 24);
                for(new S; S<MAX_HOUSES; S++)
                {
                    if(!strcmp(dini_Get("Owned.ini", HouseInfo[S][HouseNames]), Pname)) return SendClientMessage(playerid, 0xF60000AA, "You already have a house!");
                }
                if(GetPlayerMoney(playerid) < HouseInfo[i][HouseCost]) return SendClientMessage(playerid, 0xF60000AA, "You don't have enough money to buy this house");
                if(HouseInfo[i][Owned] == 1) return SendClientMessage(playerid, 0xF60000AA, "This house is already owned!");
                GivePlayerMoney(playerid, - HouseInfo[i][HouseCost]);
                GameTextForPlayer(playerid, "~r~House Purchased!", 2000, 3);
                HouseInfo[i][Owned] = 1;
                GetPlayerName(playerid, Pname, 24);
                format(HouseInfo[i][HouseOwner], 24, "%s", Pname);
                dini_Set("Owners.ini", HouseInfo[i][HouseNames], Pname);
                return 1;
            }
            SendClientMessage(playerid, 0xF60000AA, "You are not close enough to a house"); - Unreachable
            return 1;
            }
It is annoying ^^ No matter what i do, the warnings is still there.

How can i fix this ^_^?

Thanks,Alex
Reply
#2

Well, for a temporary fix, you can use '#pragma tabsize 0' under includes but I don`t recommend using it, just till you find out where`s the loose indentation problem.

Well, the problem is your command line. Show us a bit more of your "OnPlayerCommandText" function ( Or w/e it`s called, I don`t use it ).
Reply
#3

You first are using too many return 1 codes. Secondly you are not using a 'else' or 'else if' statement (Code #2), and yes, you are blind to not notice.
pawn Код:
if(strcmp(cmd, "/buyhouse", true) == 0)
{
    for(new i; i<MAX_HOUSES; i++)
    {
        if(!IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][PickupX], HouseInfo[i][PickupY], HouseInfo[i][PickupZ])) continue;
        {
            new Pname[24]; GetPlayerName(playerid, Pname, 24);
            for(new S; S<MAX_HOUSES; S++)
            {
                if(!strcmp(dini_Get("Owned.ini", HouseInfo[S][HouseNames]), Pname)) return SendClientMessage(playerid, 0xF60000AA, "You already have a house!");
            }
            if(GetPlayerMoney(playerid) < HouseInfo[i][HouseCost]) return SendClientMessage(playerid, 0xF60000AA, "You don't have enough money to buy this house");
            if(HouseInfo[i][Owned] == 1) return SendClientMessage(playerid, 0xF60000AA, "This house is already owned!");
            GivePlayerMoney(playerid, - HouseInfo[i][HouseCost]);
            GameTextForPlayer(playerid, "~r~House Purchased!", 2000, 3);
            HouseInfo[i][Owned] = 1;
            GetPlayerName(playerid, Pname, 24);
            format(HouseInfo[i][HouseOwner], 24, "%s", Pname);
            dini_Set("Owners.ini", HouseInfo[i][HouseNames], Pname);
        }
        else SendClientMessage(playerid, 0xF60000AA, "You are not close enough to a house");
    }
    return 1;
}
pawn Код:
if(strcmp(cmd, "/sellhouse", true) == 0)
{
    for(new i; i<MAX_HOUSES; i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][PickupX], HouseInfo[i][PickupY], HouseInfo[i][PickupZ]))
        {
            new Pname[24]; GetPlayerName(playerid, Pname, 24);
            if(strcmp(Pname, HouseInfo[i][HouseOwner])) return SendClientMessage(playerid, 0xF60000AA, "You don't own this house!");
            GivePlayerMoney(playerid, HouseInfo[i][HouseSell]);
            GameTextForPlayer(playerid, "~r~House Sold!", 2000, 3);
            HouseInfo[i][Owned] = 0;
            format(HouseInfo[i][HouseOwner], 24, "0943jt3u9*egjlfd");
            dini_Unset("Owners.ini", HouseInfo[i][HouseNames]);
        }
        else SendClientMessage(playerid, 0xF60000AA, "You are not close enough to a house");
    }
    return 0;
}
Reply
#4

That solves the loose indention problem. But not the unreachable code problem
Reply
#5

Quote:
Originally Posted by AlexzzPro
Посмотреть сообщение
That solves the loose indention problem. But not the unreachable code problem
What I suggest you to do is read my post and remove #pragma tabsize 0.At the end your code will be harder to read.
Reply
#6

Quote:
Originally Posted by admantis
Посмотреть сообщение
You first are using too many return 1 codes. Secondly you are not using a 'else' or 'else if' statement (Code #2), and yes, you are blind to not notice.
pawn Код:
if(strcmp(cmd, "/buyhouse", true) == 0)
{
    for(new i; i<MAX_HOUSES; i++)
    {
        if(!IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][PickupX], HouseInfo[i][PickupY], HouseInfo[i][PickupZ])) continue;
        {
            new Pname[24]; GetPlayerName(playerid, Pname, 24);
            for(new S; S<MAX_HOUSES; S++)
            {
                if(!strcmp(dini_Get("Owned.ini", HouseInfo[S][HouseNames]), Pname)) return SendClientMessage(playerid, 0xF60000AA, "You already have a house!");
            }
            if(GetPlayerMoney(playerid) < HouseInfo[i][HouseCost]) return SendClientMessage(playerid, 0xF60000AA, "You don't have enough money to buy this house");
            if(HouseInfo[i][Owned] == 1) return SendClientMessage(playerid, 0xF60000AA, "This house is already owned!");
            GivePlayerMoney(playerid, - HouseInfo[i][HouseCost]);
            GameTextForPlayer(playerid, "~r~House Purchased!", 2000, 3);
            HouseInfo[i][Owned] = 1;
            GetPlayerName(playerid, Pname, 24);
            format(HouseInfo[i][HouseOwner], 24, "%s", Pname);
            dini_Set("Owners.ini", HouseInfo[i][HouseNames], Pname);
        }
        else SendClientMessage(playerid, 0xF60000AA, "You are not close enough to a house");
    }
    return 1;
}
pawn Код:
if(strcmp(cmd, "/sellhouse", true) == 0)
{
    for(new i; i<MAX_HOUSES; i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][PickupX], HouseInfo[i][PickupY], HouseInfo[i][PickupZ]))
        {
            new Pname[24]; GetPlayerName(playerid, Pname, 24);
            if(strcmp(Pname, HouseInfo[i][HouseOwner])) return SendClientMessage(playerid, 0xF60000AA, "You don't own this house!");
            GivePlayerMoney(playerid, HouseInfo[i][HouseSell]);
            GameTextForPlayer(playerid, "~r~House Sold!", 2000, 3);
            HouseInfo[i][Owned] = 0;
            format(HouseInfo[i][HouseOwner], 24, "0943jt3u9*egjlfd");
            dini_Unset("Owners.ini", HouseInfo[i][HouseNames]);
        }
        else SendClientMessage(playerid, 0xF60000AA, "You are not close enough to a house");
    }
    return 0;
}
Код:
invalid expression, assumed zero
on code

pawn Код:
else SendClientMessage(playerid, COLOR_RED, "You are not close enough to a house");
on the buyhouse command

I am using this tutorial to make a house system
http://forum.sa-mp.com/showthread.ph...highlight=news
Reply
#7

Does it show error too in sellhouse command?
Reply
#8

No, that one works fine
Reply
#9

Quote:
Originally Posted by AlexzzPro
Посмотреть сообщение
No, that one works fine
pawn Код:
if(strcmp(cmd, "/buyhouse", true) == 0)
{
    for(new i; i<MAX_HOUSES; i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][PickupX], HouseInfo[i][PickupY], HouseInfo[i][PickupZ]))
        {
            new Pname[24]; GetPlayerName(playerid, Pname, 24);
            for(new S; S<MAX_HOUSES; S++)
            {
                if(!strcmp(dini_Get("Owned.ini", HouseInfo[S][HouseNames]), Pname)) return SendClientMessage(playerid, 0xF60000AA, "You already have a house!");
            }
            if(GetPlayerMoney(playerid) < HouseInfo[i][HouseCost]) return SendClientMessage(playerid, 0xF60000AA, "You don't have enough money to buy this house");
            if(HouseInfo[i][Owned] == 1) return SendClientMessage(playerid, 0xF60000AA, "This house is already owned!");
            GivePlayerMoney(playerid, - HouseInfo[i][HouseCost]);
            GameTextForPlayer(playerid, "~r~House Purchased!", 2000, 3);
            HouseInfo[i][Owned] = 1;
            GetPlayerName(playerid, Pname, 24);
            format(HouseInfo[i][HouseOwner], 24, "%s", Pname);
            dini_Set("Owners.ini", HouseInfo[i][HouseNames], Pname);
        }
        else SendClientMessage(playerid, 0xF60000AA, "You are not close enough to a house");
    }
    return 0;
}
Reply
#10

Quote:
Originally Posted by admantis
Посмотреть сообщение
pawn Код:
if(strcmp(cmd, "/buyhouse", true) == 0)
{
    for(new i; i<MAX_HOUSES; i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][PickupX], HouseInfo[i][PickupY], HouseInfo[i][PickupZ]))
        {
            new Pname[24]; GetPlayerName(playerid, Pname, 24);
            for(new S; S<MAX_HOUSES; S++)
            {
                if(!strcmp(dini_Get("Owned.ini", HouseInfo[S][HouseNames]), Pname)) return SendClientMessage(playerid, 0xF60000AA, "You already have a house!");
            }
            if(GetPlayerMoney(playerid) < HouseInfo[i][HouseCost]) return SendClientMessage(playerid, 0xF60000AA, "You don't have enough money to buy this house");
            if(HouseInfo[i][Owned] == 1) return SendClientMessage(playerid, 0xF60000AA, "This house is already owned!");
            GivePlayerMoney(playerid, - HouseInfo[i][HouseCost]);
            GameTextForPlayer(playerid, "~r~House Purchased!", 2000, 3);
            HouseInfo[i][Owned] = 1;
            GetPlayerName(playerid, Pname, 24);
            format(HouseInfo[i][HouseOwner], 24, "%s", Pname);
            dini_Set("Owners.ini", HouseInfo[i][HouseNames], Pname);
        }
        else SendClientMessage(playerid, 0xF60000AA, "You are not close enough to a house");
    }
    return 0;
}
That one works Thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)