Pets crashing the server

  • 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.
Mar 18, 2021
16
0
1
25
so i edited a pet skript and it now crashes the server
i think its the while spawned entity is alive:
but im not sure pls help me

Code:
command /Pet [<text>]:
    permission: command.pet
    permission message: [&c&l!&f] You don't have permission
    aliases: /pets
    trigger:
        if {onpet.%player%} does not exist:
            set {onpet.%player%} to false
        if arg 1 is not "hapoo" or "cash" or "enderno" or "remove" or "reset" or "delete":
            send "[&d&l!&f] /Pets"
            stop
        if arg 1 is "hapoo":
            if player has permission "blumode.pet.hapoo":
                if {onpet.%player%} is false:
                    spawn 1 wolf 0 meters above player
                    set the display name of the spawned entity to "&a%player%&f's hapoo"
                    set {onpet.%player%} to true
                    set {pet.%player%} to "hapoo"
                    while spawned entity is alive:
                        loop all entities:
                            if loop-entity is a wolf:
                                if name of loop-entity is "&a%player%&f's hapoo":
                                    if distance between player and loop-entity is less than 15:
                                        if distance between player and loop-entity is bigger than 3:
                                            make loop-entity pathfind to location of player with speed 1.3
                                        else if distance between player and loop-entity is bigger than 15:
                                            teleport loop-entity to position of player
                                        if world of player is not world of loop-entity:
                                            teleport loop-entity to position of player
                    wait 1 tick
        if arg 1 is "endarno":
            if player has permission "blumode.pet.endarno":
                if {onpet.%player%} is false:
                    spawn 1 enderman 0 meters above player
                    set the display name of the spawned entity to "&a%player%&f's endarno"
                    set {onpet.%player%} to true
                    set {pet.%player%} to "hapoo"
                    while spawned entity is alive:
                        loop all entities:
                            if loop-entity is a enderman:
                                if name of loop-entity is "&a%player%&f's endarno":
                                    if distance between player and loop-entity is less than 15:
                                        if distance between player and loop-entity is bigger than 3:
                                            make loop-entity pathfind to location of player with speed 1.3
                                        else if distance between player and loop-entity is bigger than 15:
                                            teleport loop-entity to position of player
                                        if world of player is not world of loop-entity:
                                            teleport loop-entity to position of player
                    wait 1 tick
        if arg 1 is "cash":
            if player has permission "blumode.pet.hapoo":
                if {onpet.%player%} is false:
                    spawn 1 cat 0 meters above player
                    set the display name of the spawned entity to "&a%player%&f's cash"
                    set {onpet.%player%} to true
                    set {pet.%player%} to "hapoo"
                    while spawned entity is alive:
                        loop all entities:
                            if loop-entity is a cat:
                                if name of loop-entity is "&a%player%&f's cash":
                                    if distance between player and loop-entity is less than 15:
                                        if distance between player and loop-entity is bigger than 3:
                                            make loop-entity pathfind to location of player with speed 1.3
                                        else if distance between player and loop-entity is bigger than 15:
                                            teleport loop-entity to position of player
                                        if world of player is not world of loop-entity:
                                            teleport loop-entity to position of player
                    wait 1 tick
        if arg-1 is "remove" or "reset" or "delete":
            if player has permission "blumode.pet.remove":
                if {onpet.%player%} is true:
                    kill {pet.%player%}
                    set {onpet.%player%} to false
                else:
                    send "[&d&l!&f] Your pet is already spawned"

on damage of entity:
    loop all players:
        if victim's name is "&a%loop-player%&f's pet":
            cancel event
on damage of player:
    loop all players:
        if attacker's name is "&a%loop-player%&f's pet":
            cancel event
command /glitch:
    permission: command.glitch
    permission message: [&c&l!&f] You don't have permission
    trigger:
        set {onpet.%player%} to false
on join:
    wait 3 ticks
    if {onpet.%player%} is true:
        set {onpet.%player%} to false
        loop all entities:
            if loop-entity's name is "&a%player%&f's pet":
            delete loop-entity
    wait 1 second
    if {pet.%player%} is "hapoo":
        make player execute command "/pet hapoo"
    if {pet.%player%} is "endarno":
        make player execute command "/pet endarno"
    if {pet.%player%} is "cash":
        make player execute command "/pet cash"
    else:   
        stop
 
Status
Not open for further replies.