SA-MP Forums Archive
Server port - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Server port (/showthread.php?tid=579959)



Server port - AlexBlack - 01.07.2015

Hi , i want to make a system to check if the ports is 7777 for example or not , if not the gamemode will close connection, is that possible ?


Re: Server port - Suicidal.Banana - 01.07.2015

You cant get the actual port, but you can do something close too what you want with ip:

1] edit your server.cfg, add this line:
Код:
bind <yourserverip>
2] Add this code, run the function to retrieve the ip from server.cfg
Код:
stock GetServerIP()
{
	static
		sIp[16]
	;
	GetServerVarAsString("bind", sIp, sizeof(sIp));
	return sIp;
}
So then you can just do something like
Код:
if( !strcmp(GetServerIP( ), "***.***.***.***" )) { print( "Your IP isn't correct !" ); }
(where ***.***.***.*** would be the ip you expect to find in the server.cfg)