Many event vs If chain

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

DittoNut

Member
Mar 11, 2024
4
0
1
37
hi, im making a skill skript.
for server performance, what is better?
1. Single file with large if-else chains
2. Many file that has same event
3. One file listen event and calls many function(in other file)
 
I don't think it matters that much. I think its just the same performance. but there might be a little more lag if you're using functions but i'm not sure about that
 
hi, im making a skill skript.
for server performance, what is better?
1. Single file with large if-else chains
2. Many file that has same event
3. One file listen event and calls many function(in other file)
For server performance, the lesser lines of code is always better. I would think one listen event that calls many functions from another file would be better than a single if else chain file as then you don’t have to duplicate similar lines of code many times which in turn would lead to more lag. Also more files could be harder to keep track of. Functions are extremely helpful for making code shorter (I use em in pretty much every Skript I write).
 
Hi, for best performance I would recommend doing a few things:
- If you have multiple of the same event, merge them into a comment-separated list. For example if you already have a periodical event that loops players, there's no need to have more than one
- if-else chains are okay--as long as they don't get too long, but it is beneficial to ensure that they are organized and easy to navigate using the Find CTRL + F feature of most text editors
- Keep everything in functions (local or global) to prev