Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CMD:buyhouse(playerid, params[])
- {
- new moneys, newmoneys, string[256];
- for(new x = 0; x < MAX_HOUSES; x++)
- {
- if(IsPlayerInRangeOfPoint(2.0, playerid, HouseInfo[x][hExteriorPos][0], HouseInfo[x][hExteriorPos][1], HouseInfo[x][hExteriorPos][2]))
- {
- if(PlayerInfo[playerid][pLevel] < 5) return SCM(playerid, COLOR_GREY, "Ai nevoie de level 5 pentru a putea cumpara o casa.");
- if(PlayerInfo[playerid][pHouseKey] != 0) return SCM(playerid, COLOR_GREY, "Nu poti detine mai mult de o casa.");
- if(HouseInfo[x][hPrice] == 0) SCM(playerid, COLOR_GREY, "Aceasta casa nu este de vanzare.");
- if(PlayerInfo[playerid][pCash] >= HouseInfo[x][hPrice]) return SCM(playerid, COLOR_GREY, "Nu ai suma necesara pentru a cumpara aceasta casa.");
- id = playerid(HouseInfo[x][hOwner]);
- if(id != INVALID_PLAYER_ID) {
- PlayerInfo[id][pHouseKey] = 0;
- PlayerInfo[id][pBankMoney] += HouseInfo[x][hPrice];
- format(string, sizeof(string), "* %s ti-a cumparat casa pentru {19CF2E}$%s{239931}. Banii au fost transferati in contul tau bancar.", GetName(playerid), FormatNumber(HouseInfo[x][hPrice]));
- SCM(id, 0x239931FF, string);
- }
- else {
- mysql_format(handle, szQuery, sizeof(szQuery), "SELECT * FROM `accounts` WHERE `ID` = '%d'", HouseInfo[x][hOwner]);
- new Cache: result = mysql_query(handle, szQuery);
- if(cache_get_row_count() != 0) {
- cache_get_field_content(0, "BankMoney", string); moneys = strval(string);
- newmoneys = moneys + HouseInfo[x][hPrice];
- }
- cache_delete(result);
- mysql_format(handle, szQuery, sizeof(szQuery), "UPDATE `accounts` SET `BankMoney` = '%d', `HouseKey` = '0' WHERE `ID` = '%d'", newmoneys, HouseInfo[x][hOwner]);
- mysql_tquery(handle, szQuery);
- }
- PlayerInfo[playerid][pCash] -= HouseInfo[x][hPrice];
- PlayerInfo[playerid][pHouseKey] = x;
- mysql_format(handle, szQuery, sizeof(szQuery), "UPDATE `accounts` SET `HouseKey` = '%d' WHERE `ID` = '%d'", PlayerInfo[playerid][pHouseKey], GetName(playerid));
- mysql_tquery(handle, szQuery);
- DestroyDynamicPickup(HouseInfo[x][hPickupID]);
- HouseInfo[x][hPickupID] = CreateDynamicPickup(1272, 23, HouseInfo[x][hExteriorPos][0], HouseInfo[x][hExteriorPos][1], HouseInfo[x][hExteriorPos][2], 0, 0, -1, 250);
- if(!strcmp(HouseInfo[x][hOwner], "The State", true) && strlen(HouseInfo[x][hOwner]) >= 1) {
- format(string, sizeof(string), "* Felicitari! Ai cumparat aceasta casa pentru {19CF2E}$%s{239931}.", FormatNumber(HouseInfo[x][hPrice]));
- SCM(playerid, 0x239931FF, string);
- }
- else {
- format(string, sizeof(string), "* Felicitari! Ai cumparat casa lui %s pentru {19CF2E}$%s{239931}.", HouseInfo[x][hOwner], FormatNumber(HouseInfo[x][hPrice]));
- SCM(playerid, 0x239931FF, string);
- }
- PlayerInfo[playerid][pRentedHouse] = 0;
- HouseInfo[x][hPrice] = 0;
- HouseInfo[x][hOwner] = GetName(playerid);
- labelHouse(x);
- mysql_format(handle, szQuery, sizeof(szQuery), "UPDATE houses SET Owner = '%e', Price = '0' WHERE ID = '%d'", HouseInfo[x][hOwner], x);
- mysql_tquery(handle, szQuery);
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement