Problem with "code"

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

ProfiiQus

New Member
Jul 28, 2017
9
0
0
Hello,
I have a problem with the following line of code:

Code:
if {xp.%loop-player%} is greater than {x}*({lvl.%player%}+{y})*({lvl.%player%})+{y})+{z}*{lvl.%player%}+{w}-1:
The error which is actually printed is:
"There's no world in a periodic event if no world is given in the event".

Many thanks for any help.
 
Hello,
I have a problem with the following line of code:

Code:
if {xp.%loop-player%} is greater than {x}*({lvl.%player%}+{y})*({lvl.%player%})+{y})+{z}*{lvl.%player%}+{w}-1:
The error which is actually printed is:
"There's no world in a periodic event if no world is given in the event".

Many thanks for any help.
This is in a periodical so you cant use %player%. Maybe you meant to put loop-player there?
 
  • Like
Reactions: ProfiiQus
Oh, didn't notice that, thanks.
But, Skript is now unable to understand the condition..
 
Skript is now unable to understand the condition
What condition? Post the exact error here with the exact code, not only the line that's giving you the problem.

Use the help request layout on future threads to avoid having to ask such questions.
 
Things which matter in the actual code:
code_language.skript:
variables:
    {xp.%player%} = 0
    {lvl.%player%} = 1
    {x} = 1
    {y} = 8
    {z} = 4
    {w} = 0

every 5 seconds:
    loop all players:
        if {xp.%loop-player%} is greater than {x}*({lvl.%loop-player%}+{y})*({lvl.%loop-player%})+{y})+{z}*{lvl.%loop-player%}+{w}-1:
            remove {x}*({lvl.%loop-player%}+{y})*({lvl.%loop-player%})+{y})+{z}*{lvl.%loop-player%}+{w}-1 from {xp.%loop-player%}
            add 1 to {lvl.%loop-player%}

Error code:
code_language.skript:
>[2K [20:31:44 ERROR]: can't understand this condition: '{xp.%loop-player%} is greater than {x}*({lvl.%loop-player%}+{y})*({lvl.%loop-player%})+{y})+{z}*{lvl.%loop-player%}+{w}-1' (rpg.sk, line 28: if {xp.%loop-player%} is greater than {x}*({lvl.%loop-player%}+{y})*({lvl.%loop-player%})+{y})+{z}*{lvl.%loop-player%}+{w}-1:')
 
Things which matter in the actual code:
code_language.skript:
variables:
    {xp.%player%} = 0
    {lvl.%player%} = 1
    {x} = 1
    {y} = 8
    {z} = 4
    {w} = 0

every 5 seconds:
    loop all players:
        if {xp.%loop-player%} is greater than {x}*({lvl.%loop-player%}+{y})*({lvl.%loop-player%})+{y})+{z}*{lvl.%loop-player%}+{w}-1:
            remove {x}*({lvl.%loop-player%}+{y})*({lvl.%loop-player%})+{y})+{z}*{lvl.%loop-player%}+{w}-1 from {xp.%loop-player%}
            add 1 to {lvl.%loop-player%}

Error code:
code_language.skript:
>[2K [20:31:44 ERROR]: can't understand this condition: '{xp.%loop-player%} is greater than {x}*({lvl.%loop-player%}+{y})*({lvl.%loop-player%})+{y})+{z}*{lvl.%loop-player%}+{w}-1' (rpg.sk, line 28: if {xp.%loop-player%} is greater than {x}*({lvl.%loop-player%}+{y})*({lvl.%loop-player%})+{y})+{z}*{lvl.%loop-player%}+{w}-1:')


You messed a bracket up.

Replace it with this:

code_language.skript:
if {xp.%loop-player%} is greater than {x}*({lvl.%loop-player%}+{y})*({lvl.%loop-player%}+{y})+{z}*{lvl.%loop-player%}+{w}-1:
 
  • Like
Reactions: ProfiiQus
@Lego_freak1999 that's a good eye, i spent more time than i would like to admit looking at the code trying to figure what was wrong.

Also as a personal recommendation, stop using periodical triggers as they produce a lot of lag with a bunch of people online. You could perfectly add that code to every function or part of code that adds experience so it's only executed whenever a player gains xp, and not every 5 seconds that would be wasting resources on something that may not even execute. With that code it wouldn't be much of a problem, but on a larger code that may imply looking a database or placing blocks, something like that could perfectly drop your tps by 2 or 3.
 
  • Like
Reactions: ProfiiQus
Thanks all of you for help and recommendation, it finally works as it has to!

Thumbs up
 
Status
Not open for further replies.