• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] how to get the last digit of a player's IP
#11
Then you are still doing something wrong.
Code:
#include <a_samp>
#include <sscanf2>

main()
{
    new
        IP_LAN[] = "192.168.1.69",
        IP_PUBLIC[] = "86.88.190.219",
        
        ip_lan_part[4], ip_public_part[4]
    ;
    sscanf(IP_LAN, "p<.>dddd", ip_lan_part[0], ip_lan_part[1], ip_lan_part[2], ip_lan_part[3]);
    sscanf(IP_PUBLIC, "p<.>dddd", ip_public_part[0], ip_public_part[1], ip_public_part[2], ip_public_part[3]);

    if (ip_lan_part[0] == 192 && ip_lan_part[1] == 168 && ip_lan_part[2] == 1 && (1 <= ip_lan_part[3] <= 255))
    {
        print("IP_LAN: Is accepted LAN");
    }
    else
    {
        print("IP_LAN: Is NOT accepted LAN");
    }

    if (ip_public_part[0] == 192 && ip_public_part[1] == 168 && ip_public_part[2] == 1 && (1 <= ip_public_part[3] <= 255))
    {
        print("IP_PUBLIC: Is accepted LAN");
    }
    else
    {
        print("IP_PUBLIC: Is NOT accepted LAN");
    }
}

100% guaranteed that the output is:
Quote:IP_LAN: Is accepted LAN
IP_PUBLIC: Is NOT accepted LAN


Is your public server home hosted? If so, when connecting to the public server's IP on the same network the server is hosted on, it will use your default gateway. If not, you still did something wrong in your script. (I confirmed the script works the first time already -- I usually test something before posting it, even if I'm already sure it would work)
  Reply


Messages In This Thread
RE: how to get the last digit of a player's IP - by Kwarde - 2021-07-16, 07:14 PM

Forum Jump: