SA-MP Forums Archive
Problem with Houses. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with Houses. (/showthread.php?tid=496976)



Problem with Houses. - Drago987 - 24.02.2014

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


Re: Problem with Houses. - DexterC - 24.02.2014

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;
}



Re: Problem with Houses. - Lidor124 - 24.02.2014

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.