This is good if you have static ip, but if you have dynamic ip like me, then you can use something like this:
PHP Code:
#include <amxmodx>
#include <sockets>
new g_ip[32]
new g_socket
public plugin_init(){
register_plugin("Get server ip", "1.0", "Sylwester")
register_clcmd("say ip", "get_server_ip")
}
public get_server_ip(id){
new error
if(g_socket>0){
client_print(id, print_chat, "Error: socket is in use")
return PLUGIN_HANDLED
}
g_socket = socket_open("www.whatsmyip.org", 80, SOCKET_TCP, error)
if(g_socket > 0){
socket_send(g_socket, "GET / HTTP/1.1^nHost: www.whatsmyip.org^n^n", 64)
client_print(id, print_chat, "Sending request...")
set_task(0.1, "recv", id)
}else{
client_print(id, print_chat, "Socket error")
}
return PLUGIN_HANDLED
}
public recv(id){
if(!socket_change(g_socket, 100))
set_task(0.1, "recv", id)
else{
new data[512], i, pos
socket_recv(g_socket, data, 511)
pos = containi(data, "Your IP is ")
if(pos>-1){
pos += 11
while(data[pos+i]=='.' || (data[pos+i]>='0' && data[pos+i]<='9')){
g_ip[i] = data[pos+i]
i++
}
client_print(id, print_chat, "Server ip: %s", g_ip)
}
socket_close(g_socket)
g_socket = 0
}
}
My plugin connects to one of the "what is my ip" websites and gets your ip. It will work as long as the website is online, the way it displays ip is not changed and you are not banned because of sending requests too often

If you have your own website you could use it for this plugin. Just make script that displays only ip on whole page (like
www.whatismyip.org but that one is down for me now so I used other) and modify this plugin.
__________________