Spawning animals problem

  • 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 comminuty!

    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.

Bilbo

Member
Jan 26, 2017
27
0
0
29
Good Evening.

So i have this fairly simple code made yet it still does this thing that it somehow spawns more mobs than it should, might something please help me out by explaining this?

EDIT: To explain it a bit more - There are mobs spawned that dont exactly need to be there. They can spawn only if the location value is set, but the code calls for them to spawn only if a player logs in. But they still duplicate.

I am on 1.8.9 currently.

Every time the server starts it loads this:

code_language.skript:
on skript load:
    loop all entities:
        delete loop-entity

So it basically clears out all the entity's from the map.
This is the code where when a player joins a server, it spawns the animal:

code_language.skript:
on join:
    set {player.join.horse::%player%} to false
    while {player.join.horse::%player%} is false:
        set {_loc::horse} to location at random number between {@min.x} and {@max.x}, 0, random number between {@min.z} and {@max.z}
        loop blocks above {_loc::horse}:
            if loop-block and block above loop-block are air:
                if block below loop-block is grass:
                    set {_loc::horse} to location of loop-block
                    set {respawn.horse::%location of loop-block%} to location of loop-block
                    spawn 1 horse at location of {_loc::horse}
                    clear {_loc::horse}
                    delete {respawn.horse::%location of loop-block%}
                    set {player.join.horse::%player%} to true
The code above is used to spawn the specific animal on player login, since i want mobs per player count

code_language.skript:
on spawn of horse:
    set name of horse to "{@horse}"
    loop blocks in radius 2:
        if {respawn.horse::%location of loop-block%} is set:
            stop
    delete entity
Basically canceling out the mob spawn if it isn't spawned on a player login.

What might be the error here?


I have this little code used for AntiSpamboting, is it somehow bugging the the code above?

Here:
code_language.skript:
on connect:
    if {join.%player%} exists:
        set {_czas} to difference between {join.%player%} and now
        if {_czas} is less than 60 seconds:
            stop
    set {join.%player%} to now
    kick the player due to "&f&lLudzu ielogojies velreiz! &2SpamBotu parbaude!"

I am totally lost on this and i cant figure it out, could somebody please help figure why this is still making more then PER player mob count?


Thanks if anybody is willing to waste a bit of their time to help out!
[doublepost=1498559593,1498554487][/doublepost]The problem is - it is impossible to delete entities that are in unloaded chunks, thats the answer to my problem. Thank you Blueyescat... :/
 
Status
Not open for further replies.