Raised This Month: $ Target: $400
 0% 

Getting the first two octects of an IP address...


Post New Thread Reply   
 
Thread Tools Display Modes
Old 02-05-2009, 18:43
Dores
This message has been deleted by Dores.
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 02-05-2009 , 18:48   Re: Getting the first two octects of an IP address...
Reply With Quote #2

This is all he wants:
PHP Code:
new ip[9];
get_user_ip(idip81);

for(new 
sizeof cafeIP i++)
{
    if(
equal(ipcafeIP[i], strlen(cafeIP[i])))
    {
        
// Give $16000
    
}

__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-05-2009 , 18:54   Re: Getting the first two octects of an IP address...
Reply With Quote #3

What about :

Code:
    #include <amxmodx>     new const cafeIP[][] = { "192.168.", "172.16.", "10.16." };     new const lenIP[ sizeof cafeIP ] = { 8, 7, 5 };     public client_connect( id )     {         new clientIP[ 9 ];         get_user_ip( id, clientIP, charsmax( clientIP ), true );                 for ( new i; i < sizeof cafeIP; i++ )         {             if ( equal( clientIP, cafeIP[ i ], lenIP[ i ] ) )             {                 //             }         }     }

Edit : Dores ownes me. Though better to not use strlen(). :p

Last edited by Arkshine; 02-05-2009 at 19:01.
Arkshine is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-05-2009 , 19:47   Re: Getting the first two octects of an IP address...
Reply With Quote #4

Won't using equal() with the length parameter be the same result as contain() ?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 02-06-2009 , 00:04   Re: Getting the first two octects of an IP address...
Reply With Quote #5

Quote:
Originally Posted by arkshine View Post
Though better to not use strlen(). :p
You're right.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-05-2009 , 20:11   Re: Getting the first two octects of an IP address...
Reply With Quote #6

Nope. It checks just the first # characters with the length parameter.
Arkshine is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 02-05-2009 , 20:43   Re: Getting the first two octects of an IP address...
Reply With Quote #7

if(contain(ip, "10.16") == 0)
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-05-2009 , 21:30   Re: Getting the first two octects of an IP address...
Reply With Quote #8

Wow. I always that the length parameter was the same as using contain. Thanks
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
P4rD0nM3
Veteran Member
Join Date: Feb 2006
Old 02-05-2009 , 22:45   Re: Getting the first two octects of an IP address...
Reply With Quote #9

Thank you very much.
P4rD0nM3 is offline
P4rD0nM3
Veteran Member
Join Date: Feb 2006
Old 02-06-2009 , 02:12   Re: Getting the first two octects of an IP address...
Reply With Quote #10

May I ask why?
P4rD0nM3 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:45.


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