1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'Skript' started by ItsAPrettyCrazyThing, Jul 27, 2022.

Tags:
Thread Status:
Not open for further replies.
  1. ItsAPrettyCrazyThing

    Joined:
    Jul 27, 2022
    Messages:
    7
    Likes Received:
    0
    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 (Text):
    1. command /readvalue <text> [<text>] [<text>] [<offlineplayer>]:
    2.     permission: op
    3.     permission message: &cThis is a debug command only.
    4.     trigger:
    5.         if arg-2 is not set:
    6.             send "&7Is this a player value or a normal value?"
    7.         if arg-2 is "player":
    8.             if arg-4 is not set:
    9.                 send "&cSend a player name so the value can be read"
    10.             if arg-4 is set:
    11.                 send "The value of %arg-1% is %{%arg-1%::%arg-4%}%"
    12.         if arg-2 is "normal":
    13.             send "The value of %arg-1% is %{%arg-1%}%"
    14.         if arg-3 is "debug":
    15.             if arg-2 is "player":
    16.                 send "{%arg-1%::%arg-4%}"
    17.             else:
    18.                 send "{%arg-1%}"
    19.        
    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
     
    #1 ItsAPrettyCrazyThing, Jul 27, 2022
    Last edited: Jul 27, 2022
  2. ViperX

    ViperX Member

    Joined:
    Jul 26, 2022
    Messages:
    26
    Likes Received:
    0
    Where is the code that you set the variable?
     
  3. ItsAPrettyCrazyThing

    Joined:
    Jul 27, 2022
    Messages:
    7
    Likes Received:
    0
    This script here:

    Code (Text):
    1. on death:
    2.     if victim is a player:
    3.         if attacker is a player:
    4.             if {health::%victim%} is not set:
    5.                 set {health::%victim%} to 18
    6.             else:
    7.                 subtract 2 from {health::%victim%}
    8.             if {health::%attacker%} is not set:
    9.                 set {health::%attacker%} to 22
    10.             else:
    11.                 add 2 to {health::%attacker%}
    12.             make console execute command "/attribute %attacker% minecraft:generic.max_health base set %{health::%attacker%}%"
    13.             make console execute command "/attribute %victim% minecraft:generic.max_health base set %{health::%victim%}%"
    14.  
    15. on respawn:
    16.     if {health.%player%} is less than or equal to 0:
    17.         make console execute command "/gamemode spectator %player%"
    18.         send "&cYou have been eliminated. You can now only watch."
    19.  
    20.  
    21. command /health <offlineplayer>:
    22.     permission: op
    23.     permission message: &cYou do not have permission to run this command.
    24.     trigger:
    25.         send "&b%arg-1%s&7 Health is &b%{health::%arg-1%}%"
    26.  
    27.  
    28. command /reloadhealth:
    29.     permission: op
    30.     permission message: &cYou do not have permission to run this command.
    31.     trigger:
    32.         send "&6Reloading health bars.."
    33.         loop all players:
    34.             make console execute command "/attribute %loop-player% minecraft:generic.max_health base set %{health::%loop-player%}%"
    35.         send "&aHealth successfully reloaded"    
    36.      
    37. command /thing [<text>] [<offlineplayer>] [<number>]:
    38.     permission: op
    39.     permission message: &cYou do not have permission to run this command.
    40.     trigger:
    41.         if arg-1 is not set:
    42.             stop
    43.         if arg-1 is "set":
    44.             if arg-3 is not set:
    45.                 send "&cNo number specified"
    46.             if arg-2 is set:
    47.                 send "&aSuccessfully set %arg-2%'s health to %arg-3%"
    48.                 set {health::%arg-2%} to arg-3
    49.         if arg-1 is "revive":
    50.             if arg-2 is set:
    51.                 set {health::%arg-2%} to 2
    52.                 make console execute command "/gamemode survival %arg-2%"
    53.                 make console execute command "/attribute %arg-2% minecraft:generic.max_health base set %{health::%arg-2%}%"
    54.                 send "&aSuccessfully revived %arg-2%"
     
    #3 ItsAPrettyCrazyThing, Jul 27, 2022
    Last edited: Jul 27, 2022
  4. ViperX

    ViperX Member

    Joined:
    Jul 26, 2022
    Messages:
    26
    Likes Received:
    0
    did you set the variable before you triend to read it?
     
  5. ItsAPrettyCrazyThing

    Joined:
    Jul 27, 2022
    Messages:
    7
    Likes Received:
    0
    Yes I did. I made this script before I made the read script.
     
  6. ViperX

    ViperX Member

    Joined:
    Jul 26, 2022
    Messages:
    26
    Likes Received:
    0
    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
     
  7. ItsAPrettyCrazyThing

    Joined:
    Jul 27, 2022
    Messages:
    7
    Likes Received:
    0
    The event is ran first then after It was ran I tried reading it.
     
  8. ViperX

    ViperX Member

    Joined:
    Jul 26, 2022
    Messages:
    26
    Likes Received:
    0
    can you do /skript info and send the output please?
    --- Double Post Merged, Jul 27, 2022, Original Post Date: Jul 27, 2022 ---
    also check the skript plugin file and check if the variable saved in variables.csv
     
  9. ItsAPrettyCrazyThing

    Joined:
    Jul 27, 2022
    Messages:
    7
    Likes Received:
    0
    Skript Info:
    https://prnt.sc/MYKuSXBD5tDi

    [​IMG]
    Variable CSV File:


    Code (Text):
    1. # === Skript's variable storage ===
    2. # Please do not modify this file manually!
    3. #
    4. # version: 2.6.3
    5.  
    6. command.changing, boolean, 00
    7. current.command, string, 802C49206665656C206C696B6520796F757220747279696E6720746F20646F20736F6D657468696E67206576696C
    8. health.<none>, long, 0000000000000016
    9. health.EpicProGamer999, long, 0000000000000000
    10. health.Monstaa783, long, 0000000000000016
    11.  
    12.  
     
  10. ViperX

    ViperX Member

    Joined:
    Jul 26, 2022
    Messages:
    26
    Likes Received:
    0
    why its health.<name>?
    try to send "%health.<name>%"?
     
  11. ItsAPrettyCrazyThing

    Joined:
    Jul 27, 2022
    Messages:
    7
    Likes Received:
    0
    Yep that works
    --- Double Post Merged, Jul 27, 2022, Original Post Date: Jul 27, 2022 ---
    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>}
     
  12. ViperX

    ViperX Member

    Joined:
    Jul 26, 2022
    Messages:
    26
    Likes Received:
    0
    if its solved mark this as solved
     
  13. ItsAPrettyCrazyThing

    Joined:
    Jul 27, 2022
    Messages:
    7
    Likes Received:
    0
Thread Status:
Not open for further replies.

Share This Page

Loading...