Optimizing Arena Save/Load

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

Status
Not open for further replies.

JustAnDev100

Member
Apr 4, 2020
2
0
1
23
Hello, So I'm trying to make a skript that will save an arena and load it. I need some help though. The first like a minute or two it works fine with 19.98 - 20 tps which is average for my server after a certain amount of time the TPS goes down a lot I mean like to 10TPS I don't want to use addons (At least try to don't use them) And I want it to load (Relatively) Big arena's

Code:
function saveArena(arena: text):
    set {_speed} to 0
    delete {revertlist.%{_arena}%::*}
    set {_height} to {minh.ww.%{_arena}%}
    loop ({maxh.ww.%{_arena}%} - {minh.ww.%{_arena}%}) times:
        loop all blocks within block at {ww.pos1.%{_arena}%} and block at {ww.pos2.%{_arena}%}:
            y-coord of loop-block is {_height}:
                add type of loop-block to {revertlist.%{_arena}%::*}
                add 1 to {_speed}
                set loop-block to red stained glass
                if {_speed} is higher than 75:
                    set {_speed} to 0
                    wait 5 tick          
        add 1 to {_height}
        wait 5 seconds
    revertArena("%{_arena}%")
function revertArena(arena: text):
    set {_bla} to 0
    set {_height} to {minh.ww.%{_arena}%}
    loop ({maxh.ww.%{_arena}%} - {minh.ww.%{_arena}%}) times:
        loop all blocks within block at {ww.pos1.%{_arena}%} and block at {ww.pos2.%{_arena}%}:
            y-coord of loop-block is {_height}:
                add 1 to {_bla}
                set loop-block to {revertlist.%{_arena}%::%{_bla}%}
                if {revertlist.%{_arena}%::%{_bla}%} is chest:
                    set slot 0 of loop-block to wooden sword
        add 1 to {_height}
If i remove the delay's the server would just crash. I already thought about the placements of block im doing in the saveArena part but i dont know how to show the progress in a different way if the block placement is causing the issuse can someone tell me how to display the progress?

Thanks alot!
If you can optimize the code / Make it less laggy (Prevent qrazy TPS drops) i will be very happy!

EDIT: The {ww.pos1.%{_arena}%} are locations also there is a little thingy build in that will fill chest with items when loading arena again
I want to use this script for Resetting a map.
 
Status
Not open for further replies.