D
Deleted member 5254
Often times you may notice you have a ton of variables for players. After a lot of players join your server you will notice your variable file growing and growing. One main issue here is that a lot of the players who join your server, may possible join once and never return.
This ends up clogging up your variable file if you don't manage the variables properly.
This snippet allows you to save data to a player's custom NBT rather than using variables.
Data saved this way is persistent with the player's data file.
(This requires SkBee 1.7.1+ and Minecraft 1.14+)
Here are 2 examples of some simple functions to set/get/delete values in the player's custom NBT.
And here are a couple examples of using these functions for setting/getting values.
Happy NBT-ing
This ends up clogging up your variable file if you don't manage the variables properly.
This snippet allows you to save data to a player's custom NBT rather than using variables.
Data saved this way is persistent with the player's data file.
(This requires SkBee 1.7.1+ and Minecraft 1.14+)
Here are 2 examples of some simple functions to set/get/delete values in the player's custom NBT.
code_language.skript:
# Simple function to set a value in a player's custom NBT
function set(p: player, key: string, obj: object):
set {_nbt} to nbt compound of {_p}
set {_c} to tag "custom" of {_nbt}
set tag {_key} of {_c} to {_obj}
set tag "custom" of {_nbt} to {_c}
# Simple function to get a value in a player's custon NBT
function get(p: player, key: string) :: object:
set {_nbt} to nbt compound of {_p}
set {_c} to tag "custom" of {_nbt}
return tag {_key} of {_c}
# Simple function to delete a value in a player's custom NBT
function delete(p: player, key: string):
set {_nbt} to nbt compound of {_p}
set {_c} to tag "custom" of {_nbt}
delete tag {_key} of {_c}
set tag "custom" of {_nbt} to {_c}
And here are a couple examples of using these functions for setting/getting values.
code_language.skript:
# Example using the set function to set a value
on first join:
set(player, "money", 100.0)
set(player, "points", 0)
set(player, "current-name", name of player)
# Example using the get function to get a value
command /money:
trigger:
set {_b} to get(player, "money")
send "&aMoney: &b$&7%{_b}%"
Happy NBT-ing
Last edited by a moderator: