Limit Mob Spawns Per Player.

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

idyllego

Member
Mar 6, 2017
1
0
0
I had a look at some previous posts, and the format I'm expected to post for help. And it seems some people instantly dismiss some people asking for help, because their post didn't meet the format, even though the request was very clearly laid out. I am not currently having any errors, my code works (to my knowledge) and so am finding it hard to fit in with the forums strict request for help format, but Ill try my best.

I was wondering if anyone more skilled in the art of Skript, could just take a look over my code, and suggest some improvements, places where I could save on efficient, or if there are simply just some better ways of doing things. This is my first attempt at using Skript :emoji_slight_smile: cheers

Code:
on spawn:
    if "%spawn reason%" is "NATURAL":
        set {_p} to 0
        loop all players in radius 126 of the event-entity:
            add 1 to {_p}
            set {target} to loop-player
            set {_n} to 0
            if {_p} is greater than 0:
                loop monsters in radius 126 around {target}:
                    add 1 to {_n}
                loop ghasts in radius 126 around {target}:
                    add 1 to {_n}
                loop magma cubes in radius 126 around {target}:
                    add 1 to {_n}
                loop slimes in radius 126 around {target}:
                    add 1 to {_n}
                if {_n} is greater than 70:
                    cancel event

I am using Skellet, and Am on all the current latest versions, with the server running 1.11.2.

Other information

For a while I've been looking for a way to make the mob limit per player, and not per loaded chunks or the entire world.

This was to stop things like mob farms effectiveness reducing massively when other players have a lot of mobs spawned around them.

The goal was to give everyone a limit of 70 mobs that can spawn around them at any one time. so I can increase the server's mob limits to a much higher number (say 400) This means that when there's only one player on the world, he doesn't get over-run by 400 mobs(only gets 70), but when there's 3-4 players, they still each 70 mobs spawning around them, so they can run their mob farms without having to worry about everyone else.

I've seen lots of people complain about the mob spawning stuff on different servers, yet couldn't find a way to fix it. Then I found skript.

So this is what I've got so far. and it seems to be working great. I wondering if you guys have any suggestions to improve it/make it more efficient. Or notice any future bugs that crop up. Also, for anyone who is needing the same thing feel free to use this.
 
Last edited:
Status
Not open for further replies.