[Include] GetServerIP
#1

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>
pawn Код:
#include <GSIP>
And use this function anywhere you like:
pawn Код:
GetServerIP();
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.
Reply
#2

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.
Reply
#3

Very, Very Usefull function thank you!

Reputation +1!
Reply
#4

Did you know that there's actually a Server Variable called "bind" (or was it "hind"?)
to get the server IP with GetServerVarAsString?^^
Reply
#5

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 **
Reply
#6

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.
Reply
#7

Good work
Reply
#8

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.
Reply
#9

Smart, never though of the use of the HTTP Function! Good job wups!
Reply
#10

How excatly, wups, that would be a great way to protect a server.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)