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 our 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 Get IP Adress on Server Ping

Discussion in 'Skript' started by EisteeRamon, Aug 27, 2018.

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

    EisteeRamon Member

    Joined:
    Aug 27, 2018
    Messages:
    10
    Likes Received:
    0
    Hey,

    What I want is... If a player pings the server, a variable should be set to its IP adress. :emoji_slight_smile:

    on server list ping:
    set {allow::%player's ip%} to true

    best regards,
    Ramon
     
  2. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,049
    Likes Received:
    145
    on server list ping:
    set {allow::%player's ip%} to true <---
    This wouldn't work, because when a player pings a server, the only info the server gets it the IP... so there is no player in this event.
    --- Double Post Merged, Aug 30, 2018, Original Post Date: Aug 30, 2018 ---
    Oops forgot to add.
    The best way to do it would be that when a player joins your server, set their IP as a variable that holds their name:
    Code (Skript):
    1. on join:
    2.     set {join::%ip of player%} to player
    So when a player pings the server, you can check the owner of said IP address
    For some reason I can't find the syntax for getting the IP on a server ping event... So I just wrote a little something with Skript-Mirror as an example
    Code (Skript):
    1. on join:
    2.     set {join::/%ip of player%} to player
    3.  
    4. on server list ping:
    5.     set {_p} to event.getAddress()
    6.     if {join::%{_p}%} is set:
    7.         send "&7[&aPINGER&7] - &b%{join::%{_p}%}% &7pinged the server" to console
     
    • Like Like x 1
  3. EisteeRamon

    EisteeRamon Member

    Joined:
    Aug 27, 2018
    Messages:
    10
    Likes Received:
    0
    I can use the on connect event too
    --- Double Post Merged, Aug 30, 2018, Original Post Date: Aug 30, 2018 ---
    What I want is... The player should add the server to its serverlist. If the player try to connect he should get kicked by reason "Add the server to your server list!"
     
  4. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,049
    Likes Received:
    145
    that would be easy
    just use the server ping list, to add the IP to a list.
    And on connect, if their ip is in that list let them connect, else like them for "Add the server to your server list"
     
  5. EisteeRamon

    EisteeRamon Member

    Joined:
    Aug 27, 2018
    Messages:
    10
    Likes Received:
    0
    Example? :/
     
  6. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,049
    Likes Received:
    145
    Okay this SHOULD work... I tested it, and it seems to work (requires Skript mirror)
    Code (Skript):
    1. on server list ping:
    2.     set {_p} to "%event.getAddress()%"
    3.     replace all "/" with "" in {_p}
    4.     add {_p} to {ServerSaveList::*}
    5.     broadcast "&aPINGED BY: %{_p}%"
    6.  
    7. on connect:
    8.     if {ServerSaveList::*} contains IP of player:
    9.         send "&aCONNECTED" to console
    10.     else:
    11.         kick player due to "You need to add our server to your server list"
    12.         send "&cKICKED" to console
     
  7. EisteeRamon

    EisteeRamon Member

    Joined:
    Aug 27, 2018
    Messages:
    10
    Likes Received:
    0
  8. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,049
    Likes Received:
    145
    You're very welcome :emoji_slight_smile:
     
Thread Status:
Not open for further replies.
Loading...