Solved Auto regenerate Mana

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

Cold

Member
May 1, 2022
29
0
1
Hello, so I want to make it so every 1 second it gives 3 mana to player's mana.
And it works perfectly right now but I want to make some changes that makes it better.

So instead of saying "if {...} is less than 100: do stuff" I want to make so it checks how much mana is the players max and then if the player's current mana is below the player's max then do stuff.

Code:
every 23 ticks:
loop all players:
if {mana.%loop-player's uuid%} is less than 100:
add 3 to {mana.%loop-player's uuid%}
 
Hello, so I want to make it so every 1 second it gives 3 mana to player's mana.
And it works perfectly right now but I want to make some changes that makes it better.

So instead of saying "if {...} is less than 100: do stuff" I want to make so it checks how much mana is the players max and then if the player's current mana is below the player's max then do stuff.

Code:
every 23 ticks:
loop all players:
if {mana.%loop-player's uuid%} is less than 100:
add 3 to {mana.%loop-player's uuid%}
If you want mana just for a minigame then when they join the game do a while loop, if it just in a specific world then make the while loop using on world chance and if that is for everyone in the server then use on join with a while loop.
Code:
On join:
    While player is online:
        #mana code
        Wait 23 tick
 
Thanks but I want to make it so let’s say you max mana is 100 when you join. Then you take in some armor which gives +25 mana to your max mana. How do I make that? (When I mean +25 to max mana it adds 25 to the maximum mana you can have before it stops giving you mana automatically)
 
Thanks but I want to make it so let’s say you max mana is 100 when you join. Then you take in some armor which gives +25 mana to your max mana. How do I make that? (When I mean +25 to max mana it adds 25 to the maximum mana you can have before it stops giving you mana automatically)
I try and help you when I get home
 
Thanks a lot!
[doublepost=1652382906,1652382206][/doublepost]Wait quick how do you do that like so when you send code here on the forums it is in a like cool box thing
 
Thanks a lot!
[doublepost=1652382906,1652382206][/doublepost]Wait quick how do you do that like so when you send code here on the forums it is in a like cool box thing
Click the + icon (insert) then choose code
 
Thanks but I want to make it so let’s say you max mana is 100 when you join. Then you take in some armor which gives +25 mana to your max mana. How do I make that? (When I mean +25 to max mana it adds 25 to the maximum mana you can have before it stops giving you mana automatically)

I change the variable for a list because you can do more stuff with list like for example you can reset everyone mana and max mana in the server with this line on code
set {mana::*} to 0
or you can set everyone max mana to an infinite number
set {max_mana::*} to 9999999
Code:
on join:
    set {mana::%player's uuid%} to 100
    if {max_mana::%player's uuid%} is not set:
        set {max_mana::%player's uuid%} to 100
        while player is online:
            if {mana::%player's uuid%} is less than {max_mana::%player's uuid%}:
                add 3 to {mana::%player's uuid%}
                if {mana::%player's uuid%} is more than {max_mana::%player's uuid%}:
                    set {mana::%player's uuid%} to {max_mana::%player's uuid%}
            wait 27 tick

#needs sk bee for scoreboard
on join:
    while player is online:
        set title of player's scoreboard to "&eMy Server"
        set line 5 of player's scoreboard to "&a " #set a random color code and a space to set the line to a blank space. PS: You need to set different color codes or add more spaces for each blank line, there can't be 2 lines with the same exact name.
        set line 4 of player's scoreboard to "&fPlayer: %player%"
        set line 3 of player's scoreboard to "&fMax Mana: %{max_mana::%player's uuid%}%"
        set line 2 of player's scoreboard to "&fCurrent Mana: %{mana::%player's uuid%}%"
        set line 1 of player's scoreboard to "&7Server Ip:"
        wait 1 second #for faster refresh rate change this time example wait 3 tick
 
on death of a player:
    set {mana::%victim's uuid%} to 100
    set {max_mana::%victim's uuid%} to 100


#need sk bee
on player armor change:
    if new armor item is iron helmet:
        set {max_mana::%player's uuid%} to {max_mana::%player's uuid%} + 25
        message "&l&aYou gain +25 mana for wearing iron helmet. Max mana %{max_mana::%player's uuid%}%" to player
    if old armor item is iron helmet:
        set {max_mana::%player's uuid%} to {max_mana::%player's uuid%} - 25
        message "&l&cYou lost +25 mana for wearing iron helmet. Max mana %{max_mana::%player's uuid%}%" to player
    if {mana::%player's uuid%} is more than {max_mana::%player's uuid%}:
        set {mana::%player's uuid%} to {max_mana::%player's uuid%}

command /test:
    trigger:
        set {mana::%player's uuid%} to 0
 
Status
Not open for further replies.