Solved Help, text and time span

  • 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.
Jan 19, 2018
18
1
3
Hello! I'm having a problem with my skript, so basically, here's the code and the issue:

code_language.skript:
command /tempban [<offline player>] [<timespan>] [<text>]:
    permission: command.tempban
    permission message: &cYou do not have permission to perform this action.
    trigger:
        if arg 1 is not set:
            message "&cUsage: /tempban <player> <timespan> <reason>"
        if arg 1 is set:
            if arg 2 is not set:
                message "&cUsage: /tempban %arg 1% <timespan> <reason>"
            if arg 2 is set:
                if arg 3 is not set:
                    message "&cUsage: /tempban %arg 1% %arg 2% <reason>"
                if arg 3 is set:
                    ban events.. etc.

But using this was causing skript to not work, pretty sure this is because timespan and text since if I put "1 day", then the day part could be a part of timespan OR text, so skript just wasn't working. I decided to change it to something like this:

code_language.skript:
command /tempban [<offline player>] [<timespan>] @ [<text>]:

So, basically using "@" as a separator for the timespan and text. This was working fine, but then I realised the "&cUsage: /tempban <player> <timespan> <reason>" messages weren't working, but instead, I got messages like "Correct usage: /tempban [<offline player>] [<timespan>] @ [<text>]" which I didn't want. How can I make it so that I get the custom usage messages I made while having the @ separator, or is there a way I can do this command without having the @ separator and still keeping timespan and text?

Before any of you say that arg 3(text) becomes arg 4(text) due to the @ separator, it does not. I have tested this.
 
getting the args yourself like this should work
code_language.skript:
command /tempban [<offline player>]  [<text>]:
    trigger:
        if arg-1 is set:
            if arg-2 is set:
                set {_timespanAndReason::*} to arg-2 split at " "
                if size of {_timespanAndReason::*} is greater than 2:
                    set {_timespan} to "%{_timespanAndReason::1}% %{_timespanAndReason::2}%" parsed as a timespan
                    set {_reason} to ""
                    loop size of {_timespanAndReason::*} times:
                        if loop-number is not 1:
                            if loop-number is not 2:
                                set {_reason} to "%{_reason}%%{_timespanAndReason::%loop-number%}% "
                    set {_reason} to first length of {_reason} - 1 characters of {_reason}
                    message "&aBanned %arg-1% for %{_reason}% for %{_timespan}%"
                else:
                    message "&cUsage: /tempban <player> <timespan> <reason>"
            else:
                message "&cUsage: /tempban <player> <timespan> <reason>"
        else:
            message "&cUsage: /tempban <player> <timespan> <reason>"
 
KXcPr
getting the args yourself like this should work
code_language.skript:
command /tempban [<offline player>]  [<text>]:
    trigger:
        if arg-1 is set:
            if arg-2 is set:
                set {_timespanAndReason::*} to arg-2 split at " "
                if size of {_timespanAndReason::*} is greater than 2:
                    set {_timespan} to "%{_timespanAndReason::1}% %{_timespanAndReason::2}%" parsed as a timespan
                    set {_reason} to ""
                    loop size of {_timespanAndReason::*} times:
                        if loop-number is not 1:
                            if loop-number is not 2:
                                set {_reason} to "%{_reason}%%{_timespanAndReason::%loop-number%}% "
                    set {_reason} to first length of {_reason} - 1 characters of {_reason}
                    message "&aBanned %arg-1% for %{_reason}% for %{_timespan}%"
                else:
                    message "&cUsage: /tempban <player> <timespan> <reason>"
            else:
                message "&cUsage: /tempban <player> <timespan> <reason>"
        else:
            message "&cUsage: /tempban <player> <timespan> <reason>"
Well, it works, partly. Look at this image:
72f7a4048d235ce61fa6cc4ef9f3e0c7.png

https://gyazo.com/72f7a4048d235ce61fa6cc4ef9f3e0c7
[doublepost=1516612705,1516608310][/doublepost]Nevermind, I have found a way to fix this issue. If others are having this problem, use something like this:

code_language.skript:
command /tempban [<offline player>] [<timespan>] [@ <text>]:
 
Status
Not open for further replies.