Solved Make a script be able to read a variable from any script

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

Status
Not open for further replies.
Jul 27, 2022
7
0
1
25
Hi so I do some skript coding. But It would be really helpful if I could make a script that would allow me to read a value from any script. But I don't understand how. I've tried many times before but I haven't gotten it to work
Here is my code

Code:
command /readvalue <text> [<text>] [<text>] [<offlineplayer>]:
    permission: op
    permission message: &cThis is a debug command only.
    trigger:
        if arg-2 is not set:
            send "&7Is this a player value or a normal value?"
        if arg-2 is "player":
            if arg-4 is not set:
                send "&cSend a player name so the value can be read"
            if arg-4 is set:
                send "The value of %arg-1% is %{%arg-1%::%arg-4%}%"
        if arg-2 is "normal":
            send "The value of %arg-1% is %{%arg-1%}%"
        if arg-3 is "debug":
            if arg-2 is "player":
                send "{%arg-1%::%arg-4%}"
            else:
                send "{%arg-1%}"
So I tried this by running /readvalue health player debug Monstaa783
And it jut says "the value of health is <none>"
And I have no clue how to fix it. because the debug value is correct. it says the variable is {health::Monstaa783} which is correct so i have no clue whats going wrong here. If anyone knows whats going on here and are willing to help me with this that would be greatly appreciated.
If it helps im using SkQuery 4.1.7 and Skript 2.6.3 and my server software is Paper 1.19.
It says it reloads successfully and there is no error's in console
 
Last edited:
Where is the code that you set the variable?
This script here:

Code:
on death:
    if victim is a player:
        if attacker is a player:
            if {health::%victim%} is not set:
                set {health::%victim%} to 18
            else:
                subtract 2 from {health::%victim%}
            if {health::%attacker%} is not set:
                set {health::%attacker%} to 22
            else:
                add 2 to {health::%attacker%}
            make console execute command "/attribute %attacker% minecraft:generic.max_health base set %{health::%attacker%}%"
            make console execute command "/attribute %victim% minecraft:generic.max_health base set %{health::%victim%}%"

on respawn:
    if {health.%player%} is less than or equal to 0:
        make console execute command "/gamemode spectator %player%"
        send "&cYou have been eliminated. You can now only watch."


command /health <offlineplayer>:
    permission: op
    permission message: &cYou do not have permission to run this command.
    trigger:
        send "&b%arg-1%s&7 Health is &b%{health::%arg-1%}%"


command /reloadhealth:
    permission: op
    permission message: &cYou do not have permission to run this command.
    trigger:
        send "&6Reloading health bars.."
        loop all players:
            make console execute command "/attribute %loop-player% minecraft:generic.max_health base set %{health::%loop-player%}%"
        send "&aHealth successfully reloaded"     
      
command /thing [<text>] [<offlineplayer>] [<number>]:
    permission: op
    permission message: &cYou do not have permission to run this command.
    trigger:
        if arg-1 is not set:
            stop
        if arg-1 is "set":
            if arg-3 is not set:
                send "&cNo number specified"
            if arg-2 is set:
                send "&aSuccessfully set %arg-2%'s health to %arg-3%"
                set {health::%arg-2%} to arg-3
        if arg-1 is "revive":
            if arg-2 is set: 
                set {health::%arg-2%} to 2
                make console execute command "/gamemode survival %arg-2%"
                make console execute command "/attribute %arg-2% minecraft:generic.max_health base set %{health::%arg-2%}%"
                send "&aSuccessfully revived %arg-2%"
 
Last edited:
no... I see that you set the variable on death right?
so do you first do the command or first run the event and after you trying to read the variable
 
can you do /skript info and send the output please?
[doublepost=1658927737,1658927426][/doublepost]also check the skript plugin file and check if the variable saved in variables.csv
 
can you do /skript info and send the output please?
[doublepost=1658927737,1658927426][/doublepost]also check the skript plugin file and check if the variable saved in variables.csv
Skript Info:
https://prnt.sc/MYKuSXBD5tDi

YJJ_B5MtO_wY

Variable CSV File:


Code:
# === Skript's variable storage ===
# Please do not modify this file manually!
#
# version: 2.6.3

command.changing, boolean, 00
current.command, string, 802C49206665656C206C696B6520796F757220747279696E6720746F20646F20736F6D657468696E67206576696C
health.<none>, long, 0000000000000016
health.EpicProGamer999, long, 0000000000000000
health.Monstaa783, long, 0000000000000016
 
Yep that works
why its health.<name>?
try to send "%health.<name>%"?
[doublepost=1658928489,1658928429][/doublepost]Oh I see the problem
I made a simple mistake. I made the script with the variables changed to {health::<name>} instead of {health.<name>} in notepad++ but forgot to update the script on the server so it has been using variables that have {health.<name>} instead of {health::<name>}
 
Status
Not open for further replies.