mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-02-06 12:14:15 +00:00
engine: server: make generic function to kick players with a reason
This commit is contained in:
parent
1d965d7543
commit
551ea71906
@ -457,6 +457,7 @@ extern convar_t *sv_validate_changelevel;
|
|||||||
// sv_main.c
|
// sv_main.c
|
||||||
//
|
//
|
||||||
void SV_FinalMessage( const char *message, qboolean reconnect );
|
void SV_FinalMessage( const char *message, qboolean reconnect );
|
||||||
|
void SV_KickPlayer( sv_client_t *cl, const char *fmt, ... ) _format( 2 );
|
||||||
void SV_DropClient( sv_client_t *cl, qboolean crash );
|
void SV_DropClient( sv_client_t *cl, qboolean crash );
|
||||||
void SV_UpdateMovevars( qboolean initialize );
|
void SV_UpdateMovevars( qboolean initialize );
|
||||||
int SV_ModelIndex( const char *name );
|
int SV_ModelIndex( const char *name );
|
||||||
|
@ -547,6 +547,51 @@ edict_t *SV_FakeConnect( const char *netname )
|
|||||||
return cl->edict;
|
return cl->edict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
==================
|
||||||
|
SV_Kick_f
|
||||||
|
|
||||||
|
Kick a user off of the server
|
||||||
|
==================
|
||||||
|
*/
|
||||||
|
void SV_KickPlayer( sv_client_t *cl, const char *fmt, ... )
|
||||||
|
{
|
||||||
|
const char *clientId;
|
||||||
|
va_list va;
|
||||||
|
char buf[MAX_VA_STRING];
|
||||||
|
|
||||||
|
if( NET_IsLocalAddress( cl->netchan.remote_address ))
|
||||||
|
{
|
||||||
|
Con_Printf( "The local player cannot be kicked!\n" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
clientId = SV_GetClientIDString( cl );
|
||||||
|
|
||||||
|
va_start( va, fmt );
|
||||||
|
Q_vsnprintf( buf, sizeof( buf ), fmt, va );
|
||||||
|
va_end( va );
|
||||||
|
|
||||||
|
if( buf[0] )
|
||||||
|
{
|
||||||
|
Log_Printf( "Kick: \"%s<%i><%s><>\" was kicked by \"Console\" (message \"%s\")\n", cl->name, cl->userid, clientId, buf );
|
||||||
|
SV_BroadcastPrintf( cl, "%s was kicked with message: \"%s\"\n", cl->name, buf );
|
||||||
|
SV_ClientPrintf( cl, "You were kicked from the game with message: \"%s\"\n", buf );
|
||||||
|
if( cl->useragent[0] )
|
||||||
|
Netchan_OutOfBandPrint( NS_SERVER, cl->netchan.remote_address, "errormsg\nKicked with message:\n%s\n", buf );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log_Printf( "Kick: \"%s<%i><%s><>\" was kicked by \"Console\"\n", cl->name, cl->userid, clientId );
|
||||||
|
SV_BroadcastPrintf( cl, "%s was kicked\n", cl->name );
|
||||||
|
SV_ClientPrintf( cl, "You were kicked from the game\n" );
|
||||||
|
if( cl->useragent[0] )
|
||||||
|
Netchan_OutOfBandPrint( NS_SERVER, cl->netchan.remote_address, "errormsg\nYou were kicked from the game\n" );
|
||||||
|
}
|
||||||
|
|
||||||
|
SV_DropClient( cl, false );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=====================
|
=====================
|
||||||
SV_DropClient
|
SV_DropClient
|
||||||
|
@ -584,7 +584,7 @@ Kick a user off of the server
|
|||||||
void SV_Kick_f( void )
|
void SV_Kick_f( void )
|
||||||
{
|
{
|
||||||
sv_client_t *cl;
|
sv_client_t *cl;
|
||||||
const char *param, *clientId;
|
const char *param;
|
||||||
|
|
||||||
if( Cmd_Argc() != 2 )
|
if( Cmd_Argc() != 2 )
|
||||||
{
|
{
|
||||||
@ -604,38 +604,7 @@ void SV_Kick_f( void )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( NET_IsLocalAddress( cl->netchan.remote_address ))
|
SV_KickPlayer( cl, "%s", Cmd_Argv( 2 ));
|
||||||
{
|
|
||||||
Con_Printf( "The local player cannot be kicked!\n" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
param = Cmd_Argv( 2 );
|
|
||||||
|
|
||||||
clientId = SV_GetClientIDString( cl );
|
|
||||||
|
|
||||||
if( *param )
|
|
||||||
{
|
|
||||||
Log_Printf( "Kick: \"%s<%i><%s><>\" was kicked by \"Console\" (message \"%s\")\n", cl->name, cl->userid, clientId, param );
|
|
||||||
SV_BroadcastPrintf( cl, "%s was kicked with message: \"%s\"\n", cl->name, param );
|
|
||||||
SV_ClientPrintf( cl, "You were kicked from the game with message: \"%s\"\n", param );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Log_Printf( "Kick: \"%s<%i><%s><>\" was kicked by \"Console\"\n", cl->name, cl->userid, clientId );
|
|
||||||
SV_BroadcastPrintf( cl, "%s was kicked\n", cl->name );
|
|
||||||
SV_ClientPrintf( cl, "You were kicked from the game\n" );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( cl->useragent[0] )
|
|
||||||
{
|
|
||||||
if( *param )
|
|
||||||
Netchan_OutOfBandPrint( NS_SERVER, cl->netchan.remote_address, "errormsg\nKicked with message:\n%s\n", param );
|
|
||||||
else
|
|
||||||
Netchan_OutOfBandPrint( NS_SERVER, cl->netchan.remote_address, "errormsg\nYou were kicked from the game\n" );
|
|
||||||
}
|
|
||||||
|
|
||||||
SV_DropClient( cl, false );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user