Raised This Month: $ Target: $400
 0% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-05-2009 , 12:30   Re: Getting the first two octects of an IP address...
Reply With Quote #1

If you want the 7 first characters, just do that :

new clientIP[8];
get_user_ip(id, clientIP, 7, 1);
Arkshine is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 02-05-2009 , 12:37   Re: Getting the first two octects of an IP address...
Reply With Quote #2

If you want both separated:

Code:
new ip[9], octet1[4], octet2[4]; get_user_ip(id, ip, 8, 1); // 111.111.XXX.XXX // ip now contains 111.111. strtok(ip, octet1, 3, ip, 7, '.'); strtok(ip, octet2, 3, ip, 7, '.'); // octet1 now contains 111 // octet2 now contains 111
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 02-05-2009 , 16:32   Re: Getting the first two octects of an IP address...
Reply With Quote #3

PHP Code:
new ip[9], newip[9];
get_user_ip(idip81); // 111.111.XXX.XXX
// ip now contains 111.111.

strtok(ipnewip3ip7'.');
add(newip8".");
strtok(ipnewip[3], 3ip7'.');
// newip contains 111.111 
Should work, not tested
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou 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