What causes slow server performance with Skript?

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

CactusMan42

Member
Aug 12, 2019
3
0
0
20
Im not sure where to put this. When writing skripts what causes the server to lag / run slower? My server doesn't lag now, but just to know what to kind of avoid.
 
I already know some languages, but thanks for the quick reply. But I will definitely start learning some C++
 
To add on to what Malia said, the #1 performance killer is periodical loops. Try to avoid them as much as possible, and if you do need to use them, use a reasonable time, here's an example of one I saw the other day that hurt my soul
code_language.skript:
every tick:
    loop all players:
        loop 20 times:
            add 1 to health of loop-player
Now, in this example, EVERY SINGLE TICK on the server, we are looping all players, then within that loop we are looping 20 times and adding to their health. What the person writing here didn't realize is all of this is attempting to happen in ONE TICK. Not to mention adding 1 to the player's health 20 times in one tick will have the same effect as just setting their health to max.
Even that being said, let's say you have 20 players on your server, EACH TICK on the server you are attempting to loop all 20 players, and run more code for each player.
Things like this will just eat up your performance, because during this same tick the server is trying to do hundreds of other tasks, but this one shitty script is trying to do hundreds of tasks as well.

If you were really needing to do something like this, space your periodical loops out. Do some math and try to estimate the damage its going to do to your server, and think realistically, does a players health need to update every tick? GOD NO... plus theres game rules for things like this.

Having a good understanding of programming as well as a good understanding of how MC works, can help you write scripts that actually perform very well on your server.
 
Status
Not open for further replies.