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.

Tempban skript

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

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

    KroterPvP Active Member

    Joined:
    Apr 10, 2017
    Messages:
    178
    Likes Received:
    7
    Hello, I'm setting up my new skript. The title says it all, I'm having errors with the tempban module. All seems correct. I'm using timespans and the timers are perfectly displayed.

    Every second the server checks if there are banned players. To do this, it loops the variable {bans::*}. If the banned player's autounban description equals to "Never", means the player is not going to be unbanned, so it stops and jumps to other loop-value. If there are any loop-value (player) who's autounban description doesn't equal to "Never", it checks if "now" is bigger than "loop-value's time of expiration". If it's true, it should execute a command to unban, and if it's not, it should stop.

    It should work, but it doesn't. The player's aren't unbanned. The autounban description part runs well. But the part to check if the player should be unbanned is not running well.

    All code is correctly writed, without any console error. Can somebody check the code, and help me?
    Code (Skript):
    1. command /tempban [<offlineplayer>] [<text>] [<timespan>]:
    2.     permission: tempban
    3.     permission message: &cYou don't have permission to do this!
    4.     executable by: console and player
    5.     trigger:
    6.         if arg 1 is set:
    7.             if arg 2 is set:
    8.                 if arg 3 is set:
    9.                     if {sban.banned.%arg 1%} is true:
    10.                         send "&7This player is already tempbanned"
    11.                     else:
    12.                         if arg 1 has permission "sb.tempban.exempt":
    13.                             send "&7This player can't be tempbanned"
    14.                         else:
    15.                             set {_now} to now
    16.                             set {_timespan} to arg 3
    17.                             add {_timespan} to {_now}
    18.                             set {_remaining} to {_now}
    19.                             set {sban.banned.%arg 1%} to true
    20.                             set {sban.bannedon.%arg 1%} to now
    21.                             set {sban.banreason.%arg 1%} to arg 2
    22.                             set {sban.banexpire.%arg 1%} to "%{_remaining}%"
    23.                             set {sban.bannedby.%arg 1%} to "%sender%"
    24.                             set {sban.banip.%arg 1%} to false
    25.                             add arg 1 to {bans::*}
    26.                             kick arg 1 due to "&7You were &cTempBanned &7from &6ServerName"
    27.                 else:
    28.                     send "&7You must use &c/tempban <player> <reason> <timespan>"
    29.             else:
    30.                 send "&7You must use &c/tempban <player> <reason> <timespan>"
    31.         else:
    32.             send "&7You must use &c/tempban <player> <reason> <timespan>"
    33. every 1 second:
    34.     execute console command "/updatetempbantimes"
    35. command /updatetempbantimes:
    36.     permission: sban.updatetempbantimes
    37.     permission message: &cYou don't have permission to do this!
    38.     executable by: console and player
    39.     trigger:
    40.         loop {bans::*}:
    41.             if {sban.banned.%loop-value%} is true:
    42.                 if {sban.banexpire.%loop-value%} is not "Never":
    43.                     if now is bigger than {sban.banexpire.%loop-value%}:
    44.                         execute console command "/unban %loop-value%"
    Thanks,
    KroterPvP.
     
    #1 KroterPvP, Jul 9, 2017
    Last edited: Jul 9, 2017
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    It's because your stopping the loop in line 43 & 48. From what you said I think you think it just stops the current loop iteration but it actually stops the entire loop.

    So to fix it just do something like this:
    Code (Skript):
    1. loop {bans::*}:
    2.     if {sban.banned.%loop-value%} is true:
    3.         if {sban.banexpire.%loop-value%} is not "Never":
    4.             if now is bigger than {sban.banexpire.%loop-value%}:
    5.                 execute console command "/unban %loop-value%"
    If nothing happens if the condition isn't met, there's no need to have 'else'
     
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Oh, that's easyer than what I expected it was...

    Thanks, I will try this
    --- Double Post Merged, Jul 9, 2017, Original Post Date: Jul 9, 2017 ---
    No, It's not running. I don't know why but the unban command is not executed when the condition is reached.
     
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Are you saying that line 5 (line 46 in the original) is not working? Did you try testing another command there or simply broadcasting "hi"
     
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Yes, I've done it and the only condition that is not executing is
    Code (Skript):
    1. if now is bigger than {sban.banexpire.%loop-value%}:
    2.      execute console command "/unban %loop-value%
    3. # Line 43 of my thread description code"
     
  6. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    You cant compare if now is bigger than something because it looks like this: 7/9/17 9:35 AM. Instead you need to check the difference between now and the original variable you set to now. Idk if that makes sense how i explained it but here's what your code should look like:
    Code (Skript):
    1. #in the temban command you need to add this:
    2. set {sban.banlength.%arg-1%} to arg-3
    3.  
    4. #then replace line 43 with this:
    5. set {_elapsed_time} to difference between now and {sban.banexpire.%loop-value%}
    6. if {_elapsed_time} is greater than {sban.banlength.%loop-value%} :
    7.     execute console command "/unban %loop-value%"
     
  7. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    I agree with you. It should work doing that change to the code, but it doesn't.
    I don't know why is this doing that. It should work now, and it doesn't...

    What should the error be¿?
     
  8. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    can you said your current updated code
     
  9. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Code (Skript):
    1. command /tempban [<offlineplayer>] [<text>] [<timespan>]:
    2.     permission: sb.tempban
    3.     permission message: &c&lSuperBans &8» &cYou don't have permission to do this!
    4.     executable by: console and player
    5.     trigger:
    6.         if arg 1 is set:
    7.             if arg 2 is set:
    8.                 if arg 3 is set:
    9.                     if {sban.banned.%arg 1%} is true:
    10.                         send "&c&lSuperBans &8» &7This player is already tempbanned"
    11.                     else:
    12.                         if arg 1 has permission "sb.tempban.exempt":
    13.                             send "&c&lSuperBans &8» &7This player can't be tempbanned"
    14.                         else:
    15.                             set {_now} to now
    16.                             set {_timespan} to arg 3
    17.                             add {_timespan} to {_now}
    18.                             set {_remaining} to {_now}
    19.                             set {sban.banned.%arg 1%} to true
    20.                             set {sban.bannedon.%arg 1%} to now
    21.                             set {sban.banreason.%arg 1%} to arg 2
    22.                             set {sban.banexpire.%arg 1%} to "%{_remaining}%"
    23.                             set {sban.tempbanlenght.%arg 1%} to arg 3
    24.                             set {sban.bannedby.%arg 1%} to "%sender%"
    25.                             set {sban.banip.%arg 1%} to false
    26.                             add arg 1 to {bans::*}
    27.                             kick arg 1 due to "&7Sadly, you were &cTempBanned &7from &6ServerName&7. Apply on our forums if you want to dispute your ban!%nl%%nl%&7Banned by: &a%{sban.bannedby.%arg 1%}%%nl%&7Banned on: &c%{sban.bannedon.%arg 1%}%%nl%&7Autounban: &c%{sban.banexpire.%arg 1%}%%nl%&7IP Banned: &c%{sban.banip.%arg 1%}%%nl%&7Reason: &c%{sban.banreason.%arg 1%}%%nl%%nl%&eBuy an unban &8» &cwww.yourserver.buycraft.net%nl%&eForums to apply &8» &cwww.yourserver.net"
    28.                             loop all players:
    29.                                 if loop-player has permission "sb.tempban.notify":
    30.                                     send "&c&lSuperBans &8» &7I have handled a &a&lNEW BAN&r&7!" to loop-player
    31.                                     send "" to loop-player
    32.                                     send " &7Player banned &8» &e%arg 1%" to loop-player
    33.                                     send " &7Banned by &8» &a%sender%" to loop-player
    34.                                     send " &7Ban reason &8» &7'&a%arg 2%&7'" to loop-player
    35.                                     send " &7Autounban &8» &a%{_remaining}% &7(&a%arg 3%&7)" to loop-player
    36.                             send "&cSuperBans&8: &a%sender% &7banned &e%arg 1% &7('&a%arg 2%&7') &7- (&a%arg 3%&7)" to console
    37.                 else:
    38.                     send "&c&lSuperBans &8» &7You must use &c/tempban <player> <reason> <timespan>"
    39.             else:
    40.                 send "&c&lSuperBans &8» &7You must use &c/tempban <player> <reason> <timespan>"
    41.         else:
    42.             send "&c&lSuperBans &8» &7You must use &c/tempban <player> <reason> <timespan>"
    43. every 1 second:
    44.     execute console command "/updatetempbantimes"
    45. command /updatetempbantimes:
    46.     permission: sban.updatetempbantimes
    47.     permission message: &c&lSuperBans &8» &cYou don't have permission to do this!
    48.     executable by: console and player
    49.     trigger:
    50.         loop {bans::*}:
    51.             if {sban.banned.%loop-value%} is true:
    52.                 if {sban.banexpire.%loop-value%} is not "Never":
    53.                     set {_elapsedtime} to difference between now and {sban.banexpire.%loop-value%}
    54.                     if {_elapsedtime} is greater than {sban.tempbanlenght.%loop-value%}:
    55.                         execute console command "/unban %loop-value%"
     
  10. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    remove quotes in line 22:
    Code (Skript):
    1. set {sban.banexpire.%arg 1%} to {_remaining}
     
  11. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220

    But this variable is not used in the /updatetempbantimes, so it is not causing the error.

    (EDIT: I can't remove the quotes, because without them the text is not displayed.
    DOUBLE EDIT: Oh, Yes, I can remove it and it's displayed.)

    TRIPLE EDIT: Oh, I look silly with many edits! It's fixed removing quotes!
     
    #11 ShaneBee, Jul 9, 2017
    Last edited by a moderator: Jul 9, 2017
Thread Status:
Not open for further replies.

Share This Page

Loading...