APickledWalrus / skript-placeholders

Placeholder integration for Skript.
GNU General Public License v3.0
28 stars 8 forks source link

How to grab value of placeholder without needing player present? #19

Closed xYosemite closed 3 years ago

xYosemite commented 3 years ago

1.5.1, latest.

Description

I am trying to implement a way to grab the current capper from a King Of The Hill plugin as I want to give them damage resistance. However, I'm not sure how to make it so the variable {capper} is set to that variable without a player having to be online? I want it to just grab the value of the placeholder and value it in a variable in the script.

Example: every 1 second in world "world": #this is done as there is no skript even for the koth plugin set {capper} to the placeholder "koth_currentcapper": # trying to set the capper placeholder to the value

This doesn't work as it's not proper syntax, a player is required.

However, this obviously works: command /capper: trigger: set {_capper} to placeholder "koth_currentcapper" from player message "%{_capper}%"

Is there any way the server can just grab the value of a global variable at any moment without a player needing to be present? Is there any work-arounds? "koth_currentcapper" is from Subside's KoTH plugin and is global, meaning that it's no different for certain players.

APickledWalrus commented 3 years ago

placeholder %string% should work I think... what if you do parse placeholder %string%

xYosemite commented 3 years ago

Says cannot understand this condition.

How do you mean exactly? I have tried set {_capper} to placeholder "koth_currentcapper" from player and parse placeholder "koth_currentcapper" as {capper}

Do you have an example?

APickledWalrus commented 3 years ago

Try

set {variable} to parse placeholder "PLACEHOLDER NAME"

to do it without needing a player player argument is supposed to be optional

xYosemite commented 3 years ago

I tried this originally, does not work.

Are you sure it is optional?

APickledWalrus commented 3 years ago

It is supposed to be. I will take a look at this when I can :)

xYosemite commented 3 years ago

Thanks, man. I hope you can try sort it out ASAP- I want to be able to use this for my KoTH gamemode. :)

APickledWalrus commented 3 years ago

Sorry for not giving you an update. I had no issues getting a result without a player present. Here is the code I used:

command /test:
    trigger:
        set {_p} to parse placeholder "server_tps"
        send "RESULT: '%{_p}%'" to executor

It successfully prints the following: RESULT: '*20.0, *20.0, *20.0, ' (This was ran both in game and from console)

PlaceholderAPI 2.10.9 skript-placeholders 1.5.1

oskarkk commented 3 years ago

Hi, if you've seen the previous version of this comment, it was totally wrong, I thought that I had a problem maybe related to the OP's problem, but with almost all placeholders and especially with %server_tps%, but I've made the following mistakes:

APickledWalrus commented 3 years ago

All placeholder values are returned as Strings, so I am not sure why you might be having that issue. However, if you got it working okay on your end it should be good. I am going to close this issue because I am still unable to reproduce it. If either of you are still having issues, feel free to comment here (even though it's closed).