AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   catch on client_disconnect (https://forums.alliedmods.net/showthread.php?t=311936)

JocAnis 11-08-2018 18:17

catch on client_disconnect
 
hey guys..where (or how) can i check what can we get from player when he disconnect's ?
im particulary interested in his last origin (which is impossible, its too late for that command ?) but we can get his nick, steamid, ip...something more?

fysiks 11-08-2018 21:57

Re: catch on client_disconnect
 
Try it and see. What are you trying to do?

E1_531G 11-09-2018 14:14

Re: catch on client_disconnect
 
API says the player entity is still valid, this means you can try to get his origin.

Bugsy 11-09-2018 18:21

Re: catch on client_disconnect
 
It may work but I would avoid it if possible. Can you maybe log it on his most recent kill/death, health change, money change, shot/damage, or any other game event?

FYI I just did this test and the origin was not accurate:
1. Spawn at T spawn in dust2.
2. Kill HL process, which resulted in my origin output when I timed out.
3. Recompiled the plugin to spawn myself at this origin and it was at bomb site B.

PHP Code:

#include <amxmodx>
#include <fakemeta>

public plugin_init() 
{
    
register_clcmd"say test" "Test" );
}

public 
client_disconnectid )
{
    new 
Float:fOrigin];
    
    if ( !
is_user_botid ) )
    {
        
pevid pev_origin fOrigin );
        
server_print"%d = %f %f %f" id fOrigin] , fOrigin] , fOrigin] )
    }
}

public 
Testid )
{
    
//Test 1 which is at bombsite B
    //set_pev( id , pev_origin , { -2080.000000 , 1824.000000 , 208.000000 } );
    
    //Test 2 was successful at CT spawn
    
set_pevid pev_origin , { 352.000000 2368.000000 , -87.000000 } );



iceeedr 11-09-2018 20:44

Re: catch on client_disconnect
 
Quote:

Originally Posted by Bugsy (Post 2623324)
It may work but I would avoid it if possible. Can you maybe log it on his most recent kill/death, health change, money change, shot/damage, or any other game event?

FYI I just did this test and the origin was not accurate:
1. Spawn at T spawn in dust2.
2. Kill HL process, which resulted in my origin output when I timed out.
3. Recompiled the plugin to spawn myself at this origin and it was at bomb site B.

PHP Code:

#include <amxmodx>
#include <fakemeta>

public plugin_init() 
{
    
register_clcmd"say test" "Test" );
}

public 
client_disconnectid )
{
    new 
Float:fOrigin];
    
    if ( !
is_user_botid ) )
    {
        
pevid pev_origin fOrigin );
        
server_print"%d = %f %f %f" id fOrigin] , fOrigin] , fOrigin] )
    }
}

public 
Testid )
{
    
//Test 1 which is at bombsite B
    //set_pev( id , pev_origin , { -2080.000000 , 1824.000000 , 208.000000 } );
    
    //Test 2 was successful at CT spawn
    
set_pevid pev_origin , { 352.000000 2368.000000 , -87.000000 } );



It may be a stupid question, but have you also tested it with the public client_disconnected?

JocAnis 11-10-2018 08:02

Re: catch on client_disconnect
 
@fysiks, if tr leaves, replace ct with his origin, simple as that haha
@bugsy, interesting..i did this test: EDIT: thought fakemeta/engine will change anything
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <engine>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new Float:fOrigin]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd"say /origin""origin" )
}
public 
client_disconnectid )
{
    if( !
is_user_botid ) )    
        
entity_get_vectoridEV_VEC_originfOrigin )
}
public 
originid )
{
    
entity_set_originidfOrigin )


and i tryed 3 times, all 3 worked (disconnect, retry, quit..) but im not sure what will be if player got crashed cs(cant think of the reason but maybe possible) or interenet connection lost, im not sure if it will be the same
edit: oh how now i see you did test with timed out
maybe to add check: if player timed out -> make normal spawn?

Bugsy 11-10-2018 09:21

Re: catch on client_disconnect
 
Can you provide a use-case for what you want to do with this origin? If it was me I would log it on some other game event, not disconnect.

JocAnis 11-10-2018 09:55

Re: catch on client_disconnect
 
deathrun mode...if TR player leaves server -> replace one CT with his last origin...the alternative is set_task with flag b on terror player untill he leaves haha

Bugsy 11-10-2018 10:33

Re: catch on client_disconnect
 
Yeah, there really is no game event for what you're trying to do. I would create a thinking entity and set the interval to maybe every 3-5 seconds to get all players origins.

You should add an additional condition to make sure the disconnecting player was actually in game prior to him leaving.

Something like this:
PHP Code:


#include <amxmodx>
#include <engine>

new const Version[] = "0.1";

const 
Float:OriginInterval 3.0;

new 
g_iEntity Float:g_fOriginsMAX_PLAYERS ][ ];

public 
plugin_init() 
{
    
register_plugin"Log Origins" Version "bugsy" );
    
    
g_iEntity create_entity"info_target" );
    
entity_set_stringg_iEntity EV_SZ_classname "lo_entity" );
    
register_think"lo_entity" "LOEntThink" );
    
entity_set_floatg_iEntity EV_FL_nextthink , ( get_gametime() + OriginInterval ) );
}

public 
client_disconnectid )
{
    if ( 
g_fOriginsid ][ ] )
    {
        
//spawn new player at g_fOrigins[ id ]
    
}
    
    
g_fOriginsid ][ ] = 0.0;
    
g_fOriginsid ][ ] = 0.0;
    
g_fOriginsid ][ ] = 0.0;
}

public 
LOEntThinkiEntity )
{
    if ( 
iEntity == g_iEntity 
    {
        new 
iPlayers32 ] , iNum id;
        
        
get_playersiPlayers iNum "aeh" "TERRORIST" );
        
        if ( 
iNum )
        {
            for ( new 
iNum i++ )
            {
                
id iPlayers];
                
entity_get_vectorid EV_VEC_origin g_fOriginsid ] );
            }
        }
        
        
entity_set_floatg_iEntity EV_FL_nextthink , ( get_gametime() + OriginInterval ) );
    }



JocAnis 11-10-2018 11:46

Re: catch on client_disconnect
 
interesting, thanks..
but because its deathrun (1TR + othersCT) we can shorten it to not loop all players, but only to check TR ?


All times are GMT -4. The time now is 18:42.

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