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!

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

Zabrid YAML Manager

Discussion in 'Scripts' started by Zabrid, Apr 17, 2022.

  1. Zabrid

    Supporter

    Joined:
    Mar 2, 2019
    Messages:
    53
    Likes Received:
    1
    THIS RESOURCE IS TO HELP SKRIPT DEVELOPERS MANAGE THEIR DATA. IT IS NOT FOR YOUR AVERAGE SERVER OWNER!

    Have you ever had problems with skript's built-in data storage system? Have you ever wanted to use Skript-YAML but didn't know how? Well then, this script has you covered!

    This script automatically sort all of your data into separate folders (per user) to ensure maximum server performance at all times. Not only that, it can also store server-side data (e.i unique players).

    Config:
    Code (Text):
    1. # ###################################################################
    2. # Zabrid's YAML Manager
    3. # Author(s): {zabrid}#3433
    4.  
    5. # Required Plugins:
    6. # - Skript
    7. # - Skript-YAML
    8.  
    9. # Functions:
    10. # - zdata_server_setvalue(value: text, chicken: text, save: boolean): - Set server related data
    11. # - zdata_server_getvalue(value: text) :: text: - Get server related data
    12. # - zdata_server_save(): - Save all server related data
    13. # - zdata_player_setvalue(p: player, value: text, chicken: text, save: boolean): - Set data for a specific player
    14. # - zdata_player_getvalue(p: player, value: text) :: text: - Get data from a specific player
    15. # - zdata_player_save(p: player): - Save a specific player's data
    16. # - zdata_player_gettop(value: text) :: texts: - Get a sorted list from high to low (Player data, duh)
    17.  
    18. # Values Cheat Sheet:
    19. # - chicken = What you're setting the value to
    20. # - value = The name of the variable you're setting.
    21. #   - Values can be split into different nodes by putting a "." (ex: "stats.blocks-placed.cactus")
    22. # - save = Do you want to save the data immediently?
    23.  
    24. # ###################################################################
    25.  
    26. # Configuration
    27. options:
    28.  
    29. #  How often the server will auto-save YAML data
    30.     auto-save-speed: 5
    31.  
    32. #  Whether or not the server will announce YAML data saving
    33.     auto-save-announcement-boolean: true
    34.  
    35. #  Only send the YAML saving announcement message to server ops
    36.     auto-save-announcement-ops-only: true
    37.  
    38. #  YAML data save message
    39.     auto-save-announcement-starting-message: "&8[&cData&8] &7Saving all player and server data..."
    40.     auto-save-announcement-ended-message: "&8[&cData&8] &7Successfully saved all player and server data. &8(&c%{_time}%&8)"
    41.  
    42. #  Still Loading Data Kick Message
    43.     still-loading-message: "&8&m                         %nl%%nl%&7You cannot join at this time.%nl%&7Data from the server is still being loaded.%nl%%nl%&cPlease try again in ~15 seconds.%nl%%nl%&8&m                         "
    44.  
    45. #  Do you want to automatically delete a YAML value if it is less than or equal to 0? (Only for numbers and integers)
    46.     do-not-save-numbers-equal-less-than-0: false
    47.  
    48. #  The folder where you want all data to go to.
    49. #  WARNING: IF YOU CHANGE THIS DATA DOES NOT TRANSFER
    50.     directory: plugins/ZabridYamlManager
    Example:
    Code (Text):
    1. # This is an example on how to use Zabrid's YAML Manager
    2. # This example shows how you could track a player's kills and deaths, aswell as make a leaderboard
    3.  
    4. on death:
    5.  
    6.     victim is a player
    7.  
    8.     set {_deaths} to zdata_player_getvalue(victim, "kill-tracker.deaths") parsed as integer # Retrieving the amount of deaths the victim has
    9.     add 1 to {_deaths} # Adding 1 to the amount of deaths the victim has
    10.     zdata_player_setvalue(victim, "kill-tracker.deaths", "%{_deaths}%", true) # Setting the amount of deaths the victim has. This data will be saved instantly.
    11.  
    12.     attacker is a player
    13.  
    14.     set {_kills} to zdata_player_getvalue(victim, "kill-tracker.kills") parsed as integer # Retrieving the amount of kills the attacker has
    15.     add 1 to {_kills} # Adding 1 to the amount of kills the attacker has
    16.     zdata_player_setvalue(victim, "kill-tracker.deaths", "%{_deaths}%", true) # Setting the amount of kills the attacker has. This data will be saved instantly.
    17.  
    18. on join:
    19.  
    20.     set {_deaths} to zdata_player_getvalue(player, "kill-tracker.deaths")
    21.     if "%{_deaths}%" is "<none>": # Skript bug, means you have to do it like this
    22.         zdata_player_setvalue(player, "kill-tracker.deaths", "0", false) # I did not save here because I will save later in the event
    23.  
    24.     set {_kills} to zdata_player_getvalue(player, "kill-tracker.kills")
    25.     if "%{_kills}%" is "<none>":
    26.         zdata_player_setvalue(player, "kill-tracker.kills", "0", false) # I did not save here because I will save later in the event
    27.  
    28.     zdata_player_save(player) # Saves all of the players YAML data
    29.  
    30. command /kills [<offline player>]:
    31.     trigger:
    32.         set {_p} to arg 1 ? player
    33.         set {_kills} to zdata_player_getvalue({_p}, "kill-tracker.kills")
    34.         if {_kills} is set:
    35.             send "&a%{_p}% has killed &n%{_kills}%&a people."
    36.         else:
    37.             send "&cThis player does not have any Kills data stored."
    38.  
    39. command /deaths [<offline player>]:
    40.     trigger:
    41.         set {_p} to arg 1 ? player
    42.         set {_deaths} to zdata_player_getvalue({_p}, "kill-tracker.deaths")
    43.         if {_deaths} is set:
    44.             send "&c%{_p}% has died &n%{_deaths}%&c times."
    45.         else:
    46.             send "&cThis player does not have any Deaths data stored."
    47.  
    48. # This is how you make a leaderboard with Zabrid's YAML Manager
    49.  
    50. command /killstop:
    51.     trigger:
    52.  
    53.         set {_leaderboard::*} to zdata_player_gettop("kill-tracker.kills")
    54.  
    55.         send "%{_leaderboard::1} parsed as offline player% &7is the top killer."
    56.  
    57.         send ""
    58.         send "&aTop 10 Killers on the server!"
    59.         send "&8-> &7Tracking &d%size of {_leaderboard::*}%&7 players"
    60.         send ""
    61.  
    62.         loop {_leaderboard::*}:
    63.  
    64.             if loop-index parsed as integer is greater than 10: #This means only the top 10 most kills will show up
    65.                 stop
    66.        
    67.             # loop-value = the UUID of the player
    68.             # loop-index = The player's position. This value is text by default, so parse it if you need to do math
    69.             set {_value} to zdata_player_getvalue(loop-value parsed as offline player, "kill-tracker.kills") # loop-value saved as the uuid of the player, so to get the name you need to parse as offline player
    70.  
    71.             send "&7 %loop-index%. &a%loop-value parsed as offline player% &8- &7%{_value}%"
    72.    
    73.         send ""
    Required Plugins:
    Code (Text):
    1.   Skript
    2.   Skript-YAML
    Support Discord: https://discord.gg/vMuWFWXJVy
     

Share This Page

Loading...