Sprint Stamina

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

Zoltam

Member
May 29, 2020
1
0
0
Category: Stamina

Suggested name: Stamina

Spigot/Skript Version: I don't mind which version do you write this

What I want:
I want a skript that adds stamina to action bar like: Stamina 67/100 and you lose stamina when you sprint and when stamina is 0 it stops sprinting. And when you are not sprinting it restores it

Ideas for commands: no need for commands

Ideas for permissions: stamina.infinite which gives you infinite stamina

When I'd like it by: A reasonable time maybe?
 
Code:
variables:
    {stamina::%player%} = 100
on player sprint toggle:
    if {stamina::%player%} > 0:
        loop {stamina::%player%} times:
            wait a second
            if player is sprinting:
                if {stamina::%player%} > 0:
                    reduce {stamina::%player%} by 1
                else:
                    cancel event
                    stop trigger
                    send "&cYour stamina is too low to run!" to player
    else:
        cancel event
        stop trigger
        send "&cYour stamina is too low to run!" to player
every 3 seconds:
    loop all players:
        if loop-player is not sprinting:
            if {stamina::%player%} < 100
                increase {stamina::%player%} by 1