BuyHouse -
norton2 - 04.12.2014
Please help me!
I give /buyhouse I do not buy the house buyhouse correct.
Example: I go to the house with ID: 30 and I give / buyhouse buy my house with ID: 1, normal should buy my house with ID: 30
Код HTML:
CMD:buyhouse(playerid, params[])
{
new Float:oldposx, Float:oldposy, Float:oldposz, sendername[MAX_PLAYER_NAME], query[512];
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
for(new h = 0; h < sizeof(HouseInfo); h++)
{
if(IsPlayerInRangeOfPoint(3, playerid, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]) || HouseInfo[h][hOwned] == 0)
{
if(PlayerInfo[playerid][pHouseKey] < 255) return SendClientMessage(playerid, COLOR_ERROR, "You already own a House.");
if(PlayerInfo[playerid][pCash] > HouseInfo[h][hValue])
{
PlayerInfo[playerid][pHouseKey] = h;
HouseInfo[h][hOwned] = 1;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(HouseInfo[h][hOwner], sendername, 0, strlen(sendername), 255);
GivePlayerCash(playerid, -HouseInfo[h][hValue]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, "Congratulations, on your new Purchase !");
SendClientMessage(playerid, COLOR_LIGHTBLUE, "Type /help to review the new property help section !");
mysql_format(handle, query, sizeof(query), "UPDATE `houses` SET `Owner` = '%s', `Owned` = '%i' WHERE ID = '%i'", HouseInfo[h][hOwner], HouseInfo[h][hOwned], h);
mysql_query(handle, query);
Update(playerid, pHouseKeyu);
OnPropTextdrawUpdate(1, h);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_ERROR, "You don't have enough cash to buy this House.");
}
}
}
return 1;
}
Re: BuyHouse -
xCrazyMonkey - 04.12.2014
Can you tell me what your variable "HouseInfo" means? What info is it saving?
I think your problem is in your loop, not sure though.
Re: BuyHouse -
norton2 - 04.12.2014
Код HTML:
enum hInfo
{
hID,
hOwner[100],
hDiscription[100],
Float:hEntrancex,
Float:hEntrancey,
Float:hEntrancez,
Float:hExitx,
Float:hExity,
Float:hExitz,
hValue,
hInt,
hLook,
hOwned,
hRent,
hRentabil,
hLevel,
hVw,
};
new HouseInfo[55][hInfo];
new Text3D:HouseLabel[sizeof(HouseInfo)];
new housep[sizeof(HouseInfo)];
Код HTML:
public LoadHouses()
{
new tempp[124], PropertyString[256], TotalHouses;
cache_get_data(rows, fields);
while(TotalHouses < rows)
{
cache_get_row(TotalHouses, 0, tempp), HouseInfo[TotalHouses][hID] = strval(tempp);
cache_get_row(TotalHouses, 1, tempp), format(HouseInfo[TotalHouses][hOwner], 100, tempp);
cache_get_row(TotalHouses, 2, tempp), format(HouseInfo[TotalHouses][hDiscription], 100, tempp);
cache_get_row(TotalHouses, 3, tempp), HouseInfo[TotalHouses][hEntrancex] = floatstr(tempp);
cache_get_row(TotalHouses, 4, tempp), HouseInfo[TotalHouses][hEntrancey] = floatstr(tempp);
cache_get_row(TotalHouses, 5, tempp), HouseInfo[TotalHouses][hEntrancez] = floatstr(tempp);
cache_get_row(TotalHouses, 6, tempp), HouseInfo[TotalHouses][hExitx] = floatstr(tempp);
cache_get_row(TotalHouses, 7, tempp), HouseInfo[TotalHouses][hExity] = floatstr(tempp);
cache_get_row(TotalHouses, 8, tempp), HouseInfo[TotalHouses][hExitz] = floatstr(tempp);
cache_get_row(TotalHouses, 9, tempp), HouseInfo[TotalHouses][hValue] = strval(tempp);
cache_get_row(TotalHouses, 10, tempp), HouseInfo[TotalHouses][hInt] = strval(tempp);
cache_get_row(TotalHouses, 11, tempp), HouseInfo[TotalHouses][hLook] = strval(tempp);
cache_get_row(TotalHouses, 12, tempp), HouseInfo[TotalHouses][hOwned] = strval(tempp);
cache_get_row(TotalHouses, 13, tempp), HouseInfo[TotalHouses][hRent] = strval(tempp);
cache_get_row(TotalHouses, 14, tempp), HouseInfo[TotalHouses][hRentabil] = strval(tempp);
cache_get_row(TotalHouses, 15, tempp), HouseInfo[TotalHouses][hLevel] = strval(tempp);
cache_get_row(TotalHouses, 16, tempp), HouseInfo[TotalHouses][hVw] = strval(tempp);
TotalHouses++;
}
printf("%d houses loaded",TotalHouses);
return 1;
}
Re: BuyHouse -
dusk - 04.12.2014
pawn Код:
if(IsPlayerInRangeOfPoint(3, playerid, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]) || HouseInfo[h][hOwned] == 0)
This doesn't look right. You check "if a player is near a house entrance OR the house is not owned". I think you meant AND.
pawn Код:
if(IsPlayerInRangeOfPoint(3, playerid, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]) && HouseInfo[h][hOwned] == 0)
Re: BuyHouse -
norton2 - 04.12.2014
Now command does not work at all
Re: BuyHouse -
dusk - 04.12.2014
Oh, something I missed before. See how IsPlayerInRangeOfPoint function is used. The first parameter should be playerid and the second one should be distance.
Re: BuyHouse -
norton2 - 04.12.2014
thanks very very much
+1