Solved Problem with Skript IP

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

Jugandoconrody

New Member
Nov 13, 2017
6
0
0
25
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_language.skript:
on load:
    clear {ips::*}

on join:
    set {ip.%player%} to ip of player
    if {ip.%player%.checkip} is not set:
        set {ip.%player%.checkip} to false
        wait 1 tick
    if {ip.%player%.checkip} is false:
        if {ips::*} contains {ip.%player%}:
            wait 1 tick
            kick the player due to "Already other user is playing with your same ip."
        else:
            set {ip.%player%.checkip} to true
            add {ip.%player%} to {ips::*}

on quit:
    if {ip.%player%.checkip} is true:
        remove {ip.%player%} from {ips::*}
        set {ip.%player%.checkip} to false
 
I think youre over-complicating this
code_language.skript:
on join:
    if "%{ips::*}%" contains "%player's ip%":
        wait 1 tick
        kick the player due to "Already other user is playing with your same ip."
   else:
        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)
 
Last edited:
It still does not work when the skript is executed with more than 2 users:

code_language.skript:
on join:
    if {ips::*} contains player's ip:
        wait 1 tick
        kick the player due to "Already other user is playing with your same ip."
    else:
        add player's ip to {ips::*}
        set {checkip.%player%} to true

on quit:
    if {checkip.%player%} is true:
        remove player's ip from {ips::*}
        set {checkip.%player%} to false

pJCWBZH.png
 
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:.
 
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:.
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.
 
If it works a lot of thanks Donut!!!

code_language.skript:
on join:
    if "%{ips::*}%" contains player's ip:
        wait 1 tick
        kick the player due to "Already other user is playing with your same ip."
    else:
        add player's ip to {ips::*}
        set {checkip.%player%} to true

on quit:
    if {checkip.%player%} is true:
        remove player's ip from {ips::*}
        set {checkip.%player%} to false
 
Status
Not open for further replies.