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.

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

Discussion in 'Skript' started by KroterPvP, Jul 24, 2017.

Thread Status:
Not open for further replies.
  1. KroterPvP

    KroterPvP Active Member

    Joined:
    Apr 10, 2017
    Messages:
    178
    Likes Received:
    7
    Hello, as the title says, I want to create a config.yml like that:
    Code (Skript):
    1. options:
    2.     max warns: 4
    3.     dissallowed muted cmds: "msg" or "tell" or "helpop"
    4. messages:
    5.     prefix: &c&lSuperBans &8» &7
    6.     ban screen message:
    7.     - '&7Sadly, you were &cBanned &7from &6ServerName&7. Apply on our forums if you want to dispute your ban!'
    8.     - '%nl%'
    9.     - '%nl%'
    10.     - '%&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!
     
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    • Like Like x 1
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    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?
     
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Yes but it'd require a lot of variables. Play around with it or use YML.
     
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    I have no idea to made it with skript options. Any help?
     
  6. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    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 (Skript):
    1.  
    2. options:
    3.     maxWarns : 4
    4.     disallowedCMDs : msg or tell or helpop
    5.     prefix : &c&lSuperBans &8» &7
    6.     # {SERVERNAME} and {BANHAMMER} are placeholders
    7.     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}
    8.  
    9. variables:
    10.     {superBans.config::serverName} = "myServerNameHere"
    11.  
    12. function textFormat(patient: text, replacer: text, donor: text, replacer1: text, donor1: text) :: text:
    13.     replace "%{_replacer}%" in {_patient} with "%{_donor}%"
    14.     replace "%{_replacer1}%" in {_patient} with "%{_donor1}%"
    15.     return colored "%{_patient}%"
    16.  
    17. command /messageTest [<text>]:
    18.     trigger:
    19.         # simulating player banned
    20.         set {_p} to arg 1
    21.  
    22.         # contains example
    23.         if "{@disallowedCMDs}" contains "%arg 1%":
    24.             message "&cThose commands are disallowed!" to player
    25.             stop
    26.  
    27.         # textFormat example
    28.         set {sban.bannedby.%{_p}%} to "%player%"
    29.         set {_message} to textFormat("{@banMessage}", "{SERVERNAME}", "%{superBans.config::serverName}%", "{BANHAMMER}", "%{sban.bannedby.%{_p}%}%")
    30.         message "%{_message}%" to player
    31.  
    --- Double Post Merged, Jul 25, 2017, Original Post Date: Jul 25, 2017 ---
    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 Like x 1
  7. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    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 (Skript):
    1. options:
    2.     ban screen message:
    3.         - '&7Sadly, you were &cBanned &7from &6ServerName&7. Apply on our forums if you want to dispute your ban!'
    4.         - '%nl%'
    5.         - '%nl%'
    6.         - '%&7Banned by: &a%{sban.bannedby.%{_p}%}%%'
    7.     tempban screen message:
    8.         - 'Example line'
     
    #8 ShaneBee, Jul 26, 2017
    Last edited by a moderator: Jul 26, 2017
  8. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    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 (Skript):
    1.  
    2. variables:
    3.     {banMessage::1} = "&7Sadly, you were &cBanned &7from &6{SERVERNAME}&7. Apply on our forums if you want to dispute your ban!"
    4.     {banMessage::2} = "%nl%"
    5.     {banMessage::3} = "%nl%"
    6.     {banMessage::4} = "&7Banned by: &a{BANHAMMER}"
    7.  
    8. function textListFormat(patient: texts, replacer: text, donor: text, replacer1: text, donor1: text) :: text:
    9.     loop {_patient::*}:
    10.         if {_text} is not set:
    11.             set {_text} to loop-value
    12.         else:
    13.             set {_text} to "%{_text}%%loop-value%"
    14.     replace "%{_replacer}%" in {_text} with "%{_donor}%"
    15.     replace "%{_replacer1}%" in {_text} with "%{_donor1}%"
    16.     return colored "%{_text}%"
    17.  
    18. command /messageTest:
    19.     trigger:
    20.         set {sban.bannedby.%{_p}%} to "%player%"
    21.         set {_message} to textListFormat({banMessage::*}, "{SERVERNAME}", "%{superBans.config::serverName}%", "{BANHAMMER}", "%{sban.bannedby.%{_p}%}%")
    22.         message "%{_message}%" to player
     
    • Like Like x 1
  9. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Yes, it's possible, but not powerful than Skript's variables.
    Code (Skript):
    1. # Here's a solution.
    2. options:
    3.     file: plugins/SuperBans/config.yml
    4.  
    5. on load:
    6.     file "{@file}" doesn't exist:
    7.         create file "{@file}"
    8.         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}%}%%'"
    9.         set "{@file}"'s file contents to {_config::*}
     
  10. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    And how can I do it, but with skript options, without YML?
     
  11. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    idk
     
  12. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Use the docs.
     
  13. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    I can't find skriot option's help in thw docs. For that reason I'm writing here
     
  14. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    this is how you use options
    Code (Skript):
    1. options:
    2.     optionName: some value
    3.  
    4. command /test:
    5.     trigger:
    6.         broadcast "{@optionName}"
     
  15. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Jajaja I know that. What I'm trying to do is the message posted up
     
  16. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Oh sorry, I honestly have no idea what you're asking for at this point
     
    • Agree Agree x 1
  17. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    I want to do this with skript options:
    Code (Skript):
    1. options:
    2.     ban screen message:
    3.         - '&7Sadly, you were &cBanned &7from &6ServerName&7. Apply on our forums if you want to dispute your ban!'
    4.         - '%nl%'
    5.         - '%nl%'
    6.         - '%&7Banned by: &a%{sban.bannedby.%{_p}%}%%'
    7.     tempban screen message:
    8.         - 'Example line'
    And use {@ban screen message} to display the message.
    It should allow me to add andthis remove lines
     
  18. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    You cant really do that but you could do something like this:
    Code (Skript):
    1. options:
    2.     ban message: line 1 |line 2 | |^ line 3 is a space and this is line 4 # '|' represents a new line
    3.  
    4. command /test:
    5.     trigger:
    6.         set {_message} to "{@ban message}"
    7.         set {_split_message::*} to {_message} split at "|"
    8.         set {_num} to 1
    9.         loop size of {_split_message::*} times:
    10.             broadcast "%{_split_message::%{_num}%}%"
    11.             add 1 to {_num}
     
    • Agree Agree x 1
  19. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Yes, but I need it to be like a list, to be more easy to edit.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...