AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Catching "reconnect" command. (https://forums.alliedmods.net/showthread.php?t=102426)

BOYSplayCS 09-02-2009 09:33

Catching "reconnect" command.
 
How would I go about doing this? Please, don't ask me why, it's a secret that will be reveled soon ;).

ot_207 09-02-2009 09:55

Re: Catching "reconnect" command.
 
register_clcmd("reconnect", "haha")

One 09-02-2009 10:07

Re: Catching "reconnect" command.
 
PHP Code:

register_clcmd("reconnect""haha")

public 
haha()
{
new 
name[33]
get_user_name(id,name,32)
client_print(0,print_chat,"user %s isn idiot & trys to reconnect",name)



Exolent[jNr] 09-02-2009 10:12

Re: Catching "reconnect" command.
 
I don't think the "reconnect" and "retry" commands can be hooked via register_clcmd( ).

You should try saving player data when the player disconnects.
Then, then a player connects, check to see if the player's data was saved.
If the player hasn't connected after X minutes from disconnecting, remove the saved data.

SnoW 09-02-2009 11:40

Re: Catching "reconnect" command.
 
Yes, they aren't send to the server. I believe the best way would be checking if connected player is the one that left previously.

Alucard^ 09-02-2009 14:38

Re: Catching "reconnect" command.
 
Also, you can check the method viewing the code of plugins like No retry, No reconnect, etc...

Javivi 09-02-2009 16:46

Re: Catching "reconnect" command.
 
Yes, watch this plugin:

http://forums.alliedmods.net/showthread.php?t=63484

Exolent[jNr] 09-02-2009 17:02

Re: Catching "reconnect" command.
 
This one does it better:
http://forums.alliedmods.net/showthread.php?t=101937

EDIT:

I decided to write up an example of one that is like the link provided above, but also has support for removing the data after X minutes since the player left.

Code:
#include < amxmodx > #include < amxmisc > const TASK_ID_REMOVE = 1337; new Array:g_aReconnectSteamIDs; new Trie:g_tArrayPos; new g_iArraySize; public plugin_init( ) {     g_aReconnectSteamIDs = ArrayCreate( 35 );     g_tArrayPos = TrieCreate( ); } public plugin_end( ) {     ArrayDestroy( g_aReconnectSteamIDs );     TrieDestroy( g_tArrayPos ); } public client_authorized( client ) {     static szAuthid[ 35 ];     get_user_authid( client, szAuthid, 34 );         static iArrayPos;     if( !TrieGetCell( g_tArrayPos, szAuthid, iArrayPos ) )     {         return;     }         // client reconnected         RemoveReconnect( szAuthid, iArrayPos ) } public client_disconnect( client ) {     static szAuthid[ 35 ];     get_user_authid( client, szAuthid, 34 );         set_task( 60.0, "TaskRemoveReconnect", TASK_ID_REMOVE + AddReconnect( szAuthid ) ); } public TaskRemoveReconnect( iTaskId ) {     RemoveReconnect( _, ( iTaskId - TASK_ID_REMOVE ) ); } AddReconnect( szGivenAuthid[ ] ) {     static szAuthid[ 35 ], iArrayPos;         for( iArrayPos = 0; iArrayPos < g_iArraySize; iArrayPos++ )     {         ArrayGetString( g_aReconnectSteamIDs, iArrayPos, szAuthid, 34 );                 if( !szAuthid[ 0 ] )         {             ArraySetString( g_aReconnectSteamIDs, iArrayPos, szGivenAuthid );             TrieSetCell( g_tArrayPos, szGivenAuthid, iArrayPos );                         return iArrayPos;         }     }         iArrayPos = g_iArraySize++;         ArrayPushString( g_aReconnectSteamIDs, szGivenAuthid );     TrieSetCell( g_tArrayPos, szGivenAuthid, iArrayPos );         return iArrayPos; } RemoveReconnect( szGivenAuthid[ ]="", iGivenArrayPos=-1 ) {     static szAuthid[ 35 ], iArrayPos;     copy( szAuthid, 34, szGivenAuthid );     iArrayPos = iGivenArrayPos;         if( !szAuthid[ 0 ] )     {         if( iArrayPos < 0 )         {             return;         }                 ArrayGetString( g_aReconnectSteamIDs, iArrayPos, szAuthid, 34 );     }     else if( iArrayPos < 0 )     {         if( !TrieGetCell( g_tArrayPos, szAuthid, iArrayPos ) )         {             return;         }     }         ArraySetString( g_aReconnectSteamIDs, iArrayPos, "" );     TrieDeleteKey( g_tArrayPos, szAuthid );         remove_task( TASK_ID_REMOVE + iArrayPos ); }

BOYSplayCS 09-02-2009 19:01

Re: Catching "reconnect" command.
 
That's a decent size script for such a small idea.


All times are GMT -4. The time now is 15:12.

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