Raised This Month: $ Target: $400
 0% 

Kick before disconnect?


Post New Thread Reply   
 
Thread Tools Display Modes
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 05-24-2012 , 20:25   Re: Kick before disconnect?
Reply With Quote #11

PHP Code:
public client_disconnectiClient )
{
  static 
cName32 ], cSteam26 ], cIP26 ];
  
get_user_nameiClientcName32 );
  
get_user_authidiClientcSteam26 );
  
get_user_ipiClientcIP26);

  static 
cQuery512 ];
  
formatexcQuery512"INSERT INTO bans ( name, steam, ip ) VALUES ( '%s', '%s', '%s' )"cNamecSteamcIP );
  
SQL_ThreadQueryg_hSQLTuple"SQLEmptyAction"cQuery );

Is it too hard?
__________________
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-24-2012 , 21:16   Re: Kick before disconnect?
Reply With Quote #12

Quote:
Originally Posted by claudiuhks View Post
PHP Code:
public client_disconnectiClient )
{
  static 
cName32 ], cSteam26 ], cIP26 ];
  
get_user_nameiClientcName32 );
  
get_user_authidiClientcSteam26 );
  
get_user_ipiClientcIP26);

  static 
cQuery512 ];
  
formatexcQuery512"INSERT INTO bans ( name, steam, ip ) VALUES ( '%s', '%s', '%s' )"cNamecSteamcIP );
  
SQL_ThreadQueryg_hSQLTuple"SQLEmptyAction"cQuery );

Is it too hard?
You should not call natives on a player at client_disconnect() because there are times when it is called and the player is already gone, which could cause the plugin to error. You may not see this in testing, but there is a chance of it happening so you should avoid it. Also, use charsmax() in your natives or atleast use size-1 to give room for the null char.

PHP Code:
const MAX_PLAYERS 32;

new 
g_szAuthIDMAX_PLAYERS ][ 35 ];

public 
client_putinserverid )
{
    
get_user_authidid g_szAuthIDid ] , charsmaxg_szAuthID[] ) );
}

public 
client_disconnectid )
{
    
//Add ban for g_szAuthID[ id ]

__________________

Last edited by Bugsy; 05-24-2012 at 21:19.
Bugsy is offline
Misery
Senior Member
Join Date: Dec 2010
Old 05-24-2012 , 23:30   Re: Kick before disconnect?
Reply With Quote #13

Anyways, from what I understand, theres actually no way to send the "You have been banned" notice b/c the player is already gone right?

I know I can update the db, what I wanted was actually to *make him know*...
Misery is offline
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 05-24-2012 , 23:54   Re: Kick before disconnect?
Reply With Quote #14

Quote:
Originally Posted by Misery View Post
Anyways, from what I understand, theres actually no way to send the "You have been banned" notice b/c the player is already gone right?

I know I can update the db, what I wanted was actually to *make him know*...
If you do what everyone has suggested, if he tries to come back, you can send him a message and he will know he is banned then.
__________________
Hi.
Kreation is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 05-25-2012 , 03:19   Re: Kick before disconnect?
Reply With Quote #15

Quote:
Originally Posted by Bugsy View Post
You should not call natives on a player at client_disconnect() because there are times when it is called and the player is already gone, which could cause the plugin to error. You may not see this in testing, but there is a chance of it happening so you should avoid it. Also, use charsmax() in your natives or atleast use size-1 to give room for the null char.

PHP Code:
const MAX_PLAYERS 32;

new 
g_szAuthIDMAX_PLAYERS ][ 35 ];

public 
client_putinserverid )
{
    
get_user_authidid g_szAuthIDid ] , charsmaxg_szAuthID[] ) );
}

public 
client_disconnectid )
{
    
//Add ban for g_szAuthID[ id ]

I know it's not a good idea to call functions in client_disconnect, but I just gave an example. It's a bad idea just because when changelevel, this forward gets executed maximum 32 times one by one.
Forward client_disconnect is executed before AMX Mod X sets player as disconnected though.

PHP Code:
void C_ClientDisconnect(edict_t *pEntity)
{
    
CPlayer *pPlayer GET_PLAYER_POINTER(pEntity);
    if (
pPlayer->initialized)
        
executeForwards(FF_ClientDisconnectstatic_cast<cell>(pPlayer->index));

    if (
pPlayer->ingame)
    {
        --
g_players_num;
    }
    
pPlayer->Disconnect();

    
RETURN_META(MRES_IGNORED);

__________________

Last edited by claudiuhks; 05-25-2012 at 03:20.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 05-25-2012 , 08:36   Re: Kick before disconnect?
Reply With Quote #16

Use an TrieGetCell() function to use witch this

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 05-25-2012 , 09:04   Re: Kick before disconnect?
Reply With Quote #17

Quote:
Originally Posted by ^SmileY View Post
Use an TrieGetCell() function to use witch this

What would you need that for?
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 05-25-2012 , 09:09   Re: Kick before disconnect?
Reply With Quote #18

To save an steamids and names to use witch a ban command..
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 05-25-2012 , 09:18   Re: Kick before disconnect?
Reply With Quote #19

All you need for that is a simple array.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-25-2012 , 18:38   Re: Kick before disconnect?
Reply With Quote #20

Quote:
Originally Posted by claudiuhks View Post
Forward client_disconnect is executed before AMX Mod X sets player as disconnected though.

PHP Code:
void C_ClientDisconnect(edict_t *pEntity)
{
    
CPlayer *pPlayer GET_PLAYER_POINTER(pEntity);
    if (
pPlayer->initialized)
        
executeForwards(FF_ClientDisconnectstatic_cast<cell>(pPlayer->index));

    if (
pPlayer->ingame)
    {
        --
g_players_num;
    }
    
pPlayer->Disconnect();

    
RETURN_META(MRES_IGNORED);

Which is why it usually works without error. But enter a game and then kill the hl.exe process (for example purposes) and about 30 seconds later your player will timeout and there will be no player to call the natives on when client_disconnect() is called.
__________________
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 13:58.


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