AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   will be [32] enought for an IP address? (https://forums.alliedmods.net/showthread.php?t=85562)

Owyn 02-12-2009 16:12

will be [32] enought for an IP address?
 
just wondering will
user_ip[32]
work fine or not

YamiKaitou 02-12-2009 16:15

Re: will be [32] enought for an IP address?
 
With port: 22
Without port: 16

Anything more than that is wasted space

Owyn 02-12-2009 16:19

Re: will be [32] enought for an IP address?
 
thx ^^ i thought so

Spunky 02-13-2009 04:28

Re: will be [32] enought for an IP address?
 
Quote:

Originally Posted by YamiKaitou (Post 760604)
Without port: 15

You mean 16. :P

xxx.xxx.xxx.xxx + 1

Exolent[jNr] 02-13-2009 07:17

Re: will be [32] enought for an IP address?
 
Code:

// 123456789012345
// xxx.xxx.xxx.xxx

// length of an IP without a port is 15

// when creating a variable for a string,
// the size should be the length + 1
// this is because the array must have 0 as it's final cell to be a string

new ip[16];


YamiKaitou 02-13-2009 08:40

Re: will be [32] enought for an IP address?
 
An IP without the port is 14 chars, so new ip[15] works.

Code:

111.111.111.111:65535
123456789012345678901


EDIT: At least everytime I do it I come up with 14 chars...


EDIT2: What do you know, they didn't line up. Original post changed as the w/port one is wrong as well.

Arkshine 02-13-2009 08:48

Re: will be [32] enought for an IP address?
 
111.111.111.111 ; 111 = 3 chars ; . = 1 char ; 4*3 + 3 = 15 chars

So it should be Ip[16];

YamiKaitou 02-13-2009 10:02

Re: will be [32] enought for an IP address?
 
I could always say that I was saying the value of charsmax for them. But, that wasn't what I intended to say, so I miscounted :P

Brad 02-13-2009 10:22

Re: will be [32] enought for an IP address?
 
Assuming AMXX can handle IPV6, 16 won't be enough.

Arkshine 02-13-2009 10:47

Re: will be [32] enought for an IP address?
 
In this case : "xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx" , it would be : 8*4 + 7 = 39 chars

So, Ip[40], if I'm right.


All times are GMT -4. The time now is 16:55.

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