Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. new plantseedcount[MAX_PLAYERS];
  2. new plantseedtimer[MAX_PLAYERS];
  3. CMD:buyseeds(playerid,params[])
  4. {
  5. new formatstring[100];
  6. if(!IsPlayerInRangeOfPoint(playerid,3.5,1363.6545,-1718.6127,8.5180) &&
  7. !IsPlayerInRangeOfPoint(playerid,3.5,2783.6255,-2373.3210,13.6328) &&
  8. !IsPlayerInRangeOfPoint(playerid,3.5,2351.7390,-648.0338,128.0547)) return SendClientMessage(playerid,-1,"[SERVER]You are not near a drug market spot.");
  9. new amount;
  10. if(sscanf(params, "d", amount)) return SendClientMessage(playerid,-1,"[SERVER] Correct usage: /buyseeds [amount]");
  11. if(amount < 1 || amount > 250) return SendClientMessage(playerid,-1,"[SERVER] You are not permitted to buy seeds in bulk, you may only buy 250 seeds.");
  12. if(GetPlayerMoney(playerid) < (amount*100))
  13. {
  14. new str[128]; format(str, sizeof(str), "You need %s in order to buy %d seeds.", FormatNumber(amount*100), amount);
  15. SendClientMessage(playerid, -1, str);
  16. return 1;
  17. }
  18. if(GetPVarInt(playerid, "Usedbuyseeds") ==1)
  19. {
  20. format(formatstring, 100, "[SERVER]You are attracting too much heat, you will need to wait %d seconds before buying again", plantseedcount[playerid]);
  21. SendClientMessage(playerid,-1,formatstring);
  22. return true;
  23. }
  24. SetPVarInt(playerid, "Usedbuyseeds", 1);
  25. plantseedcount[playerid] = 50;
  26. plantseedtimer[playerid] = SetTimerEx("Resetbuyseeds", 1000, true, "i", playerid);
  27. GivePlayerMoney(playerid, -(amount*100));
  28. pinfo[playerid][seeds] = pinfo[playerid][seeds] + amount;
  29. format(formatstring, 100, "[SERVER]You bought %d seed for %s!", amount, FormatNumber((amount*100)));
  30. SendClientMessage(playerid, -1, formatstring);
  31. return 1;
  32. }
  33. stock FormatNumber(number, prefix[] = "$")
  34. {
  35. new value[32], length;
  36. format(value, sizeof(value), "%d", (number < 0) ? (-number) : (number));
  37. if((length = strlen(value)) > 3)
  38. {
  39. for(new i = length, l = 0; --i >= 0; l ++) {
  40. if((l > 0) && (l % 3 == 0)) strins(value, ",", i + 1);
  41. }
  42. }
  43. if(prefix[0] != 0) strins(value, prefix, 0);
  44. if(number < 0) strins(value, "-", 0);
  45. return value;
  46. }
  47. forward Resetbuyseeds(playerid);
  48. public Resetbuyseeds(playerid)
  49. {
  50. if(plantseedcount[playerid] == 0)
  51. {
  52. if(IsPlayerConnected(playerid)) DeletePVar(playerid, "Usedbuyseeds"), KillTimer(plantseedtimer[playerid]);
  53. }
  54. return plantseedcount[playerid]--;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement