18.12.2015, 07:46
PHP код:
CMD:buyfurniture(playerid,params[]) {
#pragma unused params
new fid;
if(sscanf(params,"i",fid)) return SendClientMessage(playerid,COLOR_RED,"Usage: /buyfurniture [ID]");
if(GetPlayerCash(playerid) < GetFurniturePrice(fid)) return SendClientMessage(playerid,COLOR_RED,"Not enough money");
if(AccInfo[playerid][HouseOwner] == 0) return SendClientMessage(playerid,COLOR_RED,"You dont own a house");
for(new x = 0; x < MAX_HOUSES;x++) {
if(HouseInfo[x][Owned] == 1) {
if(AccInfo[playerid][HouseOwner] == HouseInfo[x][HID]) {
HouseInfo[x][HouseFurniture] += 1;
new furnitureid = CreateDynamicObject(fid, HouseInfo[x][ExitX],HouseInfo[x][ExitY],HouseInfo[x][ExitZ], 0,0,0, HouseInfo[x][VirtualWorld],HouseInfo[x][Interior]);
FurnitureData[furnitureid][FurnitureSlot] = HouseInfo[x][HouseFurniture];
FurnitureData[furnitureid][FurnitureMaster] = x;
FurnitureData[furnitureid][FurnitureModel] = fid;
FurnitureData[furnitureid][FurnitureX] = HouseInfo[x][ExitX];
FurnitureData[furnitureid][FurnitureY] = HouseInfo[x][ExitY];
FurnitureData[furnitureid][FurnitureZ] = HouseInfo[x][ExitZ];
FurnitureData[furnitureid][FurnitureInterior] = HouseInfo[x][Interior];
FurnitureData[furnitureid][FurnitureWorld] = HouseInfo[x][VirtualWorld];
new query[512];
mysql_format(mysql, query, sizeof(query),"INSERT INTO `furniture` (`Master`,`Slot`,`Model`,`X`,`Y`,`Z`,`RX`,`RY`,`RZ`,`Interior`,`World`) VALUES ('%i','%i','%i','%f','%f','%f','%f','%f','%f','%i','%i')",\
HouseInfo[x][HID],HouseInfo[x][HouseFurniture],fid,HouseInfo[x][ExitX],HouseInfo[x][ExitY],HouseInfo[x][ExitZ],0.0,0.0,0.0,HouseInfo[x][Interior],HouseInfo[x][VirtualWorld]);
mysql_tquery(mysql, query, "OnFurnitureCreation", "i", furnitureid);
print(query);
}
}
}
return true;
}