03.12.2015, 21:59
Hello mates so i have a problem
I had created 2 houses
I can buy the first correctly
but when i go at the second it says that this house is already bought whats could be the problem?
here is my buyhouse command
and here is my gethouse id function
I had created 2 houses
I can buy the first correctly
but when i go at the second it says that this house is already bought whats could be the problem?
here is my buyhouse command
PHP код:
CMD:buyhouse(playerid,params[])
{
new hid = GetHouseID(playerid);
new price;
HouseInfo[hid][HPrice] = price;
if(GetPlayerMoney(playerid) < price) return SendClientMessage(playerid, -1, ""COL_RED"SERVER"COL_WHITE": You don't have so much money to buy the house");
if(HouseInfo[hid][HOwned] == 1) return SendClientMessage(playerid,-1,""COL_RED"SERVER"COL_WHITE"You can't buy this house because it is already bought!");
if(HouseInfo[hid][HOwnerID] == pinfo[playerid][ID]) return SendClientMessage(playerid, -1, ""COL_RED"You can't buy your own house!");
if(!IsPlayerNearHouse(playerid)) return SendClientMessage(playerid, -1, ""COL_RED"SERVER"COL_WHITE"You can't buy a house if you are not near it!");
ShowPlayerDialog(playerid,DIALOG_BUYHOUSE,DIALOG_STYLE_INPUT,"BUY A HOUSE",""COL_RED"You want to buy a house! Since you can afford it please insert HouseName you want!","OK","Cancel");
return 1;
}
PHP код:
stock GetHouseID(playerid)
{
for(new i=0; i<MAX_HOUSES; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 1, HouseInfo[i][XExit], HouseInfo[i][YExit], HouseInfo[i][ZExit]))
{
return i;
}
else if(IsPlayerInRangeOfPoint(playerid, 1, HouseInfo[i][XEnt], HouseInfo[i][YEnt], HouseInfo[i][ZEnt]))
{
return i;
}
}
return INVALID_HOUSE_ID;
}