AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   hot to check LAN ip (https://forums.alliedmods.net/showthread.php?t=191349)

0920357689 07-29-2012 02:00

hot to check LAN ip
 
10.0.0.0 - 10.255.255.255
172.16.0.0 - 172.31.255.255
192.168.0.0 -192.168.255.255


how to check contain in list?

fysiks 07-29-2012 02:01

Re: hot to check LAN ip
 
Why do you need to do such a thing? Also, have you tried searching?

0920357689 07-29-2012 02:04

Re: hot to check LAN ip
 
Quote:

Originally Posted by fysiks (Post 1760346)
Why do you need to do such a thing? Also, have you tried searching?

I do not know use what keyword
only find "subnet" but find Nothing

fysiks 07-29-2012 02:07

Re: hot to check LAN ip
 
Quote:

Originally Posted by 0920357689 (Post 1760348)
I do not know use what keyword
only find "subnet" but find Nothing

Why do you refuse to answer my first question . . . ?

0920357689 07-29-2012 02:09

Re: hot to check LAN ip
 
Quote:

Originally Posted by fysiks (Post 1760350)
Why do you refuse to answer my first question . . . ?


I'm writing a real-time server list page
now plugins is done
but need to check the server is LAN or not

fysiks 07-29-2012 02:12

Re: hot to check LAN ip
 
What language are you doing this in? It doesn't really sound like an AMX Mod X thing.

DjOptimuS 07-29-2012 06:03

Re: hot to check LAN ip
 
If you want to restrict your server only for LAN, use --> sv_lan "1"

0920357689 07-29-2012 09:01

Re: hot to check LAN ip
 
Quote:

Originally Posted by DjOptimuS (Post 1760436)
If you want to restrict your server only for LAN, use --> sv_lan "1"


server can use

sv_lan = 0
192.168
in my test

0920357689 07-29-2012 09:43

Re: hot to check LAN ip
 
Quote:

Originally Posted by fysiks (Post 1760358)
What language are you doing this in? It doesn't really sound like an AMX Mod X thing.

PHP Code:

        new IpPort[32];
    
get_user_ip(0IpPort311);
    
    new 
isubent[4];
    for(
i=0i<4i++)
    {
        new 
Temp[32];
        
strtok(IpPortTemp31IpPort31'.');
        
subent[i] = str_to_num(Temp);
    }
    
server_print("%d %d %d %d",subent[0],subent[1],subent[2],subent[3]); 

i test my core is work:)

Backstabnoob 07-29-2012 10:30

Re: hot to check LAN ip
 
Try this

PHP Code:

stock ip2long( const ipaddr[ ] )
{
    
    if( 
containiipaddr":" ) != -)
        return 
0
    
    
new parts][ ], parts_num]
    
ExplodeStringparts33ipaddr"." )
    
    for( new 
i4i++ )
        
parts_num] = str_to_numparts] )
    
    
    return ( 
parts_num] * power256) + parts_num] * power256) + parts_num] * power256) + parts_num] )
    
}


// http://forums.alliedmods.net/showpost.php?p=596283&postcount=3
stock ExplodeStringOutput[][], MaxSizeInput[], Delimiter )
{
    new 
Idxstrlen(Input), Len;
    do 
Len += (copycOutput[Idx], SizeInput[Len], Delimiter ));
    while( (
Len l) && (++Idx Max) )
    return 
Idx;


This will convert an IP address into an integer. You can then compare the two ints to see if one is in the other's subnet.


All times are GMT -4. The time now is 15:27.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.