Server Protection - 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 Protection (
/showthread.php?tid=602993)
Server Protection -
K0P - 16.03.2016
Hi,i made a code for server port and ip check,but i want a better and optimized code,also i want it allow running on localhost,this code closes the server everytime,i added the bind and port in server.cfg file
PHP код:
new ServerIp[16];
GetServerVarAsString("bind", ServerIp, sizeof(ServerIp));
if(strcmp(ServerIp, SERVER_IP, false)!=0 || isnull(ServerIp))
{
if((strcmp(ServerIp, "127.0.0.1", false) != 0) || (strcmp(ServerIp, "localhost", false) != 0) || isnull(ServerIp)){
} else { SendRconCommand("exit"); print("The ip and port is not correct"); }
}
if(GetServerVarAsInt("port") != SERVER_PORT)
{
SendRconCommand("exit");
}
Re: Server Protection -
czerwony03 - 16.03.2016
PHP код:
new ServerIp[16];
GetServerVarAsString("bind", ServerIp, sizeof(ServerIp));
if(strcmp(ServerIp, SERVER_IP, false)!=0 || isnull(ServerIp))
{
if((strcmp(ServerIp, "127.0.0.1", false) != 0 && strcmp(ServerIp, "localhost", false) != 0) || isnull(ServerIp)) {SendRconCommand("exit"); print("The ip and port is not correct"); }
}
if(GetServerVarAsInt("port") != SERVER_PORT)
{
SendRconCommand("exit");
}
Re: Server Protection -
K0P - 16.03.2016
LOL,what change you made?
Re: Server Protection -
czerwony03 - 16.03.2016
logic change, so that it will work as you want, on localhost and 127.0.0.1
Re: Server Protection -
AbyssMorgan - 16.03.2016
Use
https://sampforum.blast.hk/showthread.php?tid=600408