There's your problem. You're using returns in there, when a return is called the function will stop executing. So you need to re-structure your code more logically, for example:
pawn Код:
COMMAND:buy(playerid, params[])
{
for(new i = 0; i < MAX_HOUSES; i++)
{
printf("MAX_HOUSES: %d", i);
if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][PickupX], HouseInfo[i][PickupY], HouseInfo[i][PickupZ]))
{
if(strcmp(dini_Get("Owned.ini", HouseInfo[i][HouseNames]), PlayerName(playerid)))
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;
format(HouseInfo[i][HouseOwner], 24, PlayerName(playerid));
return 1;
}
}
SendClientMessage(playerid, 0xF60000AA, "You are not close enough to a house");
return 1;
}
Originally it would've only worked for the first house provided you were close enough to it, but when you weren't close enough to it, it returns the SendClientMessage return value and then the execution stopped.
This way it will go through all houses until one is actually found or if one is not found, send a message to the player informing him that the he is not near a house.