Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function(_n, data, ut) {
- //pobranie localStorage
- let dane = {};
- if (localStorage.getItem("adiherosybrutus")) {
- dane = JSON.parse(localStorage.getItem("adiherosybrutus"));
- }
- if (dane) {
- for (let i in dane) {
- if (ut() > dane[i].time) {
- delete dane[i];
- }
- }
- }
- //getTime
- function getTime() {
- let czas = new Date(),
- godzina = czas.getHours(),
- sekunda = czas.getSeconds(),
- minuta = czas.getMinutes();
- if (godzina < 10) godzina = `0${godzina}`;
- if (minuta < 10) minuta = `0${minuta}`;
- if (sekunda < 10) sekunda = `0${sekunda}`;
- return `${godzina}:${minuta}:${sekunda}`;
- }
- //funkcja wysłania na diskordzika
- function sendToDiscord(lvl, nick, icon, x, y) {
- $.ajax({
- url: data[0],
- type: 'POST',
- data: JSON.stringify({
- 'embeds': [{
- 'title': `${hero.nick} · ${hero.lvl}${hero.prof} znalazł herosa/tytana!`,
- 'color': ((Math.floor(lvl / 300 * 221) + 32) * 256 + (Math.floor(lvl / 300 * (-112)) + 120)) * 256 + Math.floor(lvl / 300 * (-204)) + 217,
- 'description': `${nick} (${lvl}lvl)\n${map.name} (${x}, ${y})\n${getTime()}\n${g.worldname[0].toUpperCase() + g.worldname.substring(1)}`,
- 'thumbnail': {
- 'url': `http://berufs.margonem.pl${icon}`
- }
- }],
- content: `@here Znaleźli mnie na mapie ${map.name}`,
- username: nick,
- avatar_url: `http://berufs.margonem.pl${icon}`
- }),
- contentType: 'application/json; charset=utf-8',
- dataType: 'json',
- async: false
- });
- }
- //funkcja sprawdzajaca czy dane id z ts istnieje
- function checkHerosData(id) {
- if (dane[id]) {
- if (ut() > dane[id].time) {
- delete dane[id];
- return true;
- } else {
- return false;
- }
- }
- return true;
- }
- newNpc = function(e) {
- _n.apply(this, arguments);
- for (let i in e) {
- let heros = e[i];
- if (map.mode != 5 && heros.wt > 79 && g.worldname != "experimental" && checkHerosData(heros.id)) {
- dane[heros.id] = {
- time: ut() + (10 * 60)
- }
- localStorage.setItem("adiherosybrutus", JSON.stringify(dane));
- sendToDiscord(heros.lvl, heros.nick, heros.icon, heros.x, heros.y);
- break;
- }
- }
- }
- })(newNpc, ["https://discordapp.com/api/webhooks/602793798480953374/MoWCx6JLJvo-xyQdw76IMv3kZcuGIKRfGQ5WOBkmOS3JF9nPeMd9OpYul14_IjhJXN4t"], unix_time)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement