Pause on leave and continue the remaining time when joining back on fly

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

wrymain

Member
Feb 20, 2025
37
0
6
So i made a skript about an item that gives the player the ability to fly for five minutes if it's righ clicked. but it has flaws, that if the player leave while flying and join back, it'll make the player be able to fly even after the remaining time is 0. and if leave when on the ground, it will remove the ability to fly. so how do i fix it? and also idk why command /flyitem if arg-1 not set: give player {flyitem} doesnt work.


Python:
command /flyitem <offline player>:
    permission: op
    permission message: &4You do not have access to that command.
    trigger:
        if arg-1 is not set:
            set {_p} to player
            give {_p} {opitems::FlyFeather}
        else:
            set {_p} to "%arg-1%" parsed as player
            give {_p} {opitems::FlyFeather}

on rightclick with a feather:
    if name of item is "&f&lFly Item":
        if lore of item contains "&8Activate &efly mode &8for &c5 minutes":
            if player's fly state is false:
                set {seconds::%player%.flytime} to 59
                set {minutes::%player%.flytime} to 4
                set name of item to "&oIn Flight!"
                set player's fly state to true
                make player fly
                loop 5 times:
                    loop 60 times:
                        send action bar "&8Flight Enabled:&4&l %{minutes::%player%.flytime}%m %{seconds::%player%.flytime}%s &r&8left" to player
                        wait 1 second
                        remove 1 from {seconds::%player%.flytime}
                        if {seconds::%player%.flytime} = 0:
                            set {seconds::%player%.flytime} to 59
                    remove 1 from {minutes::%player%.flytime}
                    if {minutes::%player%.flytime} = -1:
                        loop all items in player's inventory:
                            name of loop-item is "&oIn Flight!"
                            set name of loop-item to "&cExpired!"
                make player stop flying
                set player's fly state to false
            else:
                send "&cYou are already flying!" to player
                stop
 
I think there is better way to do that but i would need the whole code, if you are still interested contact me on discord: danrub