Solved variable as minute

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

loadka95

Active Member
Feb 24, 2017
78
6
8
26
code_language.skript:
on join:
    set {_tempbanwaited} to difference between {tempbannedtimer.%player%} and now
    if {_tempbanwaited} is less than {tempban.%player%} minute: #This line is not working for me **
        wait 26 tick
        kick player due to "%{_tempbanwaited}%"

{tempban.%player%} is a number
** I tried to put the variable {tempban.%player%} to %% and "" , those time no error popped up, but still don't worked!
The error message:
Névtelen.png
 
What is the value of {tempban.%player%}? Can you put in a troubleshooting message like this?
code_language.skript:
on join:
   broadcast "%{tempban.%player%}%"
    set {_tempbanwaited} to difference between {tempbannedtimer.%player%} and now
depending on how your command that uses that variable sets the timer, it may have extra characters in it making it not work. For example with essentials the commands could be done /tempban <player> 5m, potentially adding an "m" to your variable that would make the number not work in this section here
a90a7c69fc.png
 
What is the value of {tempban.%player%}? Can you put in a troubleshooting message like this?
code_language.skript:
on join:
   broadcast "%{tempban.%player%}%"
    set {_tempbanwaited} to difference between {tempbannedtimer.%player%} and now
depending on how your command that uses that variable sets the timer, it may have extra characters in it making it not work. For example with essentials the commands could be done /tempban <player> 5m, potentially adding an "m" to your variable that would make the number not work in this section here
a90a7c69fc.png
Its just a number, nothing else.
 
Yes, but here is the full code:
code_language.skript:
variables:
    {_ponline} = 0

command /agui:
    trigger:
        set {_ponline} to 0
        open chest with 6 row named "asd" to player
        loop all players:
            add 1 to {_ponline}
            broadcast "%name of loop-value%"
            wait 1 tick
            set slot {_ponline}-1 of player's current inventory to ("%name of loop-value%" parsed as offline player)'s skull named "%name of loop-value%"
        
on inventory click:
    if name of player's current inventory is "asd":
        if clicked slot is between 0 and 53:
            if clicked inventory is not player's inventory:
                if clicked item is not air:
                    set {clickedslot.%player%} to name of clicked item
                    cancel event
                    close player's inventory
                    wait 2 tick
                    open chest with 5 row named "%{clickedslot.%player%}%" to player
                    set slot 4 of player's current inventory to ("%{clickedslot.%player%}%" parsed as offline player)'s skull named "%{clickedslot.%player%}%"
                    set slot 19 of player's current inventory to red wool block named "&aKick Player"
                    set slot 21 of player's current inventory to barrier named "&aBan Player"

    if name of player's current inventory is "%{clickedslot.%player%}%":
        loop all players:
            if loop-player is equal to {clickedslot.%player%}:
                set {punishguy} to loop-player
        if name of clicked item is "%{punishguy}%":
            cancel event
        else if name of clicked item is "&aKick Player":
            cancel event
            kick {punishguy} due to "You may not place %{punishguy}%!"
        else if name of clicked item is "&aBan Player":
            cancel event
            close player's inventory
            wait 2 tick
            open chest with 5 row named "%{clickedslot.%player%}% BAN" to player
            set slot 19 of player's current inventory to light green glass named "+1 minute"
            set slot 20 of player's current inventory to light green glass named "+1 hour"
            set slot 21 of player's current inventory to light green glass named "+1 day"
            set slot 22 of player's current inventory to barrier named "&4BAN PLAYER" with lore "&a--- &bBan time &a---||     &e%{bantimeday.%player%}%d %{bantimehour.%player%}%h %{bantimeminute.%player%}%m"
            set slot 23 of player's current inventory to red glass named "-1 day"
            set slot 24 of player's current inventory to red glass named "-1 hour"
            set slot 25 of player's current inventory to red glass named "-1 minute"

    if name of player's current inventory is "%{clickedslot.%player%}% BAN":
        if name of clicked item is "&4BAN PLAYER":
            clear {tempban.%{clickedslot.%player%}%}
            set {tempban.%{clickedslot.%player%}%} to {tempban.%{clickedslot.%player%}%}+{bantimeminute.%player%}+({bantimehour.%player%}*60)+({bantimeday.%player%}*1440)
            loop all players:
                if loop-player is equal to {clickedslot.%player%}:
                    set {punishguy} to loop-player
                    set {tempbannedtimer.%{punishguy}%} to now     #<--- 
                    kick {punishguy} due to "Banned for %{tempban.%{clickedslot.%player%}%}% min"
            cancel event
        else if name of clicked item is "+1 minute":
            add 1 to {bantimeminute.%player%}
            if {bantimeminute.%player%} is 60:
                add 1 to {bantimehour.%player%}
                remove 60 from {bantimeminute.%player%}
            cancel event
        else if name of clicked item is "+1 hour":
            add 1 to {bantimehour.%player%}
            if {bantimehour.%player%} is 24:
                add 1 to {bantimeday.%player%}
                remove 24 from {bantimehour.%player%}
            cancel event
        else if name of clicked item is "+1 day":
            add 1 to {bantimeday.%player%}
            cancel event
        else if name of clicked item is "-1 minute":
            if {bantimeminute.%player%} is more than 0:
                remove 1 from {bantimeminute.%player%}
            cancel event
        else if name of clicked item is "-1 hour":
            if {bantimehour.%player%} is more than 0:
                remove 1 from {bantimehour.%player%}
            cancel event
        else if name of clicked item is "-1 day":
            if {bantimeday.%player%} is more than 0:
                remove 1 from {bantimeday.%player%}
            cancel event
        set slot 22 of player's current inventory to barrier named "&4BAN PLAYER" with lore "&a--- &bBan time &a---||     &e%{bantimeday.%player%}%d %{bantimehour.%player%}%h %{bantimeminute.%player%}%m"
        
on join:
    broadcast "%{tempban.%player%}%"
    set {_tempbanwaited} to difference between {tempbannedtimer.%player%} and now
    if {_tempbanwaited} is less than {tempban.%player%} minute:
        wait 26 tick
        kick player due to "%{_tempbanwaited}%"
 
it may not be the best outcome, but in a bit of testing I found for me that removing the "minute" after the variable in that line makes it load properly, so it's not the variable itself I think it's the syntax not accepting text after the variable. You could incorporate that into your code elsewhere instead. this was my simplified test code
code_language.skript:
on join:
    set {_tempbanwaited} to difference between {tempbannedtimer.%player%} and now
    if {_tempbanwaited} is less than {tempban.%player%}:
        wait 26 tick
        kick player due to "%{_tempbanwaited}%"

        
command /numberset:
    trigger:
        set {tempban.%player%} to "5 minute"
        set {tempbannedtimer.%player%} to now
 
it may not be the best outcome, but in a bit of testing I found for me that removing the "minute" after the variable in that line makes it load properly, so it's not the variable itself I think it's the syntax not accepting text after the variable. You could incorporate that into your code elsewhere instead. this was my simplified test code
code_language.skript:
on join:
    set {_tempbanwaited} to difference between {tempbannedtimer.%player%} and now
    if {_tempbanwaited} is less than {tempban.%player%}:
        wait 26 tick
        kick player due to "%{_tempbanwaited}%"

       
command /numberset:
    trigger:
        set {tempban.%player%} to "5 minute"
        set {tempbannedtimer.%player%} to now
Thank You! :emoji_slight_smile:
 
it may not be the best outcome, but in a bit of testing I found for me that removing the "minute" after the variable in that line makes it load properly, so it's not the variable itself I think it's the syntax not accepting text after the variable. You could incorporate that into your code elsewhere instead. this was my simplified test code
code_language.skript:
on join:
    set {_tempbanwaited} to difference between {tempbannedtimer.%player%} and now
    if {_tempbanwaited} is less than {tempban.%player%}:
        wait 26 tick
        kick player due to "%{_tempbanwaited}%"

       
command /numberset:
    trigger:
        set {tempban.%player%} to "5 minute"
        set {tempbannedtimer.%player%} to now
@loadka95 while this doesn't error, it won't work. Depending on your skript version the tempban will either be permanent or instantly expire. What you need to do is use parsing to parse as a timespan when using a variable number of units. Also, especially when dealing with bans it's a big deal to use UUIDs so I would switch to those if I were you (and to list variables, while your at it)
 
Status
Not open for further replies.