Advertisement
Guest User

Untitled

a guest
Jun 8th, 2018
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.47 KB | None | 0 0
  1. YCMD:buybusiness(playerid, params[], help)
  2. {
  3. for(new x = 0; x < MAX_BUSINESSES; x++)
  4. {
  5. if(PlayerToPoint(2.0, playerid, BusinessInfo[x][bExteriorPos][0], BusinessInfo[x][bExteriorPos][1], BusinessInfo[x][bExteriorPos][2]))
  6. {
  7. if(PlayerInfo[playerid][pLevel] < 7) {
  8. if(PlayerInfo[playerid][pLanguage] == 1) SCM(playerid, COLOR_GREY, "Ai nevoie de level 7 pentru a putea cumpara o afacere.");
  9. else if(PlayerInfo[playerid][pLanguage] == 2) SCM(playerid, COLOR_GREY, "You need a minimum level 7 to buy a business.");
  10. return 1;
  11. }
  12. if(PlayerInfo[playerid][pBusinessKey] != 0) {
  13. if(PlayerInfo[playerid][pLanguage] == 1) SCM(playerid, COLOR_GREY, "Nu poti detine mai multe afaceri.");
  14. else if(PlayerInfo[playerid][pLanguage] == 2) SCM(playerid, COLOR_GREY, "You can not hold more business.");
  15. return 1;
  16. }
  17. if(BusinessInfo[x][bPrice] == 0) {
  18. if(PlayerInfo[playerid][pLanguage] == 1) SCM(playerid, COLOR_GREY, "Aceasta afacere nu este de vanzare.");
  19. else if(PlayerInfo[playerid][pLanguage] == 2) SCM(playerid, COLOR_GREY, "This business is not for sale.");
  20. return 1;
  21. }
  22. if(PlayerInfo[playerid][pMoney] < BusinessInfo[x][bPrice]) {
  23. if(PlayerInfo[playerid][pLanguage] == 1) SCM(playerid, COLOR_GREY, "Nu ai suma necesara pentru a cumpara aceasta afacere.");
  24. else if(PlayerInfo[playerid][pLanguage] == 2) SCM(playerid, COLOR_GREY, "You do not have the amount needed to buy this business.");
  25. return 1;
  26. }
  27. new id, moneys, newmoneys, szQuery[256], string[256];
  28. id = GetPlayerID(HouseInfo[x][hOwner]);
  29. if(id != INVALID_PLAYER_ID) {
  30. PlayerInfo[id][pBankMoney] += BusinessInfo[x][bPrice];
  31. PlayerInfo[id][pBusinessKey] = 0;
  32. if(PlayerInfo[playerid][pLanguage] == 1) SCMEx(id, COLOR_GREEN2, "* %s ti-a cumparat afacerea pentru {19CF2E}$%s{239931}. Banii au fost transferati in contul tau bancar.", GetName(playerid), FormatNumber(BusinessInfo[x][bPrice]));
  33. else if(PlayerInfo[playerid][pLanguage] == 2) SCMEx(id, COLOR_GREEN2, "* %s bought your business for {19CF2E}$%s{239931}. The money was transferred into your bank account.", GetName(playerid), FormatNumber(BusinessInfo[x][bPrice]));
  34. }
  35. else {
  36. mysql_format(mysql, szQuery, sizeof(szQuery), "SELECT * FROM `users` WHERE `ID` = '%d'", BusinessInfo[x][bOwner]);
  37. new Cache: result = mysql_query(mysql, szQuery);
  38. if(cache_get_row_count() != 0) {
  39. cache_get_field_content(0, "BankMoney", string); moneys = strval(string);
  40. newmoneys = moneys + HouseInfo[x][hPrice];
  41. }
  42. cache_delete(result);
  43. mysql_format(mysql, szQuery, sizeof(szQuery), "UPDATE `users` SET `BankMoney` = '%d', `BusinessKey` = '0' WHERE `ID` = '%d'", newmoneys, BusinessInfo[x][bOwner]);
  44. mysql_tquery(mysql, szQuery);
  45. }
  46. PlayerInfo[playerid][pMoney] -= BusinessInfo[x][bPrice];
  47. PlayerInfo[playerid][pBusinessKey] = x;
  48. mysql_format(mysql, szQuery, sizeof(szQuery), "UPDATE `users` SET `BusinessKey` = '%d' WHERE `ID` = '%d'", PlayerInfo[playerid][pBusinessKey], GetName(playerid));
  49. mysql_tquery(mysql, szQuery);
  50. DestroyDynamic3DTextLabel(BusinessInfo[x][bLabelID]);
  51. if(!strcmp(BusinessInfo[x][bOwner], "The State", true) && strlen(BusinessInfo[x][bOwner]) >= 1) {
  52. if(PlayerInfo[playerid][pLanguage] == 1) format(string, sizeof(string), "* Felicitari! Ai cumparat aceasta afacere pentru {19CF2E}$%s{239931}.", FormatNumber(BusinessInfo[x][bPrice]));
  53. else if(PlayerInfo[playerid][pLanguage] == 2) format(string, sizeof(string), "* Congratulations! You bought this business for {19CF2E}$%s{239931}.", FormatNumber(BusinessInfo[x][bPrice]));
  54. SCM(playerid, 0x239931FF, string);
  55. }
  56. else {
  57. if(PlayerInfo[playerid][pLanguage] == 1) format(string, sizeof(string), "* Felicitari! Ai cumparat afacerea lui %s pentru {19CF2E}$%s{239931}.", BusinessInfo[x][bOwner], FormatNumber(BusinessInfo[x][bPrice]));
  58. else if(PlayerInfo[playerid][pLanguage] == 2) format(string, sizeof(string), "* Congratulations! You bought his %s business for {19CF2E}$%s{239931}.", BusinessInfo[x][bOwner], FormatNumber(BusinessInfo[x][bPrice]));
  59. SCM(playerid, 0x239931FF, string);
  60.  
  61. }
  62. BusinessInfo[x][bPrice] = 0;
  63. BusinessInfo[x][bOwner] = GetName(playerid);
  64. labelBusiness(x);
  65.  
  66. mysql_format(mysql, szQuery, sizeof(szQuery), "UPDATE businesses SET Owner = '%e', Price = '0' WHERE ID = '%d'", BusinessInfo[x][bOwner], x);
  67. mysql_tquery(mysql, szQuery);
  68. }
  69. }
  70. return 1;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement