Problem with entity

  • 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.

Mikioul

New Member
Mar 20, 2017
7
0
0
Hello i made a skript of a pet, and i have a problem :

I have a part with armorstand, and all work perfectly

And i have a part with animal but only pig work, all the rest doesn't work ..
The animal spawn, follow me, but not remove (only the pig work)

The problem is the remove of animals !

i dont know why :/

code_language.skript:
function FamiliersMenu(p: player, page: text):
    if {_page} is "2":
        open virtual chest inventory with size 6 named "{@gui_prefix} &7» &fMenu &f&l2" to {_p}
        wait 2 tick
        format gui slot 1 of {_p} with player head with custom nbt "{@Pig}" to run:
            if {_p} has permission "familier.spawn.pig" or "familier.spawn.*" or "familier.*":
                FamiliersGetAnimals(player, "pig")
                set {familier.%{_p}%} to "pig"
                close {_p}'s inventory 
            else:
                show an action bar from "{@NoPermission}" to {_p}
        format gui slot 2 of {_p} with player head with custom nbt "{@Cow}" to run:
            if {_p} has permission "familier.spawn.cow" or "familier.spawn.*" or "familier.*":
                FamiliersGetAnimals(player, "cow")
                set {familier.%{_p}%} to "cow"
                close {_p}'s inventory 
            else:
                show an action bar from "{@NoPermission}" to {_p}
        format gui slot 3 of {_p} with player head with custom nbt "{@Sheep}" to run:
            if {_p} has permission "familier.spawn.sheep" or "familier.spawn.*" or "familier.*":
                FamiliersGetAnimals(player, "sheep")
                set {familier.%{_p}%} to "sheep"
                close {_p}'s inventory 
            else:
                show an action bar from "{@NoPermission}" to {_p}
        format gui slot 4 of {_p} with player head with custom nbt "{@Ocelot}" to run:
            if {_p} has permission "familier.spawn.ocelot" or "familier.spawn.*" or "familier.*":
                FamiliersGetAnimals(player, "ocelot")
                set {familier.%{_p}%} to "ocelot"
                close {_p}'s inventory 
            else:
                show an action bar from "{@NoPermission}" to {_p}
        format gui slot 5 of {_p} with player head with custom nbt "{@Chicken}" to run:
            if {_p} has permission "familier.spawn.chicken" or "familier.spawn.*" or "familier.*":
                FamiliersGetAnimals(player, "chicken")
                set {familier.%{_p}%} to "chicken"
                close {_p}'s inventory 
            else:
                show an action bar from "{@NoPermission}" to {_p}
        format gui slot 6 of {_p} with player head with custom nbt "{@Mushroom Cow}" to run:
            if {_p} has permission "familier.spawn.mushroom_cow" or "familier.spawn.*" or "familier.*":
                FamiliersGetAnimals(player, "mushroom_cow")
                set {familier.%{_p}%} to "mushroom_cow"
                close {_p}'s inventory 
            else:
                show an action bar from "{@NoPermission}" to {_p}
      
        format gui slot 48 of {_p} with player head with custom nbt "{@Arrow Left}" to run:
            wait 1 ticks
            close {_p}'s inventory
            FamiliersMenu(player, "1")
    format gui slot 49 of {_p} with barrier named "&4» &cSupprimer le familier" to run:
        delete {familier.%{_p}%}
        kill {fam.%{_p}%}





function FamiliersGetAnimals(p: player, e: text):
    send "%{fam.%{_p}%}%" to {_p}
    kill {fam.%{_p}%}
    wait 2 ticks
    set {_l} to location of {_p}'s head
    remove 0.5 from y coord of {_l}
    set {_l} to location .7 right of {_l}
    if {_e} is "pig":
        spawn a pig at {_l}
    if {_e} is "cow":
        spawn a cow at {_l}
    if {_e} is "sheep":
        spawn a sheep at {_l}
    if {_e} is "ocelot":
        spawn a ocelot at {_l}
    if {_e} is "chicken":
        spawn a chicken at {_l}
    if {_e} is "mushroom_cow":
        spawn a mooshroom at {_l}

    set {fam.%{_p}%} to spawned entity
    send "%spawned entity%" to {_p}
    send "%{fam.%{_p}%}%" to {_p}
    set {protect.%spawned entity%} to true
    if {@FamiliersNameSet} is true:
        add "{NoGravity:1b,Invulnerable:1,CustomNameVisible:1,CustomName:{@FamiliersName},Age:-25000,IsBaby:1,Size:0,NoAI:1}" to nbt of {fam.%{_p}%}
    if {@FamiliersNameSet} is false:
        add "{NoGravity:1b,Invulnerable:1,Age:-25000,IsBaby:1,Size:0,NoAI:1}" to nbt of {fam.%{_p}%}




on any move:
    if {@FamiliersPos} is "right":
        set {_l} to location of player's head
        remove 0.5 from y coord of {_l}
        set {_l} to location .7 right of {_l}
        if {@FamiliersAnimationSneak} is true:
            if player is sneaking:
                if {familier.%player%} is set: 
                    add "{Pose:{Body:[20f,0f,0f]}}" to nbt of {fam.%player%}
                    teleport {fam.%player%} to {_l}
                    wait 0.5 ticks
            else:
                if {familier.%player%} is set:
                    teleport {fam.%player%} to {_l}
                    add "{Pose:{Body:[0f,0f,0f]}}" to nbt of {fam.%player%}
                    wait 1 ticks
                    stop
    if {@FamiliersPos} is "left":
        set {_l} to location of player's head
        remove 0.5 from y coord of {_l}
        set {_l} to location .7 left of {_l}
        if {@FamiliersAnimationSneak} is true:
            if player is sneaking:
                if {familier.%player%} is set:
                    add "{Pose:{Body:[20f,0f,0f]}}" to nbt of {fam.%player%}
                    teleport {fam.%player%} to {_l}
                    wait 0.5 ticks
            else:
                if {familier.%player%} is set:
                    teleport {fam.%player%} to {_l}
                    add "{Pose:{Body:[0f,0f,0f]}}" to nbt of {fam.%player%}
                    wait 1 ticks
                    stop
 
Last edited:
Status
Not open for further replies.