Pets

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

TullyMastully

Member
Aug 9, 2017
38
0
0
34
Hello,
I'm currently making a pet skript,
and I wanted to know how to make it so if a player is on a horse for example, and click on shift or something else to not ride the horse, it will despawn the horse.

Thanks in advance,
Tully.
 
So you're trying to make an item that, when clicked, makes you ride a horse or something like that, and you want that when you stop riding it, it disappears?

Using the UUID from the nbt of the horse, setting that to a variable and checking, on a radius aroud the player, if any entity has said UUID when you dismount will work.

The player teleports when he dismounts, so you can use that event to check if they dismounted the horse. If the UUID variable is set, then delete the entity that has said UUID.

You should also cancel inventory clicks while mounted as they could remove the saddle

code_language.skript:
spawn adult horse 1 meter above the player
make player ride last spawned adult horse
set {_text} to "%nbt of last spawned adult horse%"
set {_uuid::*} to {_text} split at "UUIDMost"
set {_uuid2::*} to {_uuid::2} split at ","
set {-ridinghorse.%player%} to {_uuid2::1}
add "{Variant:%{_variant}%,CustomName:%{_nombre}%,CustomNameVisible:1,PersistenceRequired:0b,Attributes:[{Name:""generic.maxHealth"",Base:20},{Name:""generic.movementSpeed"",Base:%{_speed}%f},{Name:""horse.jumpStrength"",Base:%{_jump}%f}],Invulnerable:1,SaddleItem:{id:saddle,Count:1},ArmorItem:{id:""minecraft:%{_armadura}%"",Count:1b,Damage:0s},Tame:1,ActiveEffects:[{Id:11,Amplifier:6,Duration:2147483647,ShowParticles:0b}]}" to nbt of player's vehicle

on teleport:
    {-ridinghorse.%player%} is set
    loop all entities in radius 20 around player:
        set {_text} to "%nbt of loop-entity%"
        set {_uuid::*} to {_text} split at "UUIDMost"
        set {_uuid2::*} to {_uuid::2} split at ","
        {_uuid2::1}=={-ridinghorse.%player%}
        delete loop-entity
        stop loop
Taken from my custom skript for horses on my server, take what you need. The UUID of the horse is stored on {-ridinghorse.%player%}
 
Status
Not open for further replies.