Buy House Command -_-
#5

Quote:
Originally Posted by nezo2001
Посмотреть сообщение
So what is the condition to break it
Read the wiki page that i posted above.

The idea of BREAK is to terminate the for loop which you are running to find what the id is of the house the player is standing at. Once the house is found in the loop, you can terminate the loop. The code would look like this below:

Код:
CMD:buyhouse(playerid, params[])
{
    for(new a; a != HouseLoad; ++a)
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[a][EntranceX], HouseInfo[a][EntranceY], HouseInfo[a][EntranceZ]))
        {
            if(HouseInfo[a][HousePrice] > GetPlayerMoney(playerid)) return SendClientMessage(playerid, COLOR_RED, "You don't have enough money!");
            new draw[200];
            format(draw,sizeof(draw),"ID: %i\nPrice %i\nOwned: Yes\nOwner: %s",PlayerName(playerid));
            new query[200];
            format(query, sizeof(query), "UPDATE houses SET owner='%s', owned='true', text='%s' WHERE id='%i'", PlayerName(playerid), draw, HouseInfo[a][HouseID]);
            mysql_query(1, query);
            Update3DTextLabelText(HouseLabel, COLOR_GREEN, HouseInfo[a][HouseText]);
            GivePlayerMoney(playerid, -HouseInfo[a][HousePrice]);
            PlayerInfo[playerid][pHouseID] = HouseInfo[a][HouseID];
            SendClientMessage(playerid, COLOR_GREEN, "You've bought this house successfully!");
            break; // terminates the loop as we are finished searching for a house to buy
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "You are not near any house");
        }
    }
    return 1;
}
Reply


Messages In This Thread
Buy House Command -_- - by nezo2001 - 17.06.2015, 11:05
Re: Buy House Command -_- - by Darrenr - 17.06.2015, 11:18
Re: Buy House Command -_- - by Darrenr - 17.06.2015, 11:22
Re: Buy House Command -_- - by nezo2001 - 17.06.2015, 11:26
Re: Buy House Command -_- - by Darrenr - 17.06.2015, 11:31
Re: Buy House Command -_- - by nezo2001 - 17.06.2015, 11:46
Re: Buy House Command -_- - by Konstantinos - 17.06.2015, 11:49
Re: Buy House Command -_- - by Darrenr - 17.06.2015, 11:50
Re: Buy House Command -_- - by nezo2001 - 17.06.2015, 11:55

Forum Jump:


Users browsing this thread: 2 Guest(s)