14.12.2015, 19:36
Alright so now the only problem is left for me to solve is purchasing houses.
Lets say you are standing at house ID:14, you purchase it, it will purchase ID before it. Aka it will purchase house ID 13 instead
Lets say you are standing at house ID:14, you purchase it, it will purchase ID before it. Aka it will purchase house ID 13 instead
PHP код:
CMD:buyhouse(playerid,params[]) {
#pragma unused params
new Float:MyPos[3],string[128], query[128];
GetPlayerPos(playerid,MyPos[0],MyPos[1],MyPos[2]);
for(new x = 1; x < MAX_HOUSES;x++) {
if(IsPlayerInRangeOfPoint(playerid,2,HouseInfo[x][EnterX],HouseInfo[x][EnterY],HouseInfo[x][EnterZ])){
if(HouseInfo[x][Owned] == 0) {
if(AccInfo[playerid][HouseOwner] == 0) {
if(GetPlayerCash(playerid) < HouseInfo[x][HousePrice]) return SendClientMessage(playerid,COLOR_RED,"You dont have enough money");
HouseInfo[x][Owned] = 1;
HouseInfo[x][Locked] = 0;
GivePlayerCash(playerid,-HouseInfo[x][HousePrice]);
AccInfo[playerid][HouseOwner] = HouseInfo[x][HID];
format(string,sizeof(string),"You have purchased a house, server ID: %i for %i$",HouseInfo[x][HID],HouseInfo[x][HousePrice]);
SendClientMessage(playerid,COLOR_GREEN,string);
HouseInfo[x][Owned] = 1;
HouseInfo[x][HID] = x;
mysql_format(mysql, query, sizeof(query), "UPDATE `houses` SET `Owned`=%i,`Owner`='%e',`MasterID`=%i WHERE `ID`=%i",1,GetName(playerid),AccInfo[playerid][ID],HouseInfo[x][HID]);
mysql_tquery(mysql, query);
DestroyPickup(HouseInfo[x][HPickup]);
Delete3DTextLabel(HouseInfo[x][HouseText]);
HouseInfo[x][HPickup] = CreatePickup(1272, 1, HouseInfo[x][EnterX], HouseInfo[x][EnterY], HouseInfo[x][EnterZ]);
format(string,sizeof(string),"House Name: %s\nHouse Owner: %s\nHouse ID: %i",HouseInfo[x][HouseName],GetRoleplayName(playerid),HouseInfo[x][HID]);
HouseInfo[x][HouseText] = Create3DTextLabel(string, 0x008080FF, HouseInfo[x][EnterX], HouseInfo[x][EnterY], HouseInfo[x][EnterZ], 40.0, 0, 0);
GivePlayerCash(playerid,-HouseInfo[x][HousePrice]);
format(string,sizeof(string),"%s has purchased house ID: %i for %i$",GetName(playerid),HouseInfo[x][HID],HouseInfo[x][HousePrice]);
HousePurchaseLog(string);
print(query);
}
}
}
}
return true;
}