Lukkit
Search…
Example
In this example, a storage object is created for the config.yml file and sets the default value join-message. Then when the player event PlayerJoinEvent is called it gets the storage value from the storage object, replaces %s with the player name and sets it to the join message.
1
-- Create a storage object with the file "config.yml"
2
pluginConfig = plugin.getStorageObject("config.yml")
3
​
4
-- Set the default to join message and save the config if it is not already in there
5
if pluginConfig:setDefaultValue("join-message", "%s joined the game!") then
6
pluginConfig:save()
7
end
8
​
9
-- Make event for when players join
10
plugin.registerEvent("PlayerJoinEvent", function(event)
11
-- Set the join message based on the config value
12
event:setJoinMessage(string.format(pluginConfig:getValue("join-message"), event:getPlayer():getDisplayName()))
13
end)
Copied!
Last modified 3yr ago
Copy link