Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- YCMD:buybusiness(playerid, params[], help)
- {
- for(new x = 0; x < MAX_BUSINESSES; x++)
- {
- if(PlayerToPoint(2.0, playerid, BusinessInfo[x][bExteriorPos][0], BusinessInfo[x][bExteriorPos][1], BusinessInfo[x][bExteriorPos][2]))
- {
- if(PlayerInfo[playerid][pLevel] < 7) {
- if(PlayerInfo[playerid][pLanguage] == 1) SCM(playerid, COLOR_GREY, "Ai nevoie de level 7 pentru a putea cumpara o afacere.");
- else if(PlayerInfo[playerid][pLanguage] == 2) SCM(playerid, COLOR_GREY, "You need a minimum level 7 to buy a business.");
- return 1;
- }
- if(PlayerInfo[playerid][pBusinessKey] != 0) {
- if(PlayerInfo[playerid][pLanguage] == 1) SCM(playerid, COLOR_GREY, "Nu poti detine mai multe afaceri.");
- else if(PlayerInfo[playerid][pLanguage] == 2) SCM(playerid, COLOR_GREY, "You can not hold more business.");
- return 1;
- }
- if(BusinessInfo[x][bPrice] == 0) {
- if(PlayerInfo[playerid][pLanguage] == 1) SCM(playerid, COLOR_GREY, "Aceasta afacere nu este de vanzare.");
- else if(PlayerInfo[playerid][pLanguage] == 2) SCM(playerid, COLOR_GREY, "This business is not for sale.");
- return 1;
- }
- if(PlayerInfo[playerid][pMoney] < BusinessInfo[x][bPrice]) {
- if(PlayerInfo[playerid][pLanguage] == 1) SCM(playerid, COLOR_GREY, "Nu ai suma necesara pentru a cumpara aceasta afacere.");
- else if(PlayerInfo[playerid][pLanguage] == 2) SCM(playerid, COLOR_GREY, "You do not have the amount needed to buy this business.");
- return 1;
- }
- new id, moneys, newmoneys, szQuery[256], string[256];
- id = GetPlayerID(HouseInfo[x][hOwner]);
- if(id != INVALID_PLAYER_ID) {
- PlayerInfo[id][pBankMoney] += BusinessInfo[x][bPrice];
- PlayerInfo[id][pBusinessKey] = 0;
- 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]));
- 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]));
- }
- else {
- mysql_format(mysql, szQuery, sizeof(szQuery), "SELECT * FROM `users` WHERE `ID` = '%d'", BusinessInfo[x][bOwner]);
- new Cache: result = mysql_query(mysql, 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(mysql, szQuery, sizeof(szQuery), "UPDATE `users` SET `BankMoney` = '%d', `BusinessKey` = '0' WHERE `ID` = '%d'", newmoneys, BusinessInfo[x][bOwner]);
- mysql_tquery(mysql, szQuery);
- }
- PlayerInfo[playerid][pMoney] -= BusinessInfo[x][bPrice];
- PlayerInfo[playerid][pBusinessKey] = x;
- mysql_format(mysql, szQuery, sizeof(szQuery), "UPDATE `users` SET `BusinessKey` = '%d' WHERE `ID` = '%d'", PlayerInfo[playerid][pBusinessKey], GetName(playerid));
- mysql_tquery(mysql, szQuery);
- DestroyDynamic3DTextLabel(BusinessInfo[x][bLabelID]);
- if(!strcmp(BusinessInfo[x][bOwner], "The State", true) && strlen(BusinessInfo[x][bOwner]) >= 1) {
- if(PlayerInfo[playerid][pLanguage] == 1) format(string, sizeof(string), "* Felicitari! Ai cumparat aceasta afacere pentru {19CF2E}$%s{239931}.", FormatNumber(BusinessInfo[x][bPrice]));
- else if(PlayerInfo[playerid][pLanguage] == 2) format(string, sizeof(string), "* Congratulations! You bought this business for {19CF2E}$%s{239931}.", FormatNumber(BusinessInfo[x][bPrice]));
- SCM(playerid, 0x239931FF, string);
- }
- else {
- 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]));
- 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]));
- SCM(playerid, 0x239931FF, string);
- }
- BusinessInfo[x][bPrice] = 0;
- BusinessInfo[x][bOwner] = GetName(playerid);
- labelBusiness(x);
- mysql_format(mysql, szQuery, sizeof(szQuery), "UPDATE businesses SET Owner = '%e', Price = '0' WHERE ID = '%d'", BusinessInfo[x][bOwner], x);
- mysql_tquery(mysql, szQuery);
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement