Raised This Month: $ Target: $400
 0% 

how to get server name,map,player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RuRuRu612754
Senior Member
Join Date: Sep 2011
Old 06-27-2012 , 09:34   how to get server name,map,player
Reply With Quote #1

Hello

how to get server name,map,player?
i think use Sockets ...
but, i can't use this

best regards,
RuRuRu612754 is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 06-27-2012 , 10:31   Re: how to get server name,map,player
Reply With Quote #2

What do you say lol ?

I give you an example to have a player name :
Code:
#include < amxmodx > public plugin_init( ) {     register_plugin( "test" , "1.0" , "Aooka" );         register_clcmd( "say /name" , "CmdName" ); } public CmdName( const id ) {     new szName[ 32 ];         get_user_name( id , szName , 31 );         client_print( id , print_chat , "My name is : %s" , szName ); }

For the name of a map use it : http://www.amxmodx.org/funcwiki.php?go=func&id=244

For the server name good question ^^
__________________
Pawn ? Useless

Last edited by Aooka; 06-27-2012 at 10:31.
Aooka is offline
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 06-27-2012 , 11:25   Re: how to get server name,map,player
Reply With Quote #3

To get player name:

Spoiler


I think same method will be used to get map name:

Spoiler


Don't know we could get server name ?
Waleed is offline
Send a message via Skype™ to Waleed
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-27-2012 , 11:31   Re: how to get server name,map,player
Reply With Quote #4

Code:
#include <amxmodx> public plugin_init() {     register_clcmd( "say /details", "ClientCommand_Details" ); } public ClientCommand_Details( id ) {     new szName[ 32 ], szMapName[ 32 ], szHostName[ 64 ];         get_user_name( id, szName, charsmax( szName ) );     get_mapname( szMapName, charsmax( szMapName ) );     get_cvar_string( "hostname", szHostName, charsmax( szHostName ) );         client_print( id, print_chat, "->  Server name is %s  -> Map name is %s  -> Your name is %s", szName, szMapName, szHostName ); }
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 06-27-2012 , 11:34   Re: how to get server name,map,player
Reply With Quote #5

Maybe he want to take it from another server because he said 'sockets'.
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-27-2012 , 11:39   Re: how to get server name,map,player
Reply With Quote #6

Oh, whoops :S Well best take a look here if Neel's right http://forums.alliedmods.net/showthread.php?t=169315
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
RuRuRu612754
Senior Member
Join Date: Sep 2011
Old 06-27-2012 , 12:36   Re: how to get server name,map,player
Reply With Quote #7

Quote:
Originally Posted by Neeeeeeeeeel.- View Post
Maybe he want to take it from another server because he said 'sockets'.
Yes
I want get another server "server name" "server map" "server activeplayer count" "server maxplayer count"

Quote:
Originally Posted by hornet View Post
Oh, whoops :S Well best take a look here if Neel's right http://forums.alliedmods.net/showthread.php?t=169315
Thanks
But, Here is my information seeking is not available.
Official wiki information is missing also.

Best regards,
RuRuRu612754 is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 06-27-2012 , 12:44   Re: how to get server name,map,player
Reply With Quote #8

@Hornet: Thanks for that
Code:
get_cvar_string( "hostname", szHostName, charsmax( szHostName ) );
__________________
Pawn ? Useless
Aooka is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 06-27-2012 , 13:04   Re: how to get server name,map,player
Reply With Quote #9

Not tested but should work, i'm n00b at sockets. I started with them like two weeks ago, let me know if there are any other better way to do this

PHP Code:
#include < amxmodx >
#include < sockets >

#define PLUGIN "Sockets example"
#define VERSION "1.0"
#define AUTHOR "Neeeeeeeeeel.-"

new iSocket;

new 
iConnected;

new const 
szHost[ ] = { "XXX.XXX.XXX.XXX" };

new const 
szGetmap[ ] = { "getmap" };

const 
iPort 27015;

const 
TASK_SOCKETINIT 3391;
const 
TASK_RECVSOCKET 3378;

public 
plugin_init( ) 
{
    
register_pluginPLUGINVERSIONAUTHOR );
    
    
set_task20.0"CheckConnection"TASK_SOCKETINIT__"b" );
    
    
set_task10.0"RecvSocket"TASK_RECVSOCKET__"b" );
    
    
register_concmd"say /getmap""cmdGetMap" );
}

public 
cmdGetMap( )
{
    if( 
iConnected )
        
socket_sendiSocketszGetmapcharsmaxszGetmap ) );
    else
        
client_print0print_chat"Server not connected" );
}

public 
SocketInit( )
{
    new 
iError;

    
iSocket socket_openszHostiPortSOCKET_UDPiError );
    
    if( 
iSocket || iError )
        return;
    
    new 
data32 ];
    
    
get_user_ip0datacharsmaxdata ) );
    
    
formatexdatacharsmaxdata ), "%s on"data );
    
    
socket_sendiSocketdatacharsmaxdata ) );
}

public 
RecvSocket( )
{    
    if( 
socket_changeiSocket110000 ) )
    {
        static 
data512 ];
        
        
socket_recviSocketdatacharsmaxdata ) );
        
        if( 
containidata"off" ) != -)
        {
            
socket_closeiSocket );
            
            
iConnected 0;
            
            static 
szIP32 ];
            
parsedataszIPcharsmaxszIP ) );
            
            
client_print0print_chat"%s disconnected"szIP );
            
            
set_task20.0"CheckConnection"TASK_SOCKETINIT__"b" );
        }
        
        else if( 
containidata"connected" ) != -)
            
iConnected 1;
        
        else if( 
containidata"on" ) != -)
        {
            static 
szIP24 ];
            
parsedataszIPcharsmaxszIP ) );
            
            
client_print0print_chat"%s connected"szIP );
        }
        
        else if( 
containidata"getmap" ) != -)
        {
            static 
szMapname64 ];
            
get_mapnameszMapnamecharsmaxszMapname ) );
            
            
formatexszMapnamecharsmaxszMapname ), "^"%s^" mapname" );
            
            
socket_sendiSocketszMapnamecharsmaxszMapname ) );
        }
        
        else if( 
containidata"mapname" ) != -)
        {
            static 
szMapname64 ];
            
parsedataszMapnamecharsmaxszMapname ) );
            
            
remove_quotesszMapname );
            
            
client_print0print_chat"The map from the other server is %s"szMapname );
        }
    }
}

public 
CheckConnection( )
{
    if( 
iConnected )
        
remove_taskTASK_SOCKETINIT );
    else
        
SocketInit( );
}

public 
plugin_end( )
{
    new 
data32 ], ip32 ];
    
    
get_user_ipipcharsmaxip ) );
    
formatexdatacharsmaxdata ), "%s off"ip );
    
    
socket_sendiSocketdatacharsmaxdata ) );
    
    
socket_closeiSocket );

__________________

Last edited by Neeeeeeeeeel.-; 06-27-2012 at 13:08.
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-27-2012 , 15:30   Re: how to get server name,map,player
Reply With Quote #10

https://forums.alliedmods.net/showthread.php?t=142858

Code:
public CmdServerInfo( iPlayer ) {     new iData[ 2 ], iError;     iData[ 0 ] = iPlayer;         sq_query( "12.34.56.78", 27015, SQ_Server, "SQueryInfo", iError, _, iData, sizeof( iData ) ); } public SQueryInfo( iQueryID, iType, Trie:tBuffer, Float:flTime, bool:bFailed, iData[ ], iDataSize ) {     new iPlayer = iData[ 0 ];         if( bFailed )     {         client_print( iPlayer, print_chat, "* Failed to get server information" );     }     else     {         new szServerName[ 64 ], szMap[ 64 ], iNumPlayers, iMaxPlayers;                 TrieGetString( tBuffer, "server_name", szServerName, charsmax( szServerName ) );         TrieGetString( tBuffer, "map", szMap, charsmax( szMap ) );         TrieGetCell( tBuffer, "num_players", iNumPlayers );         TrieGetCell( tBuffer, "max_players", iMaxPlayers );                 client_print( iPlayer, print_chat, "* Server Name: %s | Map: %s | Players: %d / %d", szServerName, szMap, iNumPlayers, iMaxPlayers );     } }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply


Thread Tools
Display Modes

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 06:19.


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