PrimeDice Bot script


SUBMITTED BY: Guest

DATE: Oct. 29, 2013, 8:15 a.m.

FORMAT: Text only

SIZE: 16.3 kB

HITS: 4263

  1. var lastmessage = 0,
  2. autobet_speed = 20,
  3. normalbet_speed = 500,
  4. id = 0,
  5. timedCount, timer, lastYourBet = 0,
  6. lastAllBet = 0,
  7. lastBigBet = 0,
  8. autobet_halt, first_load = true,
  9. autobet_index = false,
  10. prev_balance = 0,
  11. bet_ids = [];
  12. function bet(bet, odds, type, callback) {
  13. $.ajax({
  14. url: '/api/bet.php',
  15. type: 'post',
  16. data: {
  17. 'bet': bet,
  18. 'game': odds,
  19. 'type': type == 0 ? 1 : 0,
  20. 'client_seed': $('#client-seed').val()
  21. },
  22. dataType: 'json',
  23. success: function (data) {
  24. if (data.error) {
  25. //alert(data.message);
  26. autobet_halt = true;
  27. return;
  28. }
  29. var $seed = $('#client-seed'),
  30. seed = $seed.val(),
  31. $parent = $seed.parent(),
  32. i = seed.indexOf('-'),
  33. val;
  34. if (i == -1) {
  35. seed += '-0000';
  36. i = seed.indexOf('-');
  37. }
  38. val = (parseInt(seed.substr(i + 1)) + 1).toString();
  39. while (val.length < 4) {
  40. val = '0' + val;
  41. }
  42. seed = seed.substr(0, i) + '-' + val;
  43. $seed.val(seed);
  44. $parent.find('.pretty-text').text(seed);
  45. $('#server-seed').text(data.next_server_seed);
  46. prev_balance = data.balance;
  47. $('#balance').val(data.balance);
  48. $('#balance-value').text(data.balance).stop(true, true).css({
  49. color: data.result == "1" ? '#0f0' : '#f66'
  50. }).animate({
  51. color: '#fff'
  52. }, 500);
  53. addRows($('#table-1'), [data], autobet_index !== false ? autobet_index + 1 : false);
  54. addRows($('#table-2'), [data]);
  55. },
  56. error: function (jqXHR) {
  57. //alert('Error:\n' + jqXHR.responseText);
  58. autobet_halt = true;
  59. },
  60. complete: function (jqXHR) {
  61. var data;
  62. try {
  63. data = $.parseJSON(jqXHR.responseText);
  64. } catch (e) {
  65. data = false;
  66. }
  67. if (typeof callback === 'function') {
  68. callback(data);
  69. }
  70. }
  71. });
  72. }
  73. function auto_bet(params) {
  74. setTimeout(function () {
  75. var current_balance = parseFloat($('#balance-value').text());
  76. if (current_balance === 0)
  77. {
  78. autobet_index = false;
  79. return;
  80. }
  81. else if(params.current_bet > current_balance)
  82. params.current_bet = current_balance;
  83. bet(params.current_bet, params.odds, params.type, function (data) {
  84. var i, a, j, curbet;
  85. if (data) {
  86. params.current_run++;
  87. autobet_index = params.current_run;
  88. if (data.result == 0) {
  89. if (params.on_loss_return) {
  90. params.current_bet = params.bet;
  91. } else {
  92. params.current_bet *= params.on_loss_multiply;
  93. }
  94. } else {
  95. if (params.on_win_return) {
  96. params.current_bet = params.bet;
  97. } else {
  98. params.current_bet *= params.on_win_multiply;
  99. }
  100. }
  101. curbet = params.current_bet.toString();
  102. if (curbet.indexOf('e') > -1) {
  103. i = parseInt(curbet.substr(0, curbet.indexOf('e')).replace('.', ''));
  104. a = parseInt(curbet.substr(curbet.indexOf('e') + 2));
  105. curbet = i.toString();
  106. for (j = 1; j < a; j++) {
  107. curbet = '0' + curbet;
  108. }
  109. params.current_bet = '0.' + curbet;
  110. }
  111. params.current_bet = +('' + params.current_bet).substr(0, ('' +params.current_bet).indexOf('.') + 9);
  112. if (data.balance < data.current_bet) {
  113. return;
  114. }
  115. }
  116. if (params.current_run < params.total_runs) {
  117. if(params.current_bet < params.bet)
  118. params.current_bet = params.bet;
  119. auto_bet(params);
  120. } else {
  121. //CHANGE THE AUTOBET PARAMETERS HERE
  122. params = {
  123. odds: 50.50,
  124. type: 0,
  125. bet: 0.0000002,
  126. total_runs: 9999999,
  127. on_loss_return: false,
  128. on_loss_multiply: 2,
  129. on_win_return: false,
  130. on_win_multiply: false,
  131. current_run: 0,
  132. current_bet: 0,
  133. current_streak: 0
  134. };
  135. params.current_bet = params.bet;
  136. autobet_index = false;
  137. auto_bet(params);
  138. return;
  139. }
  140. })
  141. }, autobet_speed);
  142. }
  143. function addRows($table, rows, autobet_i) {
  144. var table_selector = $table.selector,
  145. td_tmpl = '<td class="tabs__table-column tabs__table-cell"',
  146. $tableod, $tr, top, new_top, count = 0,
  147. need_placeholder = false,
  148. trhtml = '';
  149. if (rows.error) {
  150. //alert(rows.message);
  151. return;
  152. }
  153. console.log('new rows!');
  154. $table.stop(true);
  155. $tableod = $table.clone();
  156. if ($tableod.find('tr.placeholder').length) {
  157. need_placeholder = true;
  158. $tableod.find('tr.placeholder').remove();
  159. console.log(need_placeholder ? 'Has Placeholder' : 'No Placeholder');
  160. }
  161. top = parseInt($table.css('top'));
  162. if (isNaN(top)) top = 0;
  163. $.each(rows, function (i, data) {
  164. if (data.error) {
  165. //alert(data.message);
  166. return;
  167. }
  168. if (count == 30 || (!autobet_i && data.bet_id && $.inArray(data.bet_id, bet_ids) !== -1)) return;
  169. need_placeholder = !need_placeholder;
  170. count++;
  171. bet_ids.push(data.bet_id);
  172. var value = data.winnings.toString(),
  173. multiplier = data.multiplier.toString();
  174. if (value.indexOf('.') !== -1) {
  175. value += '00000000';
  176. }
  177. value = value.substr(0, value.indexOf('.') + 9);
  178. value = value.indexOf('-') != -1 ? value.substr(1) : value;
  179. value = (data.result == "1" ? '+' : '-') + value;
  180. if (multiplier.indexOf('.') == -1) {
  181. multiplier += '.00000';
  182. } else {
  183. multiplier += '00000';
  184. multiplier = multiplier.substr(0, multiplier.indexOf('.') + 6);
  185. }
  186. trhtml += '<tr class="tabs__table-row bet-' + data.bet_id + '">' + td_tmpl + '<a class="action-fancybox" href="/modals/bet.html?id=' + data.bet_id + '">' + data.bet_id + '</a>' + (autobet_i ? ' (' + autobet_i+ ')' : '') + '</td>' + td_tmpl + '>' + data.username + '</td>' + td_tmpl + '>' + data.elapsed + '</td>' + td_tmpl+ '>' + data.bet + '</td>' + td_tmpl + '>' + multiplier + '</td>' + td_tmpl + '>' + data.game + '</td>' + td_tmpl+ '>' + data.roll + '</td>' + td_tmpl + ' style="color: ' + (data.result == "1" ? 'green' : 'red') + '">' + value+ '</td>' + '</tr>';
  187. });
  188. $tableod.prepend(trhtml);
  189. if (need_placeholder) {
  190. $tableod.find('tr:first').clone().addClass('placeholder').prependTo($tableod);
  191. top = -(count * 34) - 34;
  192. new_top = -34;
  193. } else {
  194. top = -(count * 34);
  195. new_top = 0;
  196. }
  197. $tableod.css('top', top);
  198. $tableod.find('tr:gt(30)').addClass('removing');
  199. $table.replaceWith($tableod);
  200. $tableod.stop().animate({
  201. 'top': new_top
  202. });
  203. $tableod.find('tr.removing').animate({
  204. opacity: 0
  205. }, function () {
  206. $(this).remove();
  207. });
  208. console.log($tableod.find('tr:first').is('.placeholder') ? 'Has Placeholder' : 'No Placeholder');
  209. }
  210. function updateYourBets() {
  211. $.ajax({
  212. url: '/api/get_bets.php',
  213. data: {
  214. id: parseInt($('#user-id').text()),
  215. count: '30',
  216. bet_id: lastYourBet
  217. },
  218. type: 'post',
  219. dataType: 'json',
  220. success: function (data) {
  221. if (!data || data.length === 0) return;
  222. lastYourBet = data[0].bet_id;
  223. addRows($('#table-1'), data);
  224. }
  225. });
  226. }
  227. function updateBigBets(callback) {
  228. $.ajax({
  229. url: '/api/get_bets.php',
  230. data: {
  231. value: '.5',
  232. count: '30',
  233. bet_id: lastBigBet
  234. },
  235. type: 'post',
  236. dataType: 'json',
  237. success: function (data) {
  238. if (!data || data.length === 0) return;
  239. lastBigBet = data[0].bet_id;
  240. addRows($('#table-3'), data);
  241. },
  242. complete: function () {
  243. if (typeof callback == 'function') callback();
  244. }
  245. });
  246. }
  247. function updateAllBets(callback, first) {
  248. if (first) {
  249. $.ajax({
  250. url: '/api/get_bets.php',
  251. data: {
  252. count: '30',
  253. bet_id: lastAllBet
  254. },
  255. type: 'post',
  256. dataType: 'json',
  257. success: function (data) {
  258. if (!data || data.length === 0) return;
  259. lastAllBet = data[0].bet_id;
  260. addRows($('#table-2'), data.reverse());
  261. },
  262. complete: callback
  263. });
  264. return;
  265. }
  266. var did_one = false,
  267. checker = function () {
  268. if (did_one && typeof callback == 'function') callback();
  269. did_one = true;
  270. };
  271. $.ajax({
  272. url: '/api/get_bets.php',
  273. data: {
  274. count: '30',
  275. bet_id: lastAllBet,
  276. value: '0.1'
  277. },
  278. type: 'post',
  279. dataType: 'json',
  280. success: function (data) {
  281. if (!data || data.length === 0) return;
  282. lastAllBet = data[0].bet_id;
  283. addRows($('#table-2'), data.reverse());
  284. },
  285. complete: checker
  286. });
  287. $.ajax({
  288. url: '/api/get_bets.php',
  289. data: {
  290. count: '1',
  291. bet_id: lastAllBet,
  292. less: '0.1'
  293. },
  294. type: 'post',
  295. dataType: 'json',
  296. success: function (data) {
  297. if (!data || data.length === 0) return;
  298. lastAllBet = data[0].bet_id;
  299. addRows($('#table-2'), data.reverse());
  300. },
  301. complete: checker
  302. });
  303. }
  304. function updateBalance(checker) {
  305. $.ajax({
  306. url: '/api/get_balance.php',
  307. dataType: 'json',
  308. success: function (data) {
  309. $('#balance').val(data.balance);
  310. $('#balance-value').text(data.balance);
  311. },
  312. complete: checker
  313. });
  314. }
  315. function update(callback) {
  316. var did_count = 0,
  317. checked = function () {
  318. did_count++;
  319. if (did_count == 4 && typeof callback == 'function') callback();
  320. }
  321. updateStats(checked);
  322. updateAllBets(checked, first_load);
  323. updateBigBets(checked);
  324. updateBalance(checked);
  325. first_load = false;
  326. }
  327. function updateStats(checked) {
  328. $.ajax({
  329. url: '/api/stats.php',
  330. type: 'get',
  331. dataType: 'json',
  332. success: function (data) {
  333. $('#stats-wagered').text(data.wagered);
  334. $('#stats-bets').text(data.bets);
  335. $('#stats-bank').text(data.bank);
  336. },
  337. complete: checked
  338. })
  339. }
  340. params = {
  341. odds: 75.25,
  342. type: 0,
  343. bet: 0.00000002,
  344. total_runs: 4,
  345. on_loss_return: false,
  346. on_loss_multiply: 3,
  347. on_win_return: true,
  348. on_win_multiply: false,
  349. current_run: 0,
  350. current_bet: 0
  351. };
  352. params.current_bet = params.bet;
  353. autobet_halt = false;
  354. autobet_index = 0;
  355. auto_bet(params);

comments powered by Disqus