Advertisement
Guest User

Untitled

a guest
Sep 29th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.24 KB | None | 0 0
  1. CMD:buybiz(playerid,params[])
  2. {
  3. if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
  4. if(gPlayerLogged[playerid] != 0)
  5. {
  6. new Float:oldposx, Float:oldposy, Float:oldposz;
  7. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  8. new string[128],sendername[25],stringcasa[128];
  9. for(new b = 1; b < sizeof(++)
  10. {
  11. if(PlayerToPoint(2.0, playerid, BizzInfo[bEntranceX], BizzInfo[bEntranceY], BizzInfo[bEntranceZ]) && BizzInfo[bOwned] == 0)
  12. {
  13. if(PlayerInfo[playerid][pPbiskey] <= 254) return SendClientMessage(playerid, COLOR_WHITE, "{FFB870}You already own a business, type /sellbiztostate if you want to buy this one.");
  14. if(PlayerInfo[playerid][pLevel] < BizzInfo[bLevelNeeded])
  15. {
  16. format(string, sizeof(string), "{FFB870}You must be level %d to purchase this.",BizzInfo[bLevelNeeded]);
  17. SendClientMessage(playerid, COLOR_WHITE, string);
  18. return 1;
  19. }
  20. if(GetPlayerCash(playerid) > BizzInfo[bBuyPrice])
  21. {
  22. PlayerInfo[playerid][pPbiskey] = b;
  23. BizzInfo[bOwned] = 1;
  24. GetPlayerName(playerid, sendername, sizeof(sendername));
  25. strmid(BizzInfo[bOwner], PlayerInfo[playerid][pNormalName], 0, 25, 255);
  26. GivePlayerCash(playerid,-BizzInfo[bBuyPrice]);
  27. GameTextForPlayer(playerid, "~w~Welcome~n~You can exit at any time by moving to this door and press enter", 5000, 3);
  28. if(BizzInfo[bSbiz] == 0)
  29. {
  30. PlayerInfo[playerid][pInt] = BizzInfo[bInterior];
  31. PlayerInfo[playerid][pLocal] = b ;
  32. InBussines[playerid] = b;
  33. SetPlayerInterior(playerid,BizzInfo[bInterior]);
  34. SetPlayerVirtualWorld(playerid, BizzInfo[bVirtual]);
  35. PlayerInfo[playerid][pInt] = BizzInfo[bInterior];
  36. SetPlayerPosEx(playerid,BizzInfo[bExitX],BizzInfo[bExitY],BizzInfo[bExitZ]);
  37. }
  38. SendClientMessage(playerid, COLOR_WHITE, "Congratulations, On Your New Purchase.");
  39. SendClientMessage(playerid, COLOR_WHITE, "Type /help to review the new business help section.");
  40. format(stringcasa, sizeof(stringcasa), "%s [user:%d] a cumparat bizz-ul [bizz:%d] de la Stat pentru $%s.",sendername,PlayerInfo[playerid][pSQLID],b,FormatNumber(BizzInfo[bBuyPrice]));
  41. ABroadCast(COLOR_YELLOW, stringcasa,1);
  42. new var100[256],y,m,d,h,mi,s,string2[256],string3[256];
  43. getdate(y,m,d);
  44. gettime(h,mi,s);
  45. format(string2,sizeof(string2),"[%02d-%02d-%d %02d:%02d:%02d] %s[user:%d] bought bizz %d for $%s.",d,m,y,h,mi,s,sendername,PlayerInfo[playerid][pSQLID],b,FormatNumber(BizzInfo[bBuyPrice]));
  46. mysql_real_escape_string(string2, string3);
  47. mysql_format(SQL, var100, sizeof(var100), "INSERT INTO playerlogs (`playerid`,`giverid`,`action`,`time`) VALUES ('%d','0','%s','%02d-%02d-%d %02d:%02d:%02d')", PlayerInfo[playerid][pSQLID],string3,d,m,y,h,mi,s);
  48. mysql_tquery(SQL,var100,"","");
  49. new str1[256];
  50. mysql_format(SQL,str1,sizeof(str1),"UPDATE users SET `Money`='%d',`Bizz`='%d' WHERE `name`='%s'",GetPlayerCash(playerid),PlayerInfo[playerid][pPbiskey],PlayerInfo[playerid][pNormalName]);
  51. mysql_tquery(SQL,str1,"","");
  52. mysql_format(SQL,str1,sizeof(str1),"UPDATE `bizz` SET `Owned`='1',`Owner`='%s' WHERE `ID`='%d'",BizzInfo[bOwner],b);
  53. mysql_tquery(SQL,str1,"","");
  54. OnPropTextdrawUpdate(2,b);
  55. return 1;
  56. }
  57. else
  58. {
  59. SendClientMessage(playerid, COLOR_WHITE, "You don't have the cash for that");
  60. return 1;
  61. }
  62. }
  63. }
  64. }
  65. return 1;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement