Advertisement
Guest User

fdgd

a guest
Dec 4th, 2018
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. CMD:buyhouse(playerid, params[])
  2. {
  3. new moneys, newmoneys, string[256];
  4. for(new x = 0; x < MAX_HOUSES; x++)
  5. {
  6. if(IsPlayerInRangeOfPoint(2.0, playerid, HouseInfo[x][hExteriorPos][0], HouseInfo[x][hExteriorPos][1], HouseInfo[x][hExteriorPos][2]))
  7. {
  8. if(PlayerInfo[playerid][pLevel] < 5) return SCM(playerid, COLOR_GREY, "Ai nevoie de level 5 pentru a putea cumpara o casa.");
  9. if(PlayerInfo[playerid][pHouseKey] != 0) return SCM(playerid, COLOR_GREY, "Nu poti detine mai mult de o casa.");
  10. if(HouseInfo[x][hPrice] == 0) SCM(playerid, COLOR_GREY, "Aceasta casa nu este de vanzare.");
  11. if(PlayerInfo[playerid][pCash] >= HouseInfo[x][hPrice]) return SCM(playerid, COLOR_GREY, "Nu ai suma necesara pentru a cumpara aceasta casa.");
  12. id = playerid(HouseInfo[x][hOwner]);
  13. if(id != INVALID_PLAYER_ID) {
  14. PlayerInfo[id][pHouseKey] = 0;
  15. PlayerInfo[id][pBankMoney] += HouseInfo[x][hPrice];
  16. 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]));
  17. SCM(id, 0x239931FF, string);
  18. }
  19. else {
  20. mysql_format(handle, szQuery, sizeof(szQuery), "SELECT * FROM `accounts` WHERE `ID` = '%d'", HouseInfo[x][hOwner]);
  21. new Cache: result = mysql_query(handle, szQuery);
  22. if(cache_get_row_count() != 0) {
  23. cache_get_field_content(0, "BankMoney", string); moneys = strval(string);
  24. newmoneys = moneys + HouseInfo[x][hPrice];
  25. }
  26. cache_delete(result);
  27. mysql_format(handle, szQuery, sizeof(szQuery), "UPDATE `accounts` SET `BankMoney` = '%d', `HouseKey` = '0' WHERE `ID` = '%d'", newmoneys, HouseInfo[x][hOwner]);
  28. mysql_tquery(handle, szQuery);
  29. }
  30. PlayerInfo[playerid][pCash] -= HouseInfo[x][hPrice];
  31. PlayerInfo[playerid][pHouseKey] = x;
  32. mysql_format(handle, szQuery, sizeof(szQuery), "UPDATE `accounts` SET `HouseKey` = '%d' WHERE `ID` = '%d'", PlayerInfo[playerid][pHouseKey], GetName(playerid));
  33. mysql_tquery(handle, szQuery);
  34. DestroyDynamicPickup(HouseInfo[x][hPickupID]);
  35. HouseInfo[x][hPickupID] = CreateDynamicPickup(1272, 23, HouseInfo[x][hExteriorPos][0], HouseInfo[x][hExteriorPos][1], HouseInfo[x][hExteriorPos][2], 0, 0, -1, 250);
  36. if(!strcmp(HouseInfo[x][hOwner], "The State", true) && strlen(HouseInfo[x][hOwner]) >= 1) {
  37. format(string, sizeof(string), "* Felicitari! Ai cumparat aceasta casa pentru {19CF2E}$%s{239931}.", FormatNumber(HouseInfo[x][hPrice]));
  38. SCM(playerid, 0x239931FF, string);
  39. }
  40. else {
  41. format(string, sizeof(string), "* Felicitari! Ai cumparat casa lui %s pentru {19CF2E}$%s{239931}.", HouseInfo[x][hOwner], FormatNumber(HouseInfo[x][hPrice]));
  42. SCM(playerid, 0x239931FF, string);
  43. }
  44. PlayerInfo[playerid][pRentedHouse] = 0;
  45. HouseInfo[x][hPrice] = 0;
  46. HouseInfo[x][hOwner] = GetName(playerid);
  47. labelHouse(x);
  48.  
  49. mysql_format(handle, szQuery, sizeof(szQuery), "UPDATE houses SET Owner = '%e', Price = '0' WHERE ID = '%d'", HouseInfo[x][hOwner], x);
  50. mysql_tquery(handle, szQuery);
  51. }
  52. }
  53. return 1;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement