Solved Skript Reload

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

iMinePixels

Member
Mar 12, 2024
11
0
1
22
If anyone has the time, could I get some with this skript.

I'm wanting to display how long it take's to reload the skript. I'm not exactly sure on how to do that. Ideally, it'll replace the wait 20 tick with an actual timer, then send a completed message with the time it took.

Code:
command /reloadlinks:
    trigger:
        if player has permission "reload.skripts":
            execute player command "skript reload Links.sk"
            send "&r" to all players
            send "&7Reloading our &dLinks,sk&7.%nl%&d&oᴘᴏssɪʙʟᴇ ʟᴀɢ ғᴏʀ ᴀ ғᴇᴡ sᴇᴄᴏɴᴅs." to all players
            wait 20 tick
            send "&7Reload has been &acompleted&7." to all players
            send "&r" to all players
        else:
            send "&cThis command is for staff members only."
 
Last edited:
This should work however it's not tested.

Code:
command /reloadlinks:
    permission: reload.skripts
    trigger:
        set {_StartTime} to now
        make player execute command "/sk reload links.sk"
        broadcast "&r"
        broadcast "&7Reloading our &dLinks, &e&oPOSSIBLE LAG FOR A FEW SECONDS."
        broadcast "&r"
        skript "links.sk" is loaded
        set {_EndTime} to now
        send "Skript reloaded in (%{_EndTime}% - %{_StartTime}%)" to player
 
Do note that if you make the player execute the command, it'll show them any errors as well as the time it took for the skript to reload in their chat already.
Also your message at the end is setup wrong. Should be like this
Code:
send "Skript reloaded in %{_EndTime} - {_StartTime}%" to player
 
This should work however it's not tested.

Code:
command /reloadlinks:
    permission: reload.skripts
    trigger:
        set {_StartTime} to now
        make player execute command "/sk reload links.sk"
        broadcast "&r"
        broadcast "&7Reloading our &dLinks, &e&oPOSSIBLE LAG FOR A FEW SECONDS."
        broadcast "&r"
        skript "links.sk" is loaded
        set {_EndTime} to now
        send "Skript reloaded in (%{_EndTime}% - %{_StartTime}%)" to player
I tried this, it just sends a full legit date and actual time, rather than a "<time>ms" or "<time>seconds>".
1712013931399.png
 
Do note that if you make the player execute the command, it'll show them any errors as well as the time it took for the skript to reload in their chat already.
Also your message at the end is setup wrong. Should be like this
Code:
send "Skript reloaded in %{_EndTime} - {_StartTime}%" to player
This shows <none> instead of the issue i was having above this reply.
 
Yeah thats because theres no delay. Its like subtracting 1 from 1. You just get 0, or, nothing. Atleast, thats my understanding of it.
You can also try this:
Code:
set {_d} to difference between {_EndTime} and {_StartTime}
send "Skript reloaded in %{_d}%" to player
Do note, the way you're doing this isn't very good, skript won't have any delay between setting StartTime and EndTime. Just use the basic skript reload command, ie
Code:
command /reloadlinks:
    aliases: rl, rlinks
    permission: reload.skripts
    trigger:
        broadcast "&7Reloading our &dLinks, &e&oPOSSIBLE LAG."
        wait 10 ticks
        make player execute command "/sk reload links.sk"
 
Yeah thats because theres no delay. Its like subtracting 1 from 1. You just get 0, or, nothing. Atleast, thats my understanding of it.
You can also try this:
Code:
set {_d} to difference between {_EndTime} and {_StartTime}
send "Skript reloaded in %{_d}%" to player
Do note, the way you're doing this isn't very good, skript won't have any delay between setting StartTime and EndTime. Just use the basic skript reload command, ie
Code:
command /reloadlinks:
    aliases: rl, rlinks
    permission: reload.skripts
    trigger:
        broadcast "&7Reloading our &dLinks, &e&oPOSSIBLE LAG."
        wait 10 ticks
        make player execute command "/sk reload links.sk"
I will take this into consideration.


Code:
set {_d} to difference between {_EndTime} and {_StartTime}
send "Skript reloaded in %{_d}%" to player
This did provide 0.14 seconds time to the player. Although, you make a good point, i might just use the reload command as is no extra messages. Thank you both!
 
Hmm, didn't expect that to work. I suppose in my first example I simply got my syntax confused. If you really want to have a custom command showing how long it took, you can make the console execute the command. The only problem with this is that it won't tell you about any errors.
 
You could also simply write a skript for quick reloading:
Python:
command /skr <text>:
    permission: skript.quickreload
    trigger:
        sender is console:
            console command "skript reload %arg-1%"
        sender is a player:
            player command "skript reload %arg-1%"
        play sound "block.note_block.pling" at volume 1 at pitch 2 to sender
That way, you can just do /skr links
or /skr gamemode
or /skr spawn
or any other skript, still works with /skr all and /skr scripts and all that.
 
You could also simply write a skript for quick reloading:
Python:
command /skr <text>:
    permission: skript.quickreload
    trigger:
        sender is console:
            console command "skript reload %arg-1%"
        sender is a player:
            player command "skript reload %arg-1%"
        play sound "block.note_block.pling" at volume 1 at pitch 2 to sender
That way, you can just do /skr links
or /skr gamemode
or /skr spawn
or any other skript, still works with /skr all and /skr scripts and all that.
Oh wow, I did not think about that actually. Lol, I'm sorry, I'm new to all this stuff, so this is all very fascinating
 
No need to apologize! Being new to Skript is not a problem, these forums were designed to help new and experienced skript users. Have a great rest of your day and make a post if you need anything else!
 
  • Like
Reactions: iMinePixels