My First Multi-Player Radar

Scans and logs multiple players simultaneously using engine components

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         My First Multi-Player Radar
// @namespace    http://tampermonkey.net
// @version      1.1
// @description  Scans and logs multiple players simultaneously using engine components
// @author       You
// @match        *://*.bloxd.io/*
// @match        *://*.bloxdhop.io/*
// @match        *://*://*
// @run-at       document-body
// @grant        none
// ==/UserScript==


(function() {
    'use strict';

    let savedEngine = null;

    // 1. THE ANTENNA: Hook into the game's loading files to grab the engine
    Object.defineProperty(Function.prototype, 'call', {
        enumerable: false,
        configurable: true,
        writable: true,
        value: function (thisArg, ...args) {
            const core = args[0];
            // If we catch a piece of code containing 'entities' and 'bloxd', save it!
            if (core && core.entities && core.bloxd) {
                savedEngine = core;
                console.log("Successfully hooked into the Bloxd engine!");
            }
            return Function.prototype.call.apply(this, [thisArg, ...args]);
        }
    });

    // 2. THE MULTI-TARGET MONITOR LOOP
    setInterval(() => {
        if (!savedEngine) return;

        // Fetch your own position (You are always ID 1)
        let pos = savedEngine.entities.getState(1, "position")?.position;
        if (!pos) return;

        // DYNAMIC SCANNER: Extract a fresh list of EVERY entity currently loaded around you
        let allPlayerIds = Object.keys(savedEngine.entities.components.position);

        // This loop automatically repeats your distance math for every single active ID found
        allPlayerIds.forEach(id => {
            if (id == "1") return; // Skip yourself to prevent self-targeting

            // Fetch the current loop player's coordinate array dynamically
            let enemypos = savedEngine.entities.getState(id, "position")?.position;
            if (!enemypos) return;

            // FIXED VECTOR MATH: Subtracting individual elements keeps the calculations stable
            let dx = pos[0] - enemypos[0];
            let dy = pos[1] - enemypos[1];
            let dz = pos[2] - enemypos[2];
            let distance = Math.sqrt(dx*dx + dy*dy + dz*dz);

            // Execute the action block if this specific player is within range
            if (distance <= 6.0) {
                console.log(`attack ID: ${id} | Distance: ${distance.toFixed(2)}`);
            }
        });
    }, 100);

})();