anyway that i can get IpAddress and Port etc in cs:go?

Please post any questions about developing your plugin here. Please use the search function before posting!
qwexvf
Junior Member
Posts: 14
Joined: Wed Mar 22, 2017 2:36 am
Location: Tokyo/Japan
Contact:

anyway that i can get IpAddress and Port etc in cs:go?

Postby qwexvf » Sun Apr 16, 2017 12:35 pm

hi just want to get those information from my server.
i tried with server_spawn event but port and address return 0 or None for me!

any suggestions

Thanks.

-qwexvf
User avatar
Doldol
Senior Member
Posts: 200
Joined: Sat Jul 07, 2012 7:09 pm
Location: Belgium

Re: anyway that i can get IpAddress and Port etc in cs:go?

Postby Doldol » Sun Apr 16, 2017 3:04 pm

I won't comment on the git issue, since it's about not using hostip, but using that's been the most robust way for me.

Syntax: Select all

ip = ipaddress.IPv4Address(ConVar("hostip").get_int() & 0xffffffff).exploded
host = ConVar("hostport").get_int()
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: anyway that i can get IpAddress and Port etc in cs:go?

Postby satoon101 » Sun Apr 16, 2017 3:26 pm

I honestly don't like the idea of using ConVars, in this instance, because their values are easily changed. But, that does certainly work if you aren't worried about that issue.
Image
User avatar
Doldol
Senior Member
Posts: 200
Joined: Sat Jul 07, 2012 7:09 pm
Location: Belgium

Re: anyway that i can get IpAddress and Port etc in cs:go?

Postby Doldol » Sun Apr 16, 2017 6:07 pm

satoon101 wrote:I honestly don't like the idea of using ConVars, in this instance, because their values are easily changed. But, that does certainly work if you aren't worried about that issue.


I feel the same way about querying a remote host for it, it could go down, possibly locking up your plugin, imo even worse. But to each their own I suppose. :3
qwexvf
Junior Member
Posts: 14
Joined: Wed Mar 22, 2017 2:36 am
Location: Tokyo/Japan
Contact:

Re: anyway that i can get IpAddress and Port etc in cs:go?

Postby qwexvf » Tue Apr 18, 2017 10:13 am

Doldol wrote:I won't comment on the git issue, since it's about not using hostip, but using that's been the most robust way for me.

Syntax: Select all

ip = ipaddress.IPv4Address(ConVar("hostip").get_int() & 0xffffffff).exploded
host = ConVar("hostport").get_int()


thanks both of you for helping me out <3

this one works pretty well! i just was wondering if it there will be any problems running multiple instances.
by running multiple instance will this work?
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: anyway that i can get IpAddress and Port etc in cs:go?

Postby Ayuto » Tue Apr 18, 2017 5:34 pm

The ConVar solution doesn't seem to work reliably for the port:

Code: Select all

Socket bound to non-default port 27016 because original port was already in use.
WARNING: Port 27015 was unavailable - bound to port 27016 instead
Socket bound to non-default port 27006 because original port was already in use.
WARNING: Port 27005 was unavailable - bound to port 27006 instead
Socket bound to non-default port 27021 because original port was already in use.
WARNING: Port 27020 was unavailable - bound to port 27021 instead
Network: IP 192.168.178.60, mode MP, dedicated Yes, ports 27016 SV / 27006 CL
hostport
"hostport" = "27015"
 - Host game server port
sp plugin reload test3
[SP] Unloading plugin 'test3'...
[SP] Unable to unload plugin 'test3' as it is not currently loaded.
[SP] Loading plugin 'test3'...
27016
[SP] Successfully loaded plugin 'test3'.
You better use this:

Syntax: Select all

from engines.server import server

print(server.udp_port)
However, if you are starting your instances with different +hostport options, Predz code will work fine.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 39 guests