How to optimize?

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

MeHow

Active Member
Feb 6, 2017
140
13
18
Lithuania
Hello guys, I have this skript:
code_language.skript:
function SaveArea(t: text):
    set {_x} to 0
    loop blocks within {arena.pos1.%{_t}%} to {arena.pos2.%{_t}%}:
        if loop-block is not air:
            add 1 to {_x}
            set {arena::%{_t}%::blocklar::%location of loop-block%} to type of block at loop-block
            if {_x} is 100:
                wait 1 ticks
                set {_x} to 0
              
              
function Restore(t: text):
    set {_x} to 0
    set {_y} to 0
    wait 0.3 seconds
    loop blocks within {arena.pos1.%{_t}%} to {arena.pos2.%{_t}%}:
        if {arena::%{_t}%::blocklar::%location of loop-block%} is set:
            if type of loop-block is not {arena::%{_t}%::blocklar::%location of loop-block%}:
                add 1 to {_x}
                set block at loop-block to {arena::%{_t}%::blocklar::%location of loop-block%}
                if {_x} is 80:
                    wait 3 ticks #THIS IS AN ANTI-LAG SISTEM IF, CHANGE AT YOU RISK
                    set {_x} to 0
        else:
            if loop-block is not air:
                set block at loop-block to air
                if {_y} is 4:
                    wait 5 ticks
                    set {_y} to 0
                  
 
command /setpos1 [<text>]:
    permission: sw.op
    trigger:
        if arg 1 is set:
            set {arena.pos1.%arg-1%} to location of player
            message "{@prefix} pos1 set for %arg-1%"
            
command /setpos2 [<text>]:
    permission: sw.op
    trigger:
        if arg 1 is set:
            set {arena.pos2.%arg-1%} to location of player
            message "{@prefix} pos2 set for %arg-1%"
          
command /save [<text>]:
    permission: sw.op
    trigger:
        SaveArea("%arg-1%")
        message "{@prefix} arena %arg-1% saved."
      
command /restore [<text>]:
    permission: sw.op
    trigger:
        Restore("%arg-1%")
        message "{@prefix} arena %arg-1% restored."

how to optimize? I have 5 GB RAM server and it's still lagging
 
Hello guys, I have this skript:
code_language.skript:
function SaveArea(t: text):
    set {_x} to 0
    loop blocks within {arena.pos1.%{_t}%} to {arena.pos2.%{_t}%}:
        if loop-block is not air:
            add 1 to {_x}
            set {arena::%{_t}%::blocklar::%location of loop-block%} to type of block at loop-block
            if {_x} is 100:
                wait 1 ticks
                set {_x} to 0
             
             
function Restore(t: text):
    set {_x} to 0
    set {_y} to 0
    wait 0.3 seconds
    loop blocks within {arena.pos1.%{_t}%} to {arena.pos2.%{_t}%}:
        if {arena::%{_t}%::blocklar::%location of loop-block%} is set:
            if type of loop-block is not {arena::%{_t}%::blocklar::%location of loop-block%}:
                add 1 to {_x}
                set block at loop-block to {arena::%{_t}%::blocklar::%location of loop-block%}
                if {_x} is 80:
                    wait 3 ticks #THIS IS AN ANTI-LAG SISTEM IF, CHANGE AT YOU RISK
                    set {_x} to 0
        else:
            if loop-block is not air:
                set block at loop-block to air
                if {_y} is 4:
                    wait 5 ticks
                    set {_y} to 0
                 
 
command /setpos1 [<text>]:
    permission: sw.op
    trigger:
        if arg 1 is set:
            set {arena.pos1.%arg-1%} to location of player
            message "{@prefix} pos1 set for %arg-1%"
           
command /setpos2 [<text>]:
    permission: sw.op
    trigger:
        if arg 1 is set:
            set {arena.pos2.%arg-1%} to location of player
            message "{@prefix} pos2 set for %arg-1%"
         
command /save [<text>]:
    permission: sw.op
    trigger:
        SaveArea("%arg-1%")
        message "{@prefix} arena %arg-1% saved."
     
command /restore [<text>]:
    permission: sw.op
    trigger:
        Restore("%arg-1%")
        message "{@prefix} arena %arg-1% restored."

how to optimize? I have 5 GB RAM server and it's still lagging
This is because looping/setting blocks is synchronous so it will lag your server until the operation completes
 
Status
Not open for further replies.