Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

LiquidBounce Forum

  1. Home
  2. ScriptAPI
  3. Help a script-noob now

Help a script-noob now

Scheduled Pinned Locked Moved ScriptAPI
7 Posts 5 Posters 394 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • bestnubB Offline
    bestnubB Offline
    bestnub
    wrote on last edited by bestnub
    #1

    I tried to recreate my BotCheck in Script, but it gives just lots of errors and wont work undefined

    /// api_version=2
    var script = registerScript({
        name: "RadiusAntiBot",
        version: "1.0",
        authors: ["BestNub"]
    });
    
    var EntityPlayer = Java.type("net.minecraft.entity.player.EntityPlayer");
    var EventState = Java.type("net.ccbluex.liquidbounce.event.EventState");
    var notAlwaysInRadius = [];
    
    script.registerModule({
        name: "RadiusAntiBot",
        description: "Removes bots always in radius.",
        category: "Misc",
        settings: {
            radius: Setting.float({
                name: "Radius",
                default: 20.0,
                min: 10.0,
                max: 100.0
            }),
            removeRadius: Setting.float({
                name: "RemoveRadius",
                default: 10.0,
                min: 0.0,
                max: 10.0
            }),
            chatLog: Setting.boolean({
                name: "ChatLog",
                default: false
            }),
        }
    }, function (module) {
        module.on("enable", function () {
            notAlwaysInRadius = [];
        });
    
        module.on("world", function (event) {
            notAlwaysInRadius = [];
        });
    
        module.on("update", function () {
            var entityList = mc.theWorld.getLoadedEntityList();
            var playerList = [];
    
            for (var i in entityList)
                if (entityList[i] instanceof EntityPlayer)
                    playerList.push(entityList[i]);
    
            for (var i in playerList) {
                var currentEntity = playerList[i];
    
                if (notAlwaysInRadius.indexOf(currentEntity.getEntityId()) == -1 && mc.thePlayer.getDistanceToEntity(currentEntity) > module.settings.radius.get()) {
                    notAlwaysInRadius.push(currentEntity.getEntityId());
                    if (module.settings.chatLog.get())
                        Chat.print("[RadiusAntiBot] " + currentEntity.getName() + " is a Player");
                }
    
                if (currentEntity != mc.thePlayer && notAlwaysInRadius.indexOf(currentEntity.getEntityId()) == -1 && mc.thePlayer.getDistanceToEntity(currentEntity) < module.settings.removeRadius.get()) {
                    mc.theWorld.removeEntity(currentEntity);
                    if (module.settings.chatLog.get())
                        Chat.print("[RadiusAntiBot] Removed " + currentEntity.getName());
                }
            }
        });
    });
    

    Edit: Thx for the help. Fixed it and remove only Players added. Works great on JartexNetwork

    1 Reply Last reply
    0
    • CzechHekC Offline
      CzechHekC Offline
      CzechHek
      wrote on last edited by
      #2

      why don't you read the errors and fix them lololololo

      replace includes with indexOf

      bestnubB 1 Reply Last reply
      0
      • CzechHekC CzechHek

        why don't you read the errors and fix them lololololo

        replace includes with indexOf

        bestnubB Offline
        bestnubB Offline
        bestnub
        wrote on last edited by
        #3

        @CzechHek can you explain, how i should use indexOf

        Senk JuS 1 Reply Last reply
        0
        • notautismatallN Offline
          notautismatallN Offline
          notautismatall
          wrote on last edited by
          #4

          I don't understand how does it work 😕

          1 Reply Last reply
          0
          • bestnubB bestnub

            @CzechHek can you explain, how i should use indexOf

            Senk JuS Offline
            Senk JuS Offline
            Senk Ju
            Admin
            wrote on last edited by
            #5

            @bestnub JavaScript ES5 does not support Array.includes(). If you want to use it, either add a polyfill like this one or setup a Babel environment to compile modern JavaScript down to ES5.

            bestnubB 1 Reply Last reply
            0
            • 6Sence6 Offline
              6Sence6 Offline
              6Sence
              wrote on last edited by
              #6

              indexOf is similar to includes, you just have to use it cause java only supports ES5.

              1 Reply Last reply
              0
              • Senk JuS Senk Ju

                @bestnub JavaScript ES5 does not support Array.includes(). If you want to use it, either add a polyfill like this one or setup a Babel environment to compile modern JavaScript down to ES5.

                bestnubB Offline
                bestnubB Offline
                bestnub
                wrote on last edited by
                #7

                @Senk-Ju thx

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                About
                • Terms of Service
                • Privacy Policy
                • Status
                • Contact Us
                Downloads
                • Releases
                • Source code
                • License
                Docs
                • Tutorials
                • CustomHUD
                • AutoSettings
                • ScriptAPI
                Community
                • Forum
                • Guilded
                • YouTube
                • Twitter
                • D.Tube
                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups