GetServerIP -
wups - 23.09.2011
GetServerIP v1
Well, I saw
this thread, and I thought - why not script it?
It's only a simple HTTP request for a php script to return the IP. It's stored in a variable for later use.
ChangeLog:
Quote:
Version 1:
-Initial release.
|
Usage:
Insert this code on top of your game mode after #include <a_samp>
And use this function anywhere you like:
An example:
pawn Код:
public OnPlayerConnect(playerid)
{
new msg[100];
format(msg,sizeof(msg)," Our server IP is %s",GetServerIP());
SendClientMessage(playerid,-1,msg);
}
Installing:
Download and save to pawn/includes folder!
Download:
Version 1.1
NOTE: You CAN'T use this function in OnGameModeInit/OnFilterScriptInit. I don't think there's a way to fix it.
Feel free to do anything you want with it.
Re: GetServerIP -
IstuntmanI - 23.09.2011
OMG, that's awesome ! O.o
I'll use this ! Many, many thanks.
PS: First.
Add this to your signature.
EDIT: Oh, I forgot, +1.
Re: GetServerIP -
Edvin - 23.09.2011
Very, Very Usefull function thank you!
Reputation +1!
Re: GetServerIP - Double-O-Seven - 23.09.2011
Did you know that there's actually a Server Variable called "bind" (or was it "hind"?)
to get the server IP with GetServerVarAsString?^^
Re: GetServerIP -
IstuntmanI - 23.09.2011
Quote:
Originally Posted by Double-O-Seven
Did you know that there's actually a Server Variable called "bind" (or was it "hind"?)
to get the server IP with GetServerVarAsString?^^
|
Yeah, use "bind" with a # before and see. Put this: ( exactly this )
Код:
#bind 183.523.241.41
Won't work, server IP remains unchanged, but GetServerVarAsString will get 183.523.241.41...
EDIT: wups, Change
Код:
#if defined FILTERSCRIPTS
to
Код:
#if defined FILTERSCRIPT
EDIT2: A native from SA:MP would be better for dynamic IPs, we'd can use **
Re: GetServerIP -
HyperZ - 23.09.2011
Quote:
Originally Posted by Double-O-Seven
Did you know that there's actually a Server Variable called "bind" (or was it "hind"?)
to get the server IP with GetServerVarAsString?^^
|
Yee but we will need to put this "bind (SERVER IP)" in server.cfg

.
Correct me if im wrong plexx. ^^
Anyways good job wups.
Re: GetServerIP -
Sasino97 - 23.09.2011
Good work
Re: GetServerIP -
wups - 23.09.2011
Quote:
Originally Posted by HyperZ
Yee but we will need to put this "bind (SERVER IP)" in server.cfg  .
Correct me if im wrong plexx. ^^
Anyways good job wups.
|
Yes, that's the reason I made this.
You can also secure your GM by checking the IP if it's your servers ^^
Updated with fix for filterscripts.
Re: GetServerIP -
Lorenc_ - 23.09.2011
Smart, never though of the use of the HTTP Function! Good job wups!
Re: GetServerIP -
Fat - 23.09.2011
How excatly, wups, that would be a great way to protect a server.