Page 1 of 1
anyway that i can get IpAddress and Port etc in cs:go?
Posted: Sun Apr 16, 2017 12:35 pm
by qwexvf
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
Re: anyway that i can get IpAddress and Port etc in cs:go?
Posted: Sun Apr 16, 2017 12:55 pm
by satoon101
Re: anyway that i can get IpAddress and Port etc in cs:go?
Posted: Sun Apr 16, 2017 3:04 pm
by Doldol
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()
Re: anyway that i can get IpAddress and Port etc in cs:go?
Posted: Sun Apr 16, 2017 3:26 pm
by satoon101
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.
Re: anyway that i can get IpAddress and Port etc in cs:go?
Posted: Sun Apr 16, 2017 6:07 pm
by Doldol
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
Re: anyway that i can get IpAddress and Port etc in cs:go?
Posted: Tue Apr 18, 2017 10:13 am
by qwexvf
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?
Re: anyway that i can get IpAddress and Port etc in cs:go?
Posted: Tue Apr 18, 2017 5:34 pm
by Ayuto
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.