Raised This Month: $ Target: $400
 0% 

missed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
007asha
Member
Join Date: Mar 2010
Old 10-02-2010 , 12:15   missed
Reply With Quote #1

missed

Last edited by 007asha; 10-18-2016 at 04:55.
007asha is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 10-02-2010 , 13:23   Re: /ip = show server IP
Reply With Quote #2

Code:
#pragma semicolon 1
#include <amxmodx>

#define VERSION "1.0"

new g_Ip[25];

public plugin_init()
{
    register_plugin("Show Server ip", VERSION, "Drekes");
    
    register_clcmd("say /ip", "Cmd_ShowIP");
    register_clcmd("server_ip", "Cmd_ShowIP");
    
    get_user_ip(0, g_Ip, charsmax(g_Ip));
}

public Cmd_ShowIP(id)
    client_print(id, print_chat, "Server IP: %s", g_Ip);
untested.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 10-02-2010 , 22:51   Re: /ip = show server IP
Reply With Quote #3

You won't get external ip that way.

Try this (write ip in chat):
http://forums.alliedmods.net/showthr...96#post1157296
__________________
Impossible is Nothing
Sylwester is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-02-2010 , 23:49   Re: /ip = show server IP
Reply With Quote #4

This will handle if the server doesn't respond and parsing is simplified.
PHP Code:
#include <amxmodx>
#include <sockets>

new const Version[] = "0.1";

const 
TASK_GETIP 3467;

new 
g_szServerIP16 ];

public 
plugin_init() 
{
    
register_plugin"Get Internet IP" Version "bugsy" );
    
    
register_clcmd"say /ip" "GetIP" );
}

public 
GetIPid )
{
    if ( 
g_szServerIP] )
    {
        
client_printid print_chat "* Server IP is [ %s ]" g_szServerIP );
        return;
    }
    
    new 
iSocket iError;
    
    
iSocket socket_open"checkip.dyndns.com" 80 SOCKET_TCP iError );
    
    if ( !
iSocket || iError )
    {
        
client_printid print_chat "* Error creating socket, unable to obtain IP" );
        return;
    }
        
    
socket_sendiSocket "GET / HTTP/1.1^nHost: checkip.dyndns.com^n^n" 42 );
    
    new 
iData];
    
iData] = iSocket;
    
iData] = id;
    
iData] = get_systime();
    
    
set_task0.2 "RecvData" TASK_GETIP iData sizeofiData ) , "b" );
}

public 
RecvDataiData] )
{
    static 
szData256 ] , iStartPos iEndPos;
    new 
iSocket iData];
    new 
iRequestPlayer iData];
    new 
iRequestTime iData];
    
    if ( 
socket_changeiSocket ) )
    {
        
socket_recviSocket szData charsmaxszData ) );
        
        
iStartPos strfindszData "Current IP Address: " );
        
        if ( 
iStartPos != -)
        {
            
iEndPos strfindszData "</body>" );
            
copyg_szServerIP iEndPos - ( iStartPos 20 ) , szDataiStartPos 20 ] );
            
            
socket_closeiSocket );
            
remove_taskTASK_GETIP );
            
            
client_printiRequestPlayer print_chat "* Server IP is [ %s ]" g_szServerIP );
        }
    }
    
    if ( ( 
get_systime() - iRequestTime ) >= )
    {
        
socket_closeiSocket );
        
remove_taskTASK_GETIP );
        
        
client_printiRequestPlayer print_chat "* checkip.dyndns.com failed to respond, unable to obtain IP" );
    }

__________________

Last edited by Bugsy; 10-03-2010 at 00:44.
Bugsy is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 10-03-2010 , 03:20   Re: /ip = show server IP
Reply With Quote #5

Quote:
Originally Posted by drekes View Post
Code:
#pragma semicolon 1
#include <amxmodx>

#define VERSION "1.0"

new g_Ip[25];

public plugin_init()
{
    register_plugin("Show Server ip", VERSION, "Drekes");
    
    register_clcmd("say /ip", "Cmd_ShowIP");
    register_clcmd("server_ip", "Cmd_ShowIP");
    
    get_user_ip(0, g_Ip, charsmax(g_Ip));
}

public Cmd_ShowIP(id)
    client_print(id, print_chat, "Server IP: %s", g_Ip);
untested.

It works for me I think, I've done same plugin, that worked in same method.
reinert is offline
Old 10-03-2010, 07:04
007asha
This message has been deleted by 007asha.
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 10-03-2010 , 07:17   Re: /ip = show server IP
Reply With Quote #6

if its written this way
Code:
get_user_ip(id=0,input,len)
its gets server ip.
SpeeDeeR is offline
Old 10-03-2010, 09:29
007asha
This message has been deleted by 007asha.
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-03-2010 , 11:34   Re: /ip = show server IP
Reply With Quote #7

get_user_ip( 0 , ip , len ) will return only the internal IP address (192.168.1.XX), not the external IP (internet IP). If you don't understand this, retrieve both values and compare to see. The internal IP is only accessible for connecting by users on the same LAN. The external IP is what the rest of the world uses to connect to your server.
__________________
Bugsy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:11.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode