Problem with Houses.
#1

Hello,i've a problem with /hnext command.It shows the next available houses even if its used before,Can someone tell me what is the problem with it ?
pawn Код:
CMD:hnext(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pShopTech] == 1)
    {
        SendClientMessageEx(playerid, COLOR_RED, "* Listing next available house...");
        for(new x;x<MAX_HOUSES;x++)
        {
            if(HouseInfo[x][hOwned] == 0)
            {
                new string[128];
                format(string, sizeof(string), "%d is available to use.", x);
                SendClientMessageEx(playerid, COLOR_WHITE, string);
                break;
            }
        }
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command!");
        return 1;
    }
    return 1;
}
++ REP
Reply
#2

pawn Код:
CMD:hnext(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pShopTech] == 1)
    {
        SendClientMessageEx(playerid, COLOR_RED, "* Listing next available house...");
        for(new i = 0; i < MAX_HOUSES; i++)
        {
            if(HouseInfo[i][hOwned] == 0 && HouseInfo[i][hExteriorX] == 0.000000)
            {
                new string[128];
                format(string, sizeof(string), "%d is available to use.", i);
                SendClientMessageEx(playerid, COLOR_WHITE, string);
                break;
            }
        }
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command!");
        return 1;
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by Drago987
Посмотреть сообщение
Hello,i've a problem with /hnext command.It shows the next available houses even if its used before,Can someone tell me what is the problem with it ?
pawn Код:
CMD:hnext(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pShopTech] == 1)
    {
        SendClientMessageEx(playerid, COLOR_RED, "* Listing next available house...");
        for(new x;x<MAX_HOUSES;x++)
        {
            if(HouseInfo[x][hOwned] == 0)
            {
                new string[128];
                format(string, sizeof(string), "%d is available to use.", x);
                SendClientMessageEx(playerid, COLOR_WHITE, string);
                break;
            }
        }
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command!");
        return 1;
    }
    return 1;
}
++ REP
Your loop looks okay... nothing wrong.
if(HouseInfo[x][hOwned] == 0) - means if the house isn't owned by anyone, if there is a owner so it will count the next one non-owned.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)