I don't know how to create a config.yml like the one I've written

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

KroterPvP

Active Member
Apr 10, 2017
178
7
18
22
Hello, as the title says, I want to create a config.yml like that:
code_language.skript:
options:
    max warns: 4
    dissallowed muted cmds: "msg" or "tell" or "helpop"
messages:
    prefix: &c&lSuperBans &8» &7
    ban screen message:
    - '&7Sadly, you were &cBanned &7from &6ServerName&7. Apply on our forums if you want to dispute your ban!'
    - '%nl%'
    - '%nl%'
    - '%&7Banned by: &a%{sban.bannedby.%{_p}%}%%'
I'm using Skellett, SkQuerry3 and Skript 2.2 dev-27. It's possible to create it only using this two addons? If not, which addon do I need? Can somebody help/teach me how to create a code to do it?

Thanks!
 
So seeing that yml files are not viable or favorable in any case with skript, is there any way to create what I need with the options that skript offers? Or at least something like that?
 
So seeing that yml files are not viable or favorable in any case with skript, is there any way to create what I need with the options that skript offers? Or at least something like that?
Yes but it'd require a lot of variables. Play around with it or use YML.
 
So seeing that yml files are not viable or favorable in any case with skript, is there any way to create what I need with the options that skript offers? Or at least something like that?

YAML becomes a nonviable method of data-storage once you get around 100-250 elements per YAML file. If your entire config file is the size of the one you provided (8 elements), you shouldn't see a efficiency difference at all.

However, for configurations that are pretty small (5-12 elements), you're better off using Skript's options anyways.

We also run into the problem that you're using variables in a config/options area, which isn't possible unless you shoot it through a re-formatting process.

Here's what I would personally do if you want to use Skript options:

code_language.skript:
options:
    maxWarns : 4
    disallowedCMDs : msg or tell or helpop
    prefix : &c&lSuperBans &8» &7
    # {SERVERNAME} and {BANHAMMER} are placeholders
    banMessage : &7Sadly, you were &cBanned &7from &6{SERVERNAME}&7. Apply on our forums if you want to dispute your ban!%nl%%nl%&7Banned by: &a{BANHAMMER}

variables:
    {superBans.config::serverName} = "myServerNameHere"

function textFormat(patient: text, replacer: text, donor: text, replacer1: text, donor1: text) :: text:
    replace "%{_replacer}%" in {_patient} with "%{_donor}%"
    replace "%{_replacer1}%" in {_patient} with "%{_donor1}%"
    return colored "%{_patient}%"

command /messageTest [<text>]:
    trigger:
        # simulating player banned
        set {_p} to arg 1

        # contains example
        if "{@disallowedCMDs}" contains "%arg 1%":
            message "&cThose commands are disallowed!" to player
            stop

        # textFormat example
        set {sban.bannedby.%{_p}%} to "%player%"
        set {_message} to textFormat("{@banMessage}", "{SERVERNAME}", "%{superBans.config::serverName}%", "{BANHAMMER}", "%{sban.bannedby.%{_p}%}%")
        message "%{_message}%" to player
[doublepost=1500941689,1500941590][/doublepost]There's possibly a better way of doing this (that I honestly don't know... Maybe someone will point it out to me... mmaayyyybeeeeee), but it's the method I used for the Connect4 script here.
 
  • Like
Reactions: KingAlterIV
YAML becomes a nonviable method of data-storage once you get around 100-250 elements per YAML file. If your entire config file is the size of the one you provided (8 elements), you shouldn't see a efficiency difference at all.

However, for configurations that are pretty small (5-12 elements), you're better off using Skript's options anyways.

We also run into the problem that you're using variables in a config/options area, which isn't possible unless you shoot it through a re-formatting process.

Here's what I would personally do if you want to use Skript options:

code_language.skript:
options:
    maxWarns : 4
    disallowedCMDs : msg or tell or helpop
    prefix : &c&lSuperBans &8» &7
    # {SERVERNAME} and {BANHAMMER} are placeholders
    banMessage : &7Sadly, you were &cBanned &7from &6{SERVERNAME}&7. Apply on our forums if you want to dispute your ban!%nl%%nl%&7Banned by: &a{BANHAMMER}

variables:
    {superBans.config::serverName} = "myServerNameHere"

function textFormat(patient: text, replacer: text, donor: text, replacer1: text, donor1: text) :: text:
    replace "%{_replacer}%" in {_patient} with "%{_donor}%"
    replace "%{_replacer1}%" in {_patient} with "%{_donor1}%"
    return colored "%{_patient}%"

command /messageTest [<text>]:
    trigger:
        # simulating player banned
        set {_p} to arg 1

        # contains example
        if "{@disallowedCMDs}" contains "%arg 1%":
            message "&cThose commands are disallowed!" to player
            stop

        # textFormat example
        set {sban.bannedby.%{_p}%} to "%player%"
        set {_message} to textFormat("{@banMessage}", "{SERVERNAME}", "%{superBans.config::serverName}%", "{BANHAMMER}", "%{sban.bannedby.%{_p}%}%")
        message "%{_message}%" to player
[doublepost=1500941689,1500941590][/doublepost]There's possibly a better way of doing this (that I honestly don't know... Maybe someone will point it out to me... mmaayyyybeeeeee), but it's the method I used for the Connect4 script here.
I want to set the config like that, and let the user add & remove lines. It's possible to do that only using Skript's options?
code_language.skript:
options:
    ban screen message:
        - '&7Sadly, you were &cBanned &7from &6ServerName&7. Apply on our forums if you want to dispute your ban!'
        - '%nl%'
        - '%nl%'
        - '%&7Banned by: &a%{sban.bannedby.%{_p}%}%%'
    tempban screen message:
        - 'Example line'
 
Last edited by a moderator:
And will this code able me to do this?
code_language.skript:
options:
    ban screen message:
    - '&7Sadly, you were &cBanned &7from &6ServerName&7. Apply on our forums if you want to dispute your ban!'
    - '%nl%'
    - '%nl%'
    - '%&7Banned by: &a%{sban.bannedby.%{_p}%}%%'
I need it to be full customizable, so beeing able to add & remove lines. Is this possible? How

With Skript options: probably not (to my knowledge). However, if you preface your options stating users can use expressions like "%nl%" to express a new line in their text, like I did in my example, you shouldn't have a problem. The only downside is that it's not as neat as YAML.

If you really wanted to, you could do something like this with variables to preserve the formatting:

code_language.skript:
variables:
    {banMessage::1} = "&7Sadly, you were &cBanned &7from &6{SERVERNAME}&7. Apply on our forums if you want to dispute your ban!"
    {banMessage::2} = "%nl%"
    {banMessage::3} = "%nl%"
    {banMessage::4} = "&7Banned by: &a{BANHAMMER}"

function textListFormat(patient: texts, replacer: text, donor: text, replacer1: text, donor1: text) :: text:
    loop {_patient::*}:
        if {_text} is not set:
            set {_text} to loop-value
        else:
            set {_text} to "%{_text}%%loop-value%"
    replace "%{_replacer}%" in {_text} with "%{_donor}%"
    replace "%{_replacer1}%" in {_text} with "%{_donor1}%"
    return colored "%{_text}%"

command /messageTest:
    trigger:
        set {sban.bannedby.%{_p}%} to "%player%"
        set {_message} to textListFormat({banMessage::*}, "{SERVERNAME}", "%{superBans.config::serverName}%", "{BANHAMMER}", "%{sban.bannedby.%{_p}%}%")
        message "%{_message}%" to player
 
  • Like
Reactions: KingAlterIV
I want to set the config like that, and let the user add & remove lines. It's possible to do that only using Skript's options?
code_language.skript:
options:
    ban screen message:
        - '&7Sadly, you were &cBanned &7from &6ServerName&7. Apply on our forums if you want to dispute your ban!'
        - '%nl%'
        - '%nl%'
        - '%&7Banned by: &a%{sban.bannedby.%{_p}%}%%'
    tempban screen message:
        - 'Example line'
Yes, it's possible, but not powerful than Skript's variables.
code_language.skript:
# Here's a solution.
options:
    file: plugins/SuperBans/config.yml

on load:
    file "{@file}" doesn't exist:
        create file "{@file}"
        set {_config::*} to "options:", "  max-warns: 4", "  disallowed-mute-cmds:", "  - msg", "  - tell", "  - helpop", "", "messages:", "  prefix: §c§lSuperBans §8» §7", "  ban-message:", "  - '&7Sadly, you were &cBanned &7from &6ServerName&7. Apply on our forums if you want to dispute your ban!'", "  - '%nl%'", "  - '%nl%'", "  - '%&7Banned by: &a%{sban.bannedby.%{_p}%}%%'"
        set "{@file}"'s file contents to {_config::*}
 
Yes, it's possible, but not powerful than Skript's variables.
code_language.skript:
# Here's a solution.
options:
    file: plugins/SuperBans/config.yml

on load:
    file "{@file}" doesn't exist:
        create file "{@file}"
        set {_config::*} to "options:", "  max-warns: 4", "  disallowed-mute-cmds:", "  - msg", "  - tell", "  - helpop", "", "messages:", "  prefix: §c§lSuperBans §8» §7", "  ban-message:", "  - '&7Sadly, you were &cBanned &7from &6ServerName&7. Apply on our forums if you want to dispute your ban!'", "  - '%nl%'", "  - '%nl%'", "  - '%&7Banned by: &a%{sban.bannedby.%{_p}%}%%'"
        set "{@file}"'s file contents to {_config::*}
And how can I do it, but with skript options, without YML?
 
this is how you use options
code_language.skript:
options:
    optionName: some value

command /test:
    trigger:
        broadcast "{@optionName}"
 
Oh sorry, I honestly have no idea what you're asking for at this point
I want to do this with skript options:
code_language.skript:
options:
    ban screen message:
        - '&7Sadly, you were &cBanned &7from &6ServerName&7. Apply on our forums if you want to dispute your ban!'
        - '%nl%'
        - '%nl%'
        - '%&7Banned by: &a%{sban.bannedby.%{_p}%}%%'
    tempban screen message:
        - 'Example line'
And use {@ban screen message} to display the message.
It should allow me to add andthis remove lines
 
You cant really do that but you could do something like this:
code_language.skript:
options:
    ban message: line 1 |line 2 | |^ line 3 is a space and this is line 4 # '|' represents a new line

command /test:
    trigger:
        set {_message} to "{@ban message}"
        set {_split_message::*} to {_message} split at "|"
        set {_num} to 1
        loop size of {_split_message::*} times:
            broadcast "%{_split_message::%{_num}%}%"
            add 1 to {_num}
 
You cant really do that but you could do something like this:
code_language.skript:
options:
    ban message: line 1 |line 2 | |^ line 3 is a space and this is line 4 # '|' represents a new line

command /test:
    trigger:
        set {_message} to "{@ban message}"
        set {_split_message::*} to {_message} split at "|"
        set {_num} to 1
        loop size of {_split_message::*} times:
            broadcast "%{_split_message::%{_num}%}%"
            add 1 to {_num}
Yes, but I need it to be like a list, to be more easy to edit.
 
Status
Not open for further replies.