#Skript Optimization

1 messages · Page 1 of 1 (latest)

pale tinsel
#

Someone can help me in the optimization of one skript? Los the TPS a lot, and that crash the servers.

dreamy harness
#

send your skript

pale tinsel
dreamy harness
#

The issue is that each time a player mines another forever loop is added

The previous loops won't stop unless you make it

So since you have a huge amount of forever loops running all at the same time, it lags out the server

Not sure why you even need loops. You could just do on item pickup: without loops or something similar

Also, double check your indentation in the first code block

#

@pale tinsel

pale tinsel
#

Each loop is for a certain block of a certain mine. That's why there are so many.

And that makes a lot of sense, I'll see if I can see how not to overload the script.

dreamy harness
#

Instead of

   while player is online:
      wait 1 second
      if {AutoComp::%player's uuid%} = true:
         insert code here```

You can do
```on item pickup:
   if {AutoComp::%player's uuid%} = true:
      insert code here```

This gets rid of:
- adding more and more of the same loop
- the loop itself (forever loops can lag your server)
- 2 lines of code
#

Hopefully this helps you optimize code in the future

pale tinsel
#

Thank you very much for taking the time to analyze my problem!

#

on item pickup: This structure tells me that you don't understand it.

dreamy harness
#

O

#

Not exactly sure what you're trying to do with this then but just remember the main cause of the crashes is because it's adding more and more infinity loops over time

pale tinsel
#
      if {AutoComp::%player's uuid%} = true:
          insert code here
    cancel event``` 

This maybe work? I understood what you explained to me, I learn as I go.
#

That's why that code is so messy.

dreamy harness
pale tinsel
#

Okay, but would it be correct that way so that it is not infinite?

dreamy harness
#

there aren't even any loops at all

#

so yes

#

not sure why you have cancel event though

#

then people cant get items at all

proven cliff