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.

Solved Problem with Skript IP

Discussion in 'Skript' started by Jugandoconrody, Nov 13, 2017.

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

    Jugandoconrody New Member

    Joined:
    Nov 13, 2017
    Messages:
    6
    Likes Received:
    0
    I need to make a skript that detects when a player with the same ip is already playing, the second player (multi account) that tries to enter is kicked.
    The skript works only with an ip, but it stops working when it comes to another ip different from the list.

    Thanks in advance


    Code (Skript):
    1.  
    2.  
    3. on load:
    4.     clear {ips::*}
    5.  
    6. on join:
    7.     set {ip.%player%} to ip of player
    8.     if {ip.%player%.checkip} is not set:
    9.         set {ip.%player%.checkip} to false
    10.         wait 1 tick
    11.     if {ip.%player%.checkip} is false:
    12.         if {ips::*} contains {ip.%player%}:
    13.             wait 1 tick
    14.             kick the player due to "Already other user is playing with your same ip."
    15.         else:
    16.             set {ip.%player%.checkip} to true
    17.             add {ip.%player%} to {ips::*}
    18.  
    19. on quit:
    20.     if {ip.%player%.checkip} is true:
    21.         remove {ip.%player%} from {ips::*}
    22.         set {ip.%player%.checkip} to false
     
  2. Donut

    Donut Well-Known Member

    Joined:
    Mar 27, 2017
    Messages:
    1,340
    Likes Received:
    176
    Medals:
    I think youre over-complicating this
    Code (Skript):
    1. on join:
    2.     if "%{ips::*}%" contains "%player's ip%":
    3.         wait 1 tick
    4.         kick the player due to "Already other user is playing with your same ip."
    5.    else:
    6.         add player's ip to {ips::*}
    also i wouldnt recommend clearing the list on load because that fires whenever the script is reloaded which includes /sk reload so if people are already online when you do that then their ips wont be in the list (you could fix this by looping the players and adding their ip to the list in the event)
     
    #2 Donut, Nov 13, 2017
    Last edited: Nov 13, 2017
  3. Jugandoconrody

    Jugandoconrody New Member

    Joined:
    Nov 13, 2017
    Messages:
    6
    Likes Received:
    0
    It still does not work when the skript is executed with more than 2 users:

    Code (Skript):
    1.  
    2. on join:
    3.     if {ips::*} contains player's ip:
    4.         wait 1 tick
    5.         kick the player due to "Already other user is playing with your same ip."
    6.     else:
    7.         add player's ip to {ips::*}
    8.         set {checkip.%player%} to true
    9.  
    10. on quit:
    11.     if {checkip.%player%} is true:
    12.         remove player's ip from {ips::*}
    13.         set {checkip.%player%} to false
    [​IMG]
     
  4. Orangejuiceyummy

    Joined:
    Jan 26, 2017
    Messages:
    20
    Likes Received:
    0
    I have also noticed it lately, that if a list variable contains more than 2/3 inputs, the contains/is thing bugs out, but I prolly just did do something wrong. I think you could loop the list and check if the loop-value contains the ip, but I could be wrong :emoji_grinning:.
     
  5. Donut

    Donut Well-Known Member

    Joined:
    Mar 27, 2017
    Messages:
    1,340
    Likes Received:
    176
    Medals:
    You didnt do anything wrong, it is very buggy. Looping like you said is definitely more reliable and i shouldve used that. in this case you can also check if "%{ips::*}%" contains "%player's ip%" which wont glitch but you shouldnt always use this method because say you have "minecraft" in the list then check if it contains "mine", it will say yes even though the list doesnt actually contain it, but it works with ips since one player's ip wont be within another.
     
  6. Jugandoconrody

    Jugandoconrody New Member

    Joined:
    Nov 13, 2017
    Messages:
    6
    Likes Received:
    0
    If it works a lot of thanks Donut!!!

    Code (Skript):
    1. on join:
    2.     if "%{ips::*}%" contains player's ip:
    3.         wait 1 tick
    4.         kick the player due to "Already other user is playing with your same ip."
    5.     else:
    6.         add player's ip to {ips::*}
    7.         set {checkip.%player%} to true
    8.  
    9. on quit:
    10.     if {checkip.%player%} is true:
    11.         remove player's ip from {ips::*}
    12.         set {checkip.%player%} to false
     
Thread Status:
Not open for further replies.

Share This Page

Loading...