Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] how to get the last digit of a player's IP

 
  • 0 Vote(s) - 0 Average
Pawn how to get the last digit of a player's IP
mems
Offline

Burgershot Member
Posts: 31
Threads: 3
Joined: Sep 2020
Reputation: 0
#1
2021-07-15, 09:38 PM (This post was last modified: 2021-07-16, 01:06 AM by mems.)
hello,

title simply says it all but i'm going to elaborate a bit. i'm trying to make an anti proxy system and so far it works. however i want to whitelist ips like 192.168.1.1 until 192.168.1.255. however, it seems like i dont know how, even though i tried so many times with different approaches such as strfind, strlen, strdel but these didnt help me out either probably because the way i did it didn't work. well here's the code:

Code:
forward httpResponse(playerid, response_code, data[]);
public httpResponse(playerid, response_code, data[])
{
    new name[MAX_PLAYERS], string[192], ipstring[64];
    new ip[16];
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerIp(playerid, ip, sizeof(ip));
    format(ipstring, sizeof(string), "192.168.1.%d", strlen(ip) - 13);
    if(strcmp(ip, "127.0.0.1", true) == 0 || strcmp(ip, ipstring, true) == 0)
    {
        printf("%s(%d) IP(%s) is a LAN type, therefore able to enter the server.", name, playerid, ip);
        return 1;
    }
    // If the site sends an OK message
    if(response_code == 200)
    {
        // If a player is using VPN
        if(data[0] == 'Y')
        {
            format(string, sizeof(string), "ANTI VPN: %s(%d) has been kicked from the server due to VPN usage.", name, playerid);
            SendClientMessageToAll(COLOR_RED, string);
            printf("%s(%d) IP(%s) is not legit, therefore not able to enter the server.", name, playerid, ip);
            //SetTimerEx("DelayKick", 100, false, "i", playerid);
        }
        // If not
        if(data[0] == 'N')
        {
            printf("%s(%d) IP(%s) is legit, therefore able to enter the server.", name, playerid, ip);
            // OnPlayerConnect welcome messages should handle this
        }
        // Failsafe. Should not trigger
        if(data[0] == 'X')
        {
            printf("From the site: Wrong IP format!");
        }
    } else {
        printf("The request failed! The response code was: %d", response_code);
    }
    return 1;
}

much appreciated if anyone could help, ive been trying to fix this issue for like hours.

edit: i could do it the worst way which is:
Code:
if(strcmp(ip, "192.168.1.1", true) == 0)
then 192.168.1.2 and so on but it sucks
« Next Oldest | Next Newest »



Messages In This Thread
how to get the last digit of a player's IP - by mems - 2021-07-15, 09:38 PM
RE: how to get the last digit of a player's IP. - by Kwarde - 2021-07-15, 11:09 PM
RE: how to get the last digit of a player's IP. - by mems - 2021-07-15, 11:27 PM
RE: how to get the last digit of a player's IP. - by Kwarde - 2021-07-15, 11:37 PM
RE: how to get the last digit of a player's IP. - by mems - 2021-07-15, 11:49 PM
RE: how to get the last digit of a player's IP. - by Kwarde - 2021-07-15, 11:56 PM
RE: how to get the last digit of a player's IP. - by mems - 2021-07-16, 12:04 AM
RE: how to get the last digit of a player's IP. - by Kwarde - 2021-07-16, 12:18 AM
RE: how to get the last digit of a player's IP. - by mems - 2021-07-16, 12:26 AM
RE: how to get the last digit of a player's IP - by mems - 2021-07-16, 06:59 PM
RE: how to get the last digit of a player's IP - by Kwarde - 2021-07-16, 07:14 PM
RE: how to get the last digit of a player's IP - by mems - 2021-07-16, 07:19 PM
RE: how to get the last digit of a player's IP - by Kwarde - 2021-07-16, 07:36 PM
RE: how to get the last digit of a player's IP - by mems - 2021-07-16, 08:17 PM
RE: how to get the last digit of a player's IP - by Kwarde - 2021-07-16, 08:26 PM
RE: how to get the last digit of a player's IP - by mems - 2021-07-16, 08:33 PM
RE: how to get the last digit of a player's IP - by Kwarde - 2021-07-16, 11:26 PM

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode