Solved Skript Conditions Doesn't Work With Placeholders

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

2Unexpected

Member
Nov 4, 2022
14
1
3
23
This is a example code similar to my main code, when I run /statsmoney it literally does nothing and sends nothing. (The placeholders work fine if I don't use the if {_playerBalance}... for example if I just send a message with %{_playerBalance}% it will show my balance correctly but with if ... it does not work) also no errors on reload, I'm using Ersatz to use Placeholders. Please help, thanks.

Code:
command /statsmoney:
    trigger:
        set {_playerBalance} to placeholder "vault_eco_balance"
        if {_playerBalance} < 500:
            send "&aYou are poor"
        if {_playerBalance} > 500:
            send "&aYou are rich (%{_playerBalance}%)"
 
use player's balance instead.

for future reference all placeholders are strings so you should be parsing them.

your code will do nothing if their balance is 500 and you should be using skript-placeholders instead of Ersatz
 
The reason why placeholders aren't working the way you want them to is because  all PlaceholderAPI placeholders return as a text, not a integer or number. So where you need the placeholders to be numbers, you need to check the variable parsed as integer

code_language.skript:
set {_var} to placeholder "vault_eco_balance"
set {_var} to "%{_var}%" parsed as integer
 
Oops

[04:27:55 ERROR]: #!#!
[04:27:55 ERROR]: #!#! [Skript] Severe Error:
[04:27:55 ERROR]: #!#!
[04:27:55 ERROR]: #!#! Something went horribly wrong with Skript.
[04:27:55 ERROR]: #!#! This issue is NOT your fault! You probably can't fix it yourself, either.
[04:27:55 ERROR]: #!#! Your Minecraft version or server software appears to be unsupported by Skript (bensku's version).
[04:27:55 ERROR]: #!#! Currently only supported servers are Spigot and its forks for Minecraft 1.9 or newer.
[04:27:55 ERROR]: #!#! Other versions might work, but since you're getting this error message something is NOT working,
[04:27:55 ERROR]: #!#! nor it will work, unless you switch to supported platform.
[04:27:55 ERROR]: #!#! Issue tracker: https://github.com/SkriptLang/Skript/issues (only if you know what you're doing!)
[04:27:55 ERROR]: #!#!
[04:27:55 ERROR]: #!#! Stack trace:
[04:27:55 ERROR]: #!#! java.lang.NullPointerException: Cannot invoke "org.bukkit.entity.Player.getUniqueId()" because "<parameter1>" is null
[04:27:55 ERROR]: #!#! at me.mrdarkness462.thepit.features.economy.gold.PlayerEconomy.get(PlayerEconomy.java:38)
[04:27:55 ERROR]: #!#! at me.mrdarkness462.thepit.features.Placeholders$4.request(Placeholders.java:76)
[04:27:55 ERROR]: #!#! at org.magenpurp.api.placeholder.PAPI.onPlaceholderRequest(PAPI.java:42)
[04:27:55 ERROR]: #!#! at me.clip.placeholderapi.PlaceholderHook.onRequest(PlaceholderHook.java:35)
[04:27:55 ERROR]: #!#! at me.clip.placeholderapi.replacer.CharsReplacer.apply(CharsReplacer.java:119)
[04:27:55 ERROR]: #!#! at me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(PlaceholderAPI.java:71)
[04:27:55 ERROR]: #!#! at io.github.apickledwalrus.skriptplaceholders.skript.util.PlaceholderUtils.getPlaceholder(PlaceholderUtils.java:31)
[04:27:55 ERROR]: #!#! at io.github.apickledwalrus.skriptplaceholders.skript.elements.expressions.ExprParsePlaceholder.get(ExprParsePlaceholder.java:75)
[04:27:55 ERROR]: #!#! at io.github.apickledwalrus.skriptplaceholders.skript.elements.expressions.ExprParsePlaceholder.get(ExprParsePlaceholder.java:23)
[04:27:55 ERROR]: #!#! at ch.njol.skript.lang.util.SimpleExpression.getArray(SimpleExpression.java:102)
[04:27:55 ERROR]: #!#! at ch.njol.skript.effects.EffChange.execute(EffChange.java:268)
[04:27:55 ERROR]: #!#! at ch.njol.skript.lang.Effect.run(Effect.java:52)
[04:27:55 ERROR]: #!#! at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:61)
[04:27:55 ERROR]: #!#! at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:89)
[04:27:55 ERROR]: #!#! at ch.njol.skript.lang.Trigger.execute(Trigger.java:55)
[04:27:55 ERROR]: #!#! at ch.njol.skript.command.ScriptCommand.execute2(ScriptCommand.java:285)
[04:27:55 ERROR]: #!#! at ch.njol.skript.command.ScriptCommand.execute(ScriptCommand.java:242)
[04:27:55 ERROR]: #!#! at ch.njol.skript.command.Commands.handleCommand(Commands.java:257)
[04:27:55 ERROR]: #!#! at ch.njol.skript.command.Commands$1.onPlayerCommand(Commands.java:172)
[04:27:55 ERROR]: #!#! at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[04:27:55 ERROR]: #!#! at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
[04:27:55 ERROR]: #!#! at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[04:27:55 ERROR]: #!#! at java.base/java.lang.reflect.Method.invoke(Method.java:568)
[04:27:55 ERROR]: #!#! at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306)
[04:27:55 ERROR]: #!#! at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
[04:27:55 ERROR]: #!#! at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502)
[04:27:55 ERROR]: #!#! at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487)
[04:27:55 ERROR]: #!#! at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1154)
[04:27:55 ERROR]: #!#! at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997)
[04:27:55 ERROR]: #!#! at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45)
[04:27:55 ERROR]: #!#! at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1)
[04:27:55 ERROR]: #!#! at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13)
[04:27:55 ERROR]: #!#! at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[04:27:55 ERROR]: #!#! at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[04:27:55 ERROR]: #!#! at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44)
[04:27:55 ERROR]: #!#! at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715)
[04:27:55 ERROR]: #!#! at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374)
[04:27:55 ERROR]: #!#! at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654)
[04:27:55 ERROR]: #!#! at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557)
[04:27:55 ERROR]: #!#! at java.base/java.lang.Thread.run(Thread.java:833)
[04:27:55 ERROR]: #!#!
[04:27:55 ERROR]: #!#! Version Information:
[04:27:55 ERROR]: #!#! Skript: 2.2-dev36 (custom version)
[04:27:55 ERROR]: #!#! Bukkit: 1.8.8-R0.1-SNAPSHOT
[04:27:55 ERROR]: #!#! Minecraft: 1.8.8
[04:27:55 ERROR]: #!#! Java: 17.0.4.1 (Java HotSpot(TM) 64-Bit Server VM 17.0.4.1+1-LTS-2)
[04:27:55 ERROR]: #!#! OS: Windows 10 amd64 10.0
[04:27:55 ERROR]: #!#!
[04:27:55 ERROR]: #!#! Server platform: Spigot
[04:27:55 ERROR]: #!#!
[04:27:55 ERROR]: #!#! Current node: null
[04:27:55 ERROR]: #!#! Current item: set {_playerGold}(as java.lang.Object) to the value of placeholder(s) "thepit_leaderheads_gold"
[04:27:55 ERROR]: #!#! Current trigger: command /paygold (simple event) (paygold.sk, line -1)
[04:27:55 ERROR]: #!#!
[04:27:55 ERROR]: #!#! Thread: Server thread
[04:27:55 ERROR]: #!#!
[04:27:55 ERROR]: #!#! Language: english
[04:27:55 ERROR]: #!#! Link parse mode: DISABLED
[04:27:55 ERROR]: #!#!
[04:27:55 ERROR]: #!#! End of Error.
[04:27:55 ERROR]: #!#!
 
You can just use variables.
Code:
command /statsmoney:
    trigger:
        if {vaultecomoney::%player's uuid%} is less than 500:
            send "&aYou are poor"
        if {vaultecomoney::%player's uuid%} is greater than 500:
            send "&aYou are rich (%{vaultecomoney::%player's uuid%}%)"