05.07.2018, 11:01
PHP код:
CMD:buy(playerid,params[])
{
new count;
for(new i = 0; i < MAX_HOUSES;i++)//Loop threw all houses.
{
if(IsPlayerInRangeOfPoint(playerid,8.0, hInfo[i][HouseEX],hInfo[i][HouseEY], hInfo[i][HouseEZ]))
{
count++;
//if(GetPlayerMoney(playerid) < HInfo[i][Price]) return SendClientMessage(playerid,-1,"You don't have enough money");//Checking the players money, to see if he has enough to buy the house.
//GivePlayerMoney(playerid, -hInfo[i][HousePrice]);
// CHECK IF PLAYER ALREADY OWN A HOUSE
if(hInfo[i][HouseOwned] == 1) return SendClientMessage(playerid,-1,"This house is already owned");//Checking if the house is already owned.
hInfo[i][HouseOwned] = 1;//Setting the house owned var to 1.
new hName[24],string[145], query[100];//Creating the necessary vars.
GetPlayerName(playerid,hName,sizeof(hName));//Retrieving the player's name.
// WHAT IS HouseEX?? HouseID should be there.
format(query, sizeof(query), "UPDATE `houses` SET `HouseOwner` = '%s', `HouseOwned` = '1' WHERE `HouseEX` = '%f'", hName, hInfo[playerid][HouseEX]);
mysql_tquery(dbHandle, query);
format(string, 145, "{FFD700}House Title(%i): {FFFFFF}%s\n{FFD700}House Owner: {FFFFFF}%s\n {FFD700}House Price: {FFFFFF}$%d", hInfo[i][HouseID], hInfo[i][HouseTitle], hInfo[i][HousePrice]);
Update3DTextLabelText(hInfo[i][HouseDetails],0xFF0000FF,string);//Updating the label with a red color
SendClientMessage(playerid, -1, "House bought.");
}
return 1;
}
if(!count) return SendClientMessage(playerid, -1, "You aren't near a house!");
return 1;
}