mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2024-11-10 06:31:47 +00:00
Show client's name in callvote clientkick vote display message
Make callvote always kick by client num so player can't rename to avoid being kicked. Don't allow calling a vote to kick host or non-existent players.
This commit is contained in:
parent
eeb28dc1d0
commit
71512bb1fd
1 changed files with 38 additions and 21 deletions
|
@ -192,31 +192,35 @@ Returns a player number for either a number or name string
|
|||
Returns -1 if invalid
|
||||
==================
|
||||
*/
|
||||
int ClientNumberFromString( gentity_t *to, char *s ) {
|
||||
int ClientNumberFromString( gentity_t *to, char *s, qboolean checkNums, qboolean checkNames ) {
|
||||
gclient_t *cl;
|
||||
int idnum;
|
||||
char cleanName[MAX_STRING_CHARS];
|
||||
|
||||
// numeric values could be slot numbers
|
||||
if ( StringIsInteger( s ) ) {
|
||||
idnum = atoi( s );
|
||||
if ( idnum >= 0 && idnum < level.maxclients ) {
|
||||
cl = &level.clients[idnum];
|
||||
if ( cl->pers.connected == CON_CONNECTED ) {
|
||||
return idnum;
|
||||
if ( checkNums ) {
|
||||
// numeric values could be slot numbers
|
||||
if ( StringIsInteger( s ) ) {
|
||||
idnum = atoi( s );
|
||||
if ( idnum >= 0 && idnum < level.maxclients ) {
|
||||
cl = &level.clients[idnum];
|
||||
if ( cl->pers.connected == CON_CONNECTED ) {
|
||||
return idnum;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check for a name match
|
||||
for ( idnum=0,cl=level.clients ; idnum < level.maxclients ; idnum++,cl++ ) {
|
||||
if ( cl->pers.connected != CON_CONNECTED ) {
|
||||
continue;
|
||||
}
|
||||
Q_strncpyz(cleanName, cl->pers.netname, sizeof(cleanName));
|
||||
Q_CleanStr(cleanName);
|
||||
if ( !Q_stricmp( cleanName, s ) ) {
|
||||
return idnum;
|
||||
if ( checkNames ) {
|
||||
// check for a name match
|
||||
for ( idnum=0,cl=level.clients ; idnum < level.maxclients ; idnum++,cl++ ) {
|
||||
if ( cl->pers.connected != CON_CONNECTED ) {
|
||||
continue;
|
||||
}
|
||||
Q_strncpyz(cleanName, cl->pers.netname, sizeof(cleanName));
|
||||
Q_CleanStr(cleanName);
|
||||
if ( !Q_stricmp( cleanName, s ) ) {
|
||||
return idnum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -734,7 +738,7 @@ void Cmd_Follow_f( gentity_t *ent ) {
|
|||
}
|
||||
|
||||
trap_Argv( 1, arg, sizeof( arg ) );
|
||||
i = ClientNumberFromString( ent, arg );
|
||||
i = ClientNumberFromString( ent, arg, qtrue, qtrue );
|
||||
if ( i == -1 ) {
|
||||
return;
|
||||
}
|
||||
|
@ -966,7 +970,7 @@ static void Cmd_Tell_f( gentity_t *ent ) {
|
|||
}
|
||||
|
||||
trap_Argv( 1, arg, sizeof( arg ) );
|
||||
targetNum = ClientNumberFromString( ent, arg );
|
||||
targetNum = ClientNumberFromString( ent, arg, qtrue, qtrue );
|
||||
if ( targetNum == -1 ) {
|
||||
return;
|
||||
}
|
||||
|
@ -1092,7 +1096,7 @@ static void Cmd_VoiceTell_f( gentity_t *ent, qboolean voiceonly ) {
|
|||
}
|
||||
|
||||
trap_Argv( 1, arg, sizeof( arg ) );
|
||||
targetNum = ClientNumberFromString( ent, arg );
|
||||
targetNum = ClientNumberFromString( ent, arg, qtrue, qtrue );
|
||||
if ( targetNum == -1 ) {
|
||||
return;
|
||||
}
|
||||
|
@ -1221,7 +1225,7 @@ void Cmd_GameCommand_f( gentity_t *ent ) {
|
|||
}
|
||||
|
||||
trap_Argv( 1, arg, sizeof( arg ) );
|
||||
targetNum = ClientNumberFromString( ent, arg );
|
||||
targetNum = ClientNumberFromString( ent, arg, qtrue, qtrue );
|
||||
if ( targetNum == -1 ) {
|
||||
return;
|
||||
}
|
||||
|
@ -1365,6 +1369,19 @@ void Cmd_CallVote_f( gentity_t *ent ) {
|
|||
}
|
||||
Com_sprintf( level.voteString, sizeof( level.voteString ), "vstr nextmap");
|
||||
Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s", level.voteString );
|
||||
} else if ( !Q_stricmp( arg1, "clientkick" ) || !Q_stricmp( arg1, "kick" ) ) {
|
||||
i = ClientNumberFromString( ent, arg2, !Q_stricmp( arg1, "clientkick" ), !Q_stricmp( arg1, "kick" ) );
|
||||
if ( i == -1 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( level.clients[i].pers.localClient ) {
|
||||
trap_SendServerCommand( ent - g_entities, "print \"Cannot kick host player.\n\"" );
|
||||
return;
|
||||
}
|
||||
|
||||
Com_sprintf( level.voteString, sizeof( level.voteString ), "clientkick %d", i );
|
||||
Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "kick %s", level.clients[i].pers.netname );
|
||||
} else {
|
||||
Com_sprintf( level.voteString, sizeof( level.voteString ), "%s \"%s\"", arg1, arg2 );
|
||||
Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s", level.voteString );
|
||||
|
|
Loading…
Reference in a new issue