Guest User

Untitled

a guest
Jan 28th, 2020
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. var monthSymbol = "tháng | ";
  2. var daySymbol = "ngày | ";
  3. var hourSymbol = "giờ | ";
  4. var minuteSymbol = "phút | ";
  5. var secondSymbol = "giây ";
  6.  
  7. var arg = args[0].split("_");
  8. if (arg.length === 2) {
  9. var ID = arg[0];
  10. var cooldown = arg[1];
  11. }
  12.  
  13. var dataLoc = "%player_name%." + ID + ".date";
  14. var currentDate = new Date();
  15.  
  16. function Cooldown() {
  17. if (!Data.exists(dataLoc)) {
  18. return "0s";
  19. } else {
  20. var startDate = new Date(Data.get(dataLoc));
  21. var difference = currentDate - startDate;
  22. var result = Math.floor(difference / 1000);
  23. if (result >= cooldown) {
  24. return "0s";
  25. } else {
  26. startDate = new Date(startDate.getTime() + (cooldown * 1000));
  27. var result = startDate - currentDate;
  28.  
  29. var months = Math.floor(result / (1000 * 60 * 60 * 24 * 31));
  30. var days = Math.floor(result % (1000 * 60 * 60 * 24 * 31) / (1000 * 60 * 60 * 24));
  31. var hours = Math.floor(result % (1000 * 60 * 60 * 24) / (1000 * 60 * 60));
  32. var minutes = Math.floor(result % (1000 * 60 * 60) / (1000 * 60));
  33. var seconds = Math.floor(result % (1000 * 60) / (1000));
  34.  
  35. if (months === 0 && days === 0 && hours === 0 && minutes === 0) {
  36. return seconds + secondSymbol;
  37. } else if (months === 0 && days === 0 && hours === 0) {
  38. return minutes + minuteSymbol + seconds + secondSymbol;
  39. } else if (months === 0 && days === 0) {
  40. return hours + hourSymbol + minutes + minuteSymbol + seconds + secondSymbol;
  41. } else if (months === 0) {
  42. return days + daySymbol + hours + hourSymbol + minutes + minuteSymbol + seconds + secondSymbol;
  43. } else {
  44. return months + monthSymbol + days + daySymbol + hours + hourSymbol + minutes + minuteSymbol + seconds + secondSymbol;
  45. }
  46. }
  47. }
  48. }
  49.  
  50. function start() {
  51. var data = currentDate.toString();
  52.  
  53. Data.set(dataLoc, data);
  54. Placeholder.saveData();
  55. }
  56.  
  57. function run() {
  58. if (args.length !== 1 || arg.length !== 2) {
  59. return "&cInvalid syntax, Please use this syntax:\n&7%" + "javascript_cooldown_[ID]_[Cooldown/Start]" + "%";
  60. } else if (cooldown.toUpperCase() === "START") {
  61. return start();
  62. } else if (isNaN(cooldown)) {
  63. return "&cPlease set a valid cooldown.";
  64. } else if (!isNaN(cooldown)) {
  65. return Cooldown();
  66. } else {
  67. return "&cInvalid syntax, Please use this syntax:\n&7%" + "javascript_cooldown_[ID]_[Cooldown/Start]" + "%";
  68. }
  69. }
  70. run();
Advertisement
Add Comment
Please, Sign In to add comment