AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Handle disconected (https://forums.alliedmods.net/showthread.php?t=226136)

quark 09-14-2013 04:30

Handle disconected
 
Hey guys! Is possible to handle disconected players information and check after 5 minutes if he entered again?

dark_style 09-14-2013 04:40

Re: Handle disconected
 
I think ConnorMcLeod's Reconnect Features plugin should help you. :)

Backstabnoob 09-14-2013 05:59

Re: Handle disconected
 
You can easily do something like this:

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #define PLUGIN "New Plugin" #define VERSION "1.0" #define AUTHOR "Author" new Trie: g_tPlayersLastConnection public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         g_tPlayersLastConnection = TrieCreate( ) } public client_disconnect( id ) {     new szAuthid[ 34 ]     get_user_authid( id, szAuthid, charsmax( szAuthid ) )         TrieSetCell( g_tPlayersLastConnection, szAuthid, get_systime( ) ) } public client_putinserver( id ) {     new szAuthid[ 34 ]     get_user_authid( id, szAuthid, charsmax( szAuthid ) )                 new iTime     TrieGetCell( g_tPlayersLastConnection, szAuthid, iTime )         if( get_systime( ) - iTime <= 300 )     {         // player has reconnected within 5 minutes     } }

quark 09-14-2013 07:34

Re: Handle disconected
 
Quote:

Originally Posted by Backstabnoob (Post 2034245)
You can easily do something like this:

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #define PLUGIN "New Plugin" #define VERSION "1.0" #define AUTHOR "Author" new Trie: g_tPlayersLastConnection public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         g_tPlayersLastConnection = TrieCreate( ) } public client_disconnect( id ) {     new szAuthid[ 34 ]     get_user_authid( id, szAuthid, charsmax( szAuthid ) )         TrieSetCell( g_tPlayersLastConnection, szAuthid, get_systime( ) ) } public client_putinserver( id ) {     new szAuthid[ 34 ]     get_user_authid( id, szAuthid, charsmax( szAuthid ) )         if( !TrieKeyExists( g_tPlayersLastConnection, szAuthid ) )         return                     new iTime     TrieGetCell( g_tPlayersLastConnection, szAuthid, iTime )         if( get_systime( ) - iTime <= 300 )     {         // player has reconnected within 5 minutes     } }

How can I do something with his steamid if he does not connect again?

Black Rose 09-14-2013 09:20

Re: Handle disconected
 
Code:
set_task(60.0*5, "prune", _, szAuthid, strlen(szAuthid)); public prune(szAuthid[]) {     TrieDeleteKey(g_tPlayersLastConnection, szAuthid); }

EDIT: If this is used you don't actually have to check the value of the trie cell. You also don't need to set a time for it. If it exists with any value the reconnect was within 5 minutes.

Backstabnoob 09-14-2013 11:39

Re: Handle disconected
 
Quote:

Originally Posted by quark (Post 2034297)
How can I do something with his steamid if he does not connect again?

You will have to loop through all the values stored in the trie and check which one already passed the unix time difference.

ConnorMcLeod 09-14-2013 11:42

Re: Handle disconected
 
Quote:

Originally Posted by Backstabnoob (Post 2034245)
You can easily do something like this:

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #define PLUGIN "New Plugin" #define VERSION "1.0" #define AUTHOR "Author" new Trie: g_tPlayersLastConnection public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         g_tPlayersLastConnection = TrieCreate( ) } public client_disconnect( id ) {     new szAuthid[ 34 ]     get_user_authid( id, szAuthid, charsmax( szAuthid ) )         TrieSetCell( g_tPlayersLastConnection, szAuthid, get_systime( ) ) } public client_putinserver( id ) {     new szAuthid[ 34 ]     get_user_authid( id, szAuthid, charsmax( szAuthid ) )         if( !TrieKeyExists( g_tPlayersLastConnection, szAuthid ) )         return                     new iTime     TrieGetCell( g_tPlayersLastConnection, szAuthid, iTime )         if( get_systime( ) - iTime <= 300 )     {         // player has reconnected within 5 minutes     } }

TrieGetCell returns the same value as TrieKeyExists, you don't need to call TrieKeyExists first.

Backstabnoob 09-14-2013 11:51

Re: Handle disconected
 
Good to know, thanks. Thought it was a bit faster call.

quark 09-25-2013 15:50

Re: Handle disconected
 
Quote:

Originally Posted by ConnorMcLeod (Post 2034497)
TrieGetCell returns the same value as TrieKeyExists, you don't need to call TrieKeyExists first.

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Author"

new Trieg_tPlayersLastConnection

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
g_tPlayersLastConnection TrieCreate( )
}


public 
client_disconnectid )
{
    new 
szAuthid34 ]
    
get_user_authididszAuthidcharsmaxszAuthid ) )
    
    
TrieSetCellg_tPlayersLastConnectionszAuthidget_systime( ) )
}

public 
client_putinserverid )
{
    new 
szAuthid34 ]
    
get_user_authididszAuthidcharsmaxszAuthid ) )        
        
    new 
iTime
    TrieGetCell
g_tPlayersLastConnectionszAuthidiTime )
    
    if( 
get_systime( ) - iTime <= 300 )
    {
        
// player has reconnected within 5 minutes
    
}


So , this should work like this?

DWIGHTpN 09-25-2013 16:32

Re: Handle disconected
 
TrieGetCell() return true if key exist, and false if not..
So use it as a condition.
Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Author"

new Trie: g_tPlayersLastConnection

public plugin_init() {
   
register_plugin(PLUGIN, VERSION, AUTHOR)
   
   
g_tPlayersLastConnection = TrieCreate( )
}


public
client_disconnect( id )
{
    new
szAuthid[ 34 ]
   
get_user_authid( id, szAuthid, charsmax( szAuthid ) )
   
   
TrieSetCell( g_tPlayersLastConnection, szAuthid, get_systime( ) )
}

public
client_putinserver( id )
{
    new
szAuthid[ 34 ]
   
get_user_authid( id, szAuthid, charsmax( szAuthid ) )       
       
    new
iTime
    if( !TrieGetCell
( g_tPlayersLastConnection, szAuthid, iTime ) ) // if key not exist, exit...
        return PLUGIN_CONTINUE;
   
    if(
get_systime( ) - iTime <= 300 )
    {
       
// player has reconnected within 5 minutes
   
}
}



All times are GMT -4. The time now is 19:10.

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