Tikabum

Calc. BT & Snipe

May 6th, 2020
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. javascript:
  2. //----------------------------------------------------------------
  3. //Projeto: Calc. BT & Snipe
  4. //Autor: Desconhecido
  5. //Editor: Gil Penner (Paçoquita) <skype: gilhrpenner@gmail.com>
  6. //Versão: 1.0 - 09/07/2015
  7. //Changelog:
  8. // > 1.0 - Lançamento
  9. //---------------------------------------------------------------
  10.  
  11. if(game_data.player.premium == false) {
  12. UI.InfoMessage('Para utilizar esse script é necessário uma Conta Premium!', 3000, true);
  13. end();
  14. }
  15.  
  16. function calcular() {
  17. if(document.getElementById('bt1').value.match(/[0-9]{2}\:[0-9]{2}\:[0-9]{2}/) != null && document.getElementById('bt2').value.match(/[0-9]{2}\:[0-9]{2}\:[0-9]{2}/) != null) {
  18. var timeArray = document.getElementById('bt1').value.split(':');
  19. var travArray = document.getElementById('bt2').value.split(':');
  20. var result;
  21.  
  22. //Back Time
  23. var h = parseInt(timeArray[0], 10) + parseInt(travArray[0], 10);
  24. var m = parseInt(timeArray[1], 10) + parseInt(travArray[1], 10);
  25. var s = parseInt(timeArray[2], 10) + parseInt(travArray[2], 10);
  26.  
  27. if (s > 60) {
  28. m += 1;
  29. s -= 60;
  30. }
  31. if (m > 60) {
  32. h += 1;
  33. m -= 60;
  34. }
  35. if (h >= 24) {
  36. h -= 24;
  37. }
  38. if (s < 10) {
  39. s = '0' + s;
  40. }
  41. if (m < 10) {
  42. m = '0' + m;
  43. }
  44. if (h < 10) {
  45. h = '0' + h;
  46. }
  47. result = h + ':' + m + ':' + s;
  48. $("#resultado").html("Back:&nbsp; " + result + " (Tropas retornam)");
  49.  
  50. //Snipe
  51. var H = parseInt(timeArray[0], 10) - parseInt(travArray[0], 10);
  52. var M = parseInt(timeArray[1], 10) - parseInt(travArray[1], 10);
  53. var S = parseInt(timeArray[2], 10) - parseInt(travArray[2], 10);
  54.  
  55. if(S < 0) {S = 60 - (S * -1);M --;}
  56. if(M < 0) {M = 60 - (M * -1);H --;}
  57. if(H < 0 ) {H = 24 - (H * -1);if(H>10) {H = 'Ontem às ' + H;}else if(H<10) {H = 'Ontem às ' + H;}}
  58. if(S<10) {S = '0' + S;}
  59. if(M<10) {M = '0' + M;}
  60. if(H<10) {H = '0' + H;}
  61.  
  62. result = H + ':' + M + ':' + S;
  63. $("#resultado").html($("#resultado").html() + "<br />Snipe: " + result);
  64. $("#resultado").fadeIn("slow");
  65. } else {
  66. $("#resultado").html("<p style='color: red;'>Formato de horas incorreto!<br />Utilize: HH:MM:SS</p> ");
  67. $("#resultado").fadeIn("slow");
  68. }
  69. }
  70.  
  71. var conteudo = '<div style=max-width:600px;>' +
  72. '<h2 class="popup_box_header">Calc. BT & Snipe</h2>' +
  73. '<p><div style="text-align: center;">Hora do ataque<br /><input type="text" id="bt1"><br />Duração<br /><input type="text" id="bt2"><br /><br /><input onClick="calcular()" style="padding-left: 28px; background: #6C4824 url(https://brtwscripts.com/calc-icon.png) no-repeat 10px" class="btn" type="submit" value="Calcular"></div></p>' +
  74. '<div id="resultado" style="display: none;">Back:&nbsp; xx:xx:xx<br />Snipe: xx:xx:xx</div>' +
  75. '</div>';
  76.  
  77. Dialog.show('bt_snipe_calc', conteudo);
Add Comment
Please, Sign In to add comment