Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.50 KB | None | 0 0
  1. if (game_data.player.premium == false) { UI.InfoMessage('Para utilizar esse script รฉ necessรกrio uma Conta Premium!', 3000, true); end(); } if (game_data.screen != 'map') { UI.InfoMessage('Script deve ser usado no mapa!', 3000, true); end(); } setInterval(function() { $("#map_container div:not('.map_border') img[id^='map_cmdicons_']").each(function(i, e) { var aldeia = $(e).attr('id').replace('_0', '').replace('cmdicons', 'village'); $(e).remove(); $("#" + aldeia).remove(); }); $("#map_container div:not('.map_border') img[src*='v1.png']").each(function(i, e) { var aldeia = $(e).attr('id').replace('_0', '').replace('cmdicons', 'village'); $(e).remove(); $("#" + aldeia).remove(); }); $("#map_container div:not('.map_border') img[src*='v2.png']").each(function(i, e) { var aldeia = $(e).attr('id').replace('_0', '').replace('cmdicons', 'village'); $(e).remove(); $("#" + aldeia).remove(); }); $("#map_container div:not('.map_border') img[src*='v3.png']").each(function(i, e) { var aldeia = $(e).attr('id').replace('_0', '').replace('cmdicons', 'village'); $(e).remove(); $("#" + aldeia).remove(); }); $("#map_container div:not('.map_border') img[src*='v4.png']").each(function(i, e) { var aldeia = $(e).attr('id').replace('_0', '').replace('cmdicons', 'village'); $(e).remove(); $("#" + aldeia).remove(); }); $("#map_container div:not('.map_border') img[src*='v5.png']").each(function(i, e) { var aldeia = $(e).attr('id').replace('_0', '').replace('cmdicons', 'village'); $(e).remove(); $("#" + aldeia).remove(); }); $("#map_container div:not('.map_border') img[src*='b1.png']").each(function(i, e) { var aldeia = $(e).attr('id').replace('_0', '').replace('cmdicons', 'village'); $(e).remove(); $("#" + aldeia).remove(); }); $("#map_container div:not('.map_border') img[src*='b2.png']").each(function(i, e) { var aldeia = $(e).attr('id').replace('_0', '').replace('cmdicons', 'village'); $(e).remove(); $("#" + aldeia).remove(); }); $("#map_container div:not('.map_border') img[src*='b3.png']").each(function(i, e) { var aldeia = $(e).attr('id').replace('_0', '').replace('cmdicons', 'village'); $(e).remove(); $("#" + aldeia).remove(); }); $("#map_container div:not('.map_border') img[src*='b4.png']").each(function(i, e) { var aldeia = $(e).attr('id').replace('_0', '').replace('cmdicons', 'village'); $(e).remove(); $("#" + aldeia).remove(); }); $("#map_container div:not('.map_border') img[id*='map_icons_']").each(function(i, e) { $(e).remove(); }); }, 1);
  2.  
  3. win = window;
  4. // === tw100 ===
  5. ScriptAPI.lib = {
  6. launchOnScreen: function (screen, onError, noConflict) {
  7. if (game_data.screen != screen) {
  8. if (onError == null) return false;
  9. if (onError.substring(0, 1) == "/") window.location.href = onError;
  10. else UI.ErrorMessage(onError, 5000);
  11. return false;
  12. }
  13. if (ScriptAPI.preventLaunch === true) {
  14. UI.ErrorMessage('O script ja esta sendo TW100\'Executado', 5000);
  15. return false;
  16. }
  17. win.DSSelectVillages.enableScript();
  18. ScriptAPI.preventLaunch = (noConflict !== false) ? true : false;
  19. return true;
  20. }
  21. }
  22. win.DSSelectVillages =
  23. {
  24. currentLang: 'fr',
  25.  
  26. showWithCoords: true,
  27.  
  28. showWithCounter: true,
  29.  
  30. showWithNewLine: true,
  31.  
  32. breakAfter: -1,
  33.  
  34. enabled: false,
  35.  
  36. villages: [],
  37.  
  38. villagesId: [],
  39.  
  40. lang: {
  41. de: {
  42. UI: {
  43. selectedVillages: "Aldeias selecionadas:",
  44. enableShowWithCoords: "Mostrar BBCodes",
  45. enableShowWithCounter: "Mostrar contadores"
  46. }
  47. },
  48. fr: {
  49. UI: {
  50. selectedVillages: "๐•๐• ๐•ฆ๐•ฅ๐•ฆ๐•“๐•– ๐•‹๐•จ ๐Ÿ™๐Ÿ˜๐Ÿ˜",
  51. enableShowWithCoords: "BBcodes",
  52. enableShowWithCounter: "Lista Numerica",
  53. enableShowWithNewLine: "Em Linha"
  54. }
  55. },
  56. pt: {
  57. UI: {
  58. selectedVillages: "xD",
  59. enableShowWithCoords: "Cรณdigo BB",
  60. enableShowWithCounter: "Lista Numerica",
  61. enableShowWithNewLine: "Em Linha"
  62. }
  63. }
  64. },
  65.  
  66. enableScript: function () {
  67. this.enabled = true;
  68. this.showWithCoords = win.showWithCoords;
  69. this.showWithCounter = win.showWithCounter;
  70. this.breakAfter = win.breakAfter;
  71. win.TWMap.mapHandler.integratedSpawnSector = win.TWMap.mapHandler.spawnSector;
  72. win.TWMap.mapHandler.spawnSector = this.spawnSector;
  73.  
  74. this.oldClickFunction = win.TWMap.mapHandler.onClick;
  75. win.TWMap.mapHandler.onClick = this.clickFunction;
  76. win.TWMap.reload();
  77.  
  78. this.showUi();
  79. },
  80.  
  81. spawnSector: function (data, sector) {
  82. win.TWMap.mapHandler.integratedSpawnSector(data, sector);
  83. for (var i = 0; i < win.DSSelectVillages.villagesId.length; i++) {
  84. var villageId = win.DSSelectVillages.villagesId[i];
  85. if(villageId === null){
  86. continue;
  87. }
  88. var v = $('#map_village_' + villageId);
  89. $('<div class="DSSelectVillagesOverlay" id="DSSelectVillages_overlay_' + villageId + '" style="width:52px; height:37px; position: absolute; z-index: 50; left:' + $(v).css('left') + '; top: ' + $(v).css('top') + ';"></div>').appendTo(v.parent());
  90. $('#DSSelectVillages_overlay_' + villageId).css('outline', 'rgba(51, 255, 0, 0.7) solid 2px').css('background-color', 'rgba(155, 252, 10, 0.14)');
  91. }
  92. },
  93.  
  94. markVillageAsSelected: function (id) {
  95. $('#DSSelectVillages_overlay_' + id).css('outline', 'rgba(51, 255, 0, 0.7) solid 2px').css('background-color', 'rgba(155, 252, 10, 0.14)');
  96. },
  97. demarkVillageAsSelected: function (id) {
  98. $('#DSSelectVillages_overlay_' + id).css('outline', '').css('background-color', '');
  99. },
  100.  
  101. disableScript: function () {
  102. this.enabled = false;
  103. this.villages = [];
  104. this.villagesId = [];
  105. win.TWMap.mapHandler.onClick = this.oldClickFunction;
  106. win.TWMap.mapHandler.spawnSector = win.TWMap.mapHandler.integratedSpawnSector;
  107. win.TWMap.reload();
  108. $('#bb_main_div').remove();
  109. },
  110.  
  111. showUi: function () {
  112.  
  113. $('#map_config').prepend('<table id="bb_main_div" class="vis" style="border-spacing:0px;border-collapse:collapse;margin-top:15px;" width="100%"><tbody>'
  114. +'<tr><th colspan="3">' + this.lang[this.currentLang].UI.selectedVillages + '</th></tr>'
  115. +'<tr>'
  116. +' <td>'
  117. +' <input type="checkbox" id="bbcode">'
  118. +' </td>'
  119. +' <td>'
  120. +' <label for="warplanner_enabled">' + this.lang[this.currentLang].UI.enableShowWithCoords + '</label>'
  121. +' </td>'
  122. +'</tr>'
  123. +'<tr>'
  124. +' <td>'
  125. +' <input type="checkbox" id="zaehlen">'
  126. +' </td>'
  127. +' <td>'
  128. +' <label for="warplanner_enabled">' + this.lang[this.currentLang].UI.enableShowWithCounter + '</label>'
  129. +' </td>'
  130. +'</tr>'
  131. +'<tr>'
  132. +' <td>'
  133. +' <input type="checkbox" id="new-line">'
  134. +' </td>'
  135. +' <td>'
  136. +' <label for="new-line">' + this.lang[this.currentLang].UI.enableShowWithNewLine + '</label>'
  137. +' </td>'
  138. +'</tr>'
  139. +'<tr><td></td>'
  140. +' <td>'
  141. +' <textarea id="output" rows="5" style="width:95%;" readonly></textarea>'
  142. +' </td>'
  143. +'</tr>'
  144. +'</tbody></table>');
  145. var chkbxBBcode = $('#bbcode');
  146. var chkbxcounter = $('#zaehlen');
  147. var chkbxShowWithNewLine = $('#new-line');
  148. chkbxBBcode.prop('checked', this.showWithCoords);
  149. chkbxcounter.prop('checked', this.showWithCounter);
  150. chkbxShowWithNewLine.prop('checked', this.showWithNewLine);
  151. chkbxBBcode.change(function () {
  152. win.DSSelectVillages.showWithCoords = this.checked;
  153. win.DSSelectVillages.outputCoords();
  154. });
  155. chkbxcounter.change(function () {
  156. win.DSSelectVillages.showWithCounter = this.checked;
  157. win.DSSelectVillages.outputCoords();
  158. });
  159. chkbxShowWithNewLine.change(function () {
  160. win.DSSelectVillages.showWithNewLine = this.checked;
  161. win.DSSelectVillages.outputCoords();
  162. });
  163. },
  164.  
  165. outputCoords: function () {
  166. var coordsOutput = "";
  167. for (var i = 0; i < this.villages.length; i++) {
  168. if (this.villages[i] === null) {
  169. continue;
  170. }
  171. var realCount = 0;
  172. for (var j = 0; j <= i; j++) {
  173. if (this.villages[j] != null) {
  174. realCount++;
  175. }
  176. }
  177. coordsOutput += (this.showWithCounter ? realCount + ". " : "" ) + (this.showWithCoords ? "[coord]" : "") + this.villages[i] + (this.showWithCoords ? "[/coord]" : "") + (this.showWithNewLine ? "\n" : " ");
  178. if (this.breakAfter != -1 && realCount % this.breakAfter == 0) {
  179. coordsOutput += "\n";
  180. }
  181. }
  182. $('#output').html(coordsOutput);
  183. $("#output").select();
  184. },
  185.  
  186. handleVillage: function (x, y) {
  187. var coord = x + "|" + y;
  188. var index = this.villages.indexOf(coord);
  189. var village = win.TWMap.villages[(x) * 1000 + y];
  190. if (!village) {
  191. return;
  192. }
  193. if (index === -1) {
  194. this.villages.push(coord);
  195. this.villagesId.push(village.id);
  196. this.atacarAldeia(village.id);
  197. this.markVillageAsSelected(village.id);
  198. win.TWMap.reload();
  199. } else {
  200. this.villages[index] = null;
  201. var indexId = this.villagesId.indexOf(village.id);
  202. this.villagesId[indexId] = null;
  203. this.demarkVillageAsSelected(village.id);
  204. }
  205. this.outputCoords();
  206. },
  207.  
  208. clickFunction: function (x, y, event) {
  209. win.DSSelectVillages.handleVillage(x, y);
  210. return false; // Sinaliza que o TWMap nรƒยฃo deve seguir o URL associado a este evento de clique
  211. },
  212.  
  213. HttpClient: function() {
  214. this.get = function(aUrl, aCallback) {
  215. var anHttpRequest = new XMLHttpRequest();
  216. anHttpRequest.onreadystatechange = function() {
  217. if (anHttpRequest.readyState == 4 && anHttpRequest.status == 200)
  218. aCallback(anHttpRequest.responseText);
  219. }
  220. anHttpRequest.open( "GET", aUrl, true );
  221. anHttpRequest.send( null );
  222. }
  223. },
  224.  
  225. atacarAldeia: function(target)
  226. {
  227. var mundo = game_data.world;
  228. var aldeiaAtualId = game_data.village.id;
  229. var modelo = TWMap.urls.ctx.mp_farm_a.split("=")[5].split("&")[0];
  230. var token = csrf_token;
  231. var client = new this.HttpClient();
  232. client.get('https://'+mundo+'.tribalwars.com.pt/game.php?village='+aldeiaAtualId+'&screen=am_farm&mode=farm&ajaxaction=farm&template_id='+modelo+'&target='+target+'&source='+aldeiaAtualId+'&json=1&&h='+token, function(response) {
  233. // do something with response
  234. });
  235. },
  236.  
  237.  
  238.  
  239.  
  240. oldClickFunction: null
  241. };
  242.  
  243. ScriptAPI.lib.launchOnScreen('map', "Este script deve ser executado a partir do mapa");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement