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