Remove the port part of the ip ?

Hi, for the moment I use this :



	local IPAddress = string.Explode(":", ply:IPAddress())
	IPAddress = IPAddress[1]


But I think that thje result is this : 1.0151345.165.1 port

I just want this 1.0151345.165.1

[editline]30th July 2015[/editline]

Is that good ?

Why don’t you just try it? It should work though

You’re trying to assign a string value to an array.



local tblIPAddress = string.Explode(":", ply:IPAddress());
local strIPAddress = IPAddress[1];


Other than that it should work perfectly:


] lua_run PrintTable(string.Explode(':', '192.168.0.1:8080'))
> PrintTable(string.Explode(':', '192.168.0.1:8080'))...
1	=	192.168.0.1
2	=	8080
] lua_run print(string.Explode(':', '192.168.0.1:8080')[1])
> print(string.Explode(':', '192.168.0.1:8080')[1])...
192.168.0.1


You might also want to check if the IP isn’t ‘loopback’