Advertisement
Guest User

Untitled

a guest
Jun 1st, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. CMD:buyproducts(playerid, params[])
  2. {
  3. new amount, price, string[128];
  4. new idx = PlayerInfo[playerid][pBiz];
  5. if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  6. if(!PlayerInfo[playerid][pBiz] && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a business.");
  7. if(GetPlayerVirtualWorld(playerid)-100 != idx && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your business.");
  8. if(GetPlayerVirtualWorld(playerid)-100 != idx && PlayerInfo[playerid][pVBiz])
  9. {
  10. idx = PlayerInfo[playerid][pVBiz];
  11. if(GetPlayerVirtualWorld(playerid)-100 != idx) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your business.");
  12. }
  13. if(sscanf(params, "i", amount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /buyproducts [amount]");
  14. if(amount < 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid products amount.");
  15. if(Products < amount)
  16. {
  17. format(string, sizeof(string), "The products dropoff currently has %d products only.", Products);
  18. SendClientMessage(playerid, COLOR_GREY, string);
  19. return 1;
  20. }
  21. price = amount*20;
  22. if(PlayerInfo[playerid][pCash] < price)
  23. {
  24. format(string, sizeof(string), "You don't have that much money on you. ($%d)", price);
  25. SendClientMessage(playerid, COLOR_GREY, string);
  26. return 1;
  27. }
  28. if(BizInfo[idx][bProducts]+amount > 500) return SendClientMessage(playerid, COLOR_GREY, "Your business can't hold that much products.");
  29. GivePlayerCash(playerid, -price);
  30. BizInfo[idx][bProducts] += amount;
  31. Products -= amount;
  32. format(string, sizeof(string), "* %s has purchased %d products for $%d.", RPN(playerid), amount, price);
  33. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  34. format(string, sizeof(string), "Packages Dropoff\n{FFFF00}/deliverpackages to deliver crates\nAvailable Products: %d/20000", Products);
  35. UpdateDynamic3DTextLabelText(ProductsText, COLOR_RED, string);
  36. return 1;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement