本文整理汇总了C++中ClientNumberFromString函数的典型用法代码示例。如果您正苦于以下问题:C++ ClientNumberFromString函数的具体用法?C++ ClientNumberFromString怎么用?C++ ClientNumberFromString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ClientNumberFromString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: G_refRemove_cmd
// Removes a player from a team.
void G_refRemove_cmd(gentity_t *ent)
{
int pid;
char arg[MAX_TOKEN_CHARS];
gentity_t *player;
// Works for teamplayish matches
if(g_gametype.integer < GT_WOLF) {
G_refPrintf(ent, "\"remove\" only for team-based games!");
return;
}
// Find the player to remove.
trap_Argv(2, arg, sizeof(arg));
if((pid = ClientNumberFromString(ent, arg)) == -1) return;
player = g_entities + pid;
// Can only remove active players.
if(player->client->sess.sessionTeam == TEAM_SPECTATOR) {
G_refPrintf(ent, "You can only remove people in the game!");
return;
}
// Announce the removal
AP(va("cp \"%s\n^7removed from team %s\n\"", player->client->pers.netname, aTeams[player->client->sess.sessionTeam]));
CPx(pid, va("print \"^5You've been removed from the %s team\n\"", aTeams[player->client->sess.sessionTeam]));
SetTeam( player, "s", qtrue, -1, -1, qfalse );
if(g_gamestate.integer == GS_WARMUP || g_gamestate.integer == GS_WARMUP_COUNTDOWN) {
G_readyMatchState();
}
}
示例2: Cmd_Jail_f
void Cmd_Jail_f(gentity_t *ent)
{
char buffer[MAX_TOKEN_CHARS];
int clientNum;
if (!HasPermission(ent, PERMISSION_JAIL))
return;
if (trap_Argc() != 2)
{
MM_SendMessage(ent - g_entities, va("print \"Command usage: mjail <client-name-or-number>\n\""));
return;
}
trap_Argv(1, buffer, sizeof(buffer));
clientNum = ClientNumberFromString(ent, buffer);
if (clientNum == -1)
{
MM_SendMessage(ent - g_entities, va("print \"ERROR: Could not identify player %s\n\"", buffer));
return;
}
gentity_t *target = &g_entities[clientNum];
if (target->client->sess.jailed == qfalse)
MM_JailClient(target, qfalse);
else
{
target->client->sess.jailed = qfalse;
ClientSpawn(target); // not sure how safe this is but what the heck lmao
}
}
示例3: Cmd_Tell_f
static void Cmd_Tell_f( gentity_t *ent ) {
int targetNum;
gentity_t *target;
char *p, arg[MAX_TOKEN_CHARS];
if ( trap->Cmd_Argc() < 2 )
return;
trap->Cmd_Argv( 1, arg, sizeof( arg ) );
targetNum = ClientNumberFromString( ent, arg );
if ( targetNum == -1 )
return;
target = &g_entities[targetNum];
if ( !target || !target->inuse || !target->client )
return;
p = ConcatArgs( 2 );
//Raz: BOF
if ( strlen( p ) > MAX_SAY_TEXT ) {
p[MAX_SAY_TEXT-1] = '\0';
G_LogPrintf( "Cmd_Tell_f from %d (%s) has been truncated: %s\n", ent->s.number, ent->client->pers.netname, p );
}
G_LogPrintf( "tell: %s to %s: %s\n", ent->client->pers.netname, target->client->pers.netname, p );
G_Say( ent, target, SAY_TELL, p );
// don't tell to the player self if it was already directed to this player
// also don't send the chat back to a bot
if ( ent != target && !(ent->r.svFlags & SVF_BOT) )
G_Say( ent, ent, SAY_TELL, p );
}
示例4: Cmd_VoiceTell_f
/*
==================
Cmd_VoiceTell_f
==================
*/
static void Cmd_VoiceTell_f( gentity_t *ent, qboolean voiceonly ) {
int targetNum;
gentity_t *target;
char *id;
char arg[MAX_TOKEN_CHARS];
if ( trap_Argc () < 3 ) {
trap_SendServerCommand( ent-g_entities, va( "print \"Usage: %s <player id> <voice id>\n\"", voiceonly ? "votell" : "vtell" ) );
return;
}
trap_Argv( 1, arg, sizeof( arg ) );
targetNum = ClientNumberFromString( ent, arg );
if ( targetNum == -1 ) {
return;
}
target = &g_entities[targetNum];
if ( !target->inuse || !target->client ) {
return;
}
id = ConcatArgs( 2 );
G_LogPrintf( "vtell: %s to %s: %s\n", ent->client->pers.netname, target->client->pers.netname, id );
G_Voice( ent, target, SAY_TELL, id, voiceonly );
// don't tell to the player self if it was already directed to this player
// also don't send the chat back to a bot
if ( ent != target && !(ent->r.svFlags & SVF_BOT)) {
G_Voice( ent, ent, SAY_TELL, id, voiceonly );
}
}
示例5: G_statsPrint
// Sends a player's stats to the requesting client.
void G_statsPrint( gentity_t *ent, int nType ) {
int pid;
char *cmd = ( nType == 0 ) ? "ws" : ( ( nType == 1 ) ? "wws" : "gstats" ); // Yes, not the cleanest
char arg[MAX_TOKEN_CHARS];
if ( !ent || ( ent->r.svFlags & SVF_BOT ) ) {
return;
}
// If requesting stats for self, its easy.
if ( trap_Argc() < 2 ) {
if ( ent->client->sess.sessionTeam != TEAM_SPECTATOR ) {
CP( va( "%s %s\n", cmd, G_createStats( ent ) ) );
// Specs default to players they are chasing
} else if ( ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) {
CP( va( "%s %s\n", cmd, G_createStats( g_entities + ent->client->sess.spectatorClient ) ) );
} else {
CP( "cpm \"Type ^3\\stats <player_id>^7 to see stats on an active player.\n\"" );
return;
}
} else {
// Find the player to poll stats.
trap_Argv( 1, arg, sizeof( arg ) );
if ( ( pid = ClientNumberFromString( ent, arg ) ) == -1 ) {
return;
}
CP( va( "%s %s\n", cmd, G_createStats( g_entities + pid ) ) );
}
}
示例6: G_specinvite_cmd
// ************** SPECINVITE
//
// Sends an invitation to a player to spectate a team.
void G_specinvite_cmd(gentity_t * ent, unsigned int dwCommand, qboolean fLock)
{
int tteam, pid;
gentity_t *player;
char arg[MAX_TOKEN_CHARS];
if(team_nocontrols.integer)
{
G_noTeamControls(ent);
return;
}
if(!G_cmdDebounce(ent, aCommandInfo[dwCommand].pszCommandName))
{
return;
}
tteam = G_teamID(ent);
if(tteam == TEAM_AXIS || tteam == TEAM_ALLIES)
{
if(!teamInfo[tteam].spec_lock)
{
CP("cpm \"Your team isn't locked from spectators!\n\"");
return;
}
// Find the player to invite.
trap_Argv(1, arg, sizeof(arg));
if((pid = ClientNumberFromString(ent, arg)) == -1)
{
return;
}
player = g_entities + pid;
// Can't invite self
if(player->client == ent->client)
{
CP("cpm \"You can't specinvite yourself!\n\"");
return;
}
// Can't invite an active player.
if(player->client->sess.sessionTeam != TEAM_SPECTATOR)
{
CP("cpm \"You can't specinvite a non-spectator!\n\"");
return;
}
player->client->sess.spec_invite |= tteam;
// Notify sender/recipient
CP(va("print \"%s^7 has been sent a spectator invitation.\n\"", player->client->pers.netname));
G_printFull(va("*** You've been invited to spectate the %s team!", aTeams[tteam]), player);
}
else
{
CP("cpm \"Spectators can't specinvite players!\n\"");
}
}
示例7: Cmd_Follow_f
static void Cmd_Follow_f( gentity_t *ent ) {
int i;
char arg[MAX_TOKEN_CHARS];
if ( trap->Cmd_Argc() != 2 ) {
if ( ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) {
StopFollowing( ent );
}
return;
}
trap->Cmd_Argv( 1, arg, sizeof( arg ) );
i = ClientNumberFromString( ent, arg );
if ( i == -1 ) {
return;
}
// can't follow self
if ( &level.clients[ i ] == ent->client ) {
return;
}
// can't follow another spectator
if ( level.clients[ i ].sess.sessionTeam == TEAM_SPECTATOR ) {
return;
}
// first set them to spectator
if ( ent->client->sess.sessionTeam != TEAM_SPECTATOR ) {
SetTeam( ent, "spectator" );
}
ent->client->sess.spectatorState = SPECTATOR_FOLLOW;
ent->client->sess.spectatorClient = i;
}
示例8: G_refMute_cmd
// (Un)Mutes a player
void G_refMute_cmd(gentity_t *ent, qboolean mute)
{
int pid;
char arg[MAX_TOKEN_CHARS];
gentity_t *player;
// Find the player to mute.
trap_Argv(2, arg, sizeof(arg));
if((pid = ClientNumberFromString(ent, arg)) == -1) return;
player = g_entities + pid;
if( player->client->sess.referee != RL_NONE ) {
G_refPrintf(ent, "Cannot mute a referee.\n" );
return;
}
if(player->client->sess.muted == mute) {
G_refPrintf(ent, "\"%s^*\" %s\n", player->client->pers.netname, mute ? "is already muted!" : "is not muted!" );
return;
}
if( mute ) {
CPx(pid, "print \"^5You've been muted\n\"" );
player->client->sess.muted = qtrue;
G_Printf( "\"%s^*\" has been muted\n", player->client->pers.netname );
ClientUserinfoChanged( pid );
} else {
CPx(pid, "print \"^5You've been unmuted\n\"" );
player->client->sess.muted = qfalse;
G_Printf( "\"%s^*\" has been unmuted\n", player->client->pers.netname );
ClientUserinfoChanged( pid );
}
}
示例9: Cmd_Follow_f
/* LQ3A: Added eType variable. See LQ3A_FOLLOW_TYPE_* definitions for usage. */
void Cmd_Follow_f(gentity_t *ent, lq3a_follow_type_t eType) {
int i;
char arg[MAX_TOKEN_CHARS];
if ( trap_Argc() != 2 ) {
/* LQ3A */
if ((ent->client->sess.spectatorState == SPECTATOR_FOLLOW) ||
(ent->client->sess.spectatorState == SPECTATOR_FOLLOW_THIRDPERSON)) {
StopFollowing( ent );
}
return;
}
trap_Argv( 1, arg, sizeof( arg ) );
i = ClientNumberFromString( ent, arg );
if ( i == -1 ) {
return;
}
// can't follow self
if ( &level.clients[ i ] == ent->client ) {
return;
}
// can't follow another spectator
if ( level.clients[ i ].sess.sessionTeam == TEAM_SPECTATOR ) {
return;
}
// if they are playing a tournement game, count as a loss
if ( (g_gametype.integer == GT_TOURNAMENT )
&& ent->client->sess.sessionTeam == TEAM_FREE ) {
ent->client->sess.losses++;
}
// first set them to spectator
if ( ent->client->sess.sessionTeam != TEAM_SPECTATOR ) {
/* LQ3A */
SetTeam(ent, "spectator", qtrue);
}
/* LQ3A */
switch (eType)
{
case LQ3A_FOLLOW_TYPE_THIRDPERSON:
ent->client->sess.spectatorState = SPECTATOR_FOLLOW_THIRDPERSON;
break;
// case LQ3A_FOLLOW_AUTO:
// case LQ3A_FOLLOW_TYPE_FIRSTPERSON:
default:
ent->client->sess.spectatorState = SPECTATOR_FOLLOW;
break;
}
ent->client->sess.spectatorClient = i;
}
示例10: G_UnMute_v
// *** Player Un-Mute ***
int G_UnMute_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd)
{
if (fRefereeCmd)
{
// handled elsewhere
return G_NOTFOUND;
}
// Vote request (vote is being initiated)
if (arg)
{
int pid;
if (!vote_allow_muting.integer && ent && !ent->client->sess.referee)
{
G_voteDisableMessage(ent, arg);
return G_INVALID;
}
else if (G_voteDescription(ent, fRefereeCmd, dwVoteIndex))
{
return G_INVALID;
}
else if ((pid = ClientNumberFromString(ent, arg2)) == -1)
{
return G_INVALID;
}
if (!level.clients[pid].sess.muted)
{
G_refPrintf(ent, "Player is not muted!");
return G_INVALID;
}
Com_sprintf(level.voteInfo.vote_value, VOTE_MAXSTRING, "%d", pid);
Com_sprintf(arg2, VOTE_MAXSTRING, "%s", level.clients[pid].pers.netname);
// Vote action (vote has passed)
}
else
{
int pid = atoi(level.voteInfo.vote_value);
// Mute a player
if (level.clients[pid].sess.referee != RL_RCON)
{
trap_SendServerCommand(pid, va("cpm \"^3You have been un-muted\""));
level.clients[pid].sess.muted = qfalse;
AP(va("cp \"%s\n^3has been un-muted!\n\"", level.clients[pid].pers.netname));
ClientUserinfoChanged(pid);
}
else
{
G_Printf("Cannot un-mute a referee.\n");
}
}
return G_OK;
}
示例11: G_Kick_v
// *** Player Kick ***
int G_Kick_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd)
{
// Vote request (vote is being initiated)
if (arg)
{
int pid;
if (!vote_allow_kick.integer && ent && !ent->client->sess.referee)
{
G_voteDisableMessage(ent, arg);
return G_INVALID;
}
else if (G_voteDescription(ent, fRefereeCmd, dwVoteIndex))
{
return G_INVALID;
}
else if ((pid = ClientNumberFromString(ent, arg2)) == -1)
{
return G_INVALID;
}
if (level.clients[pid].sess.referee)
{
G_refPrintf(ent, "Can't vote to kick referees!");
return G_INVALID;
}
if (g_entities[pid].r.svFlags & SVF_BOT)
{
G_refPrintf(ent, "Can't vote to kick bots!");
return G_INVALID;
}
if (!fRefereeCmd && ent)
{
if (level.clients[pid].sess.sessionTeam != TEAM_SPECTATOR && level.clients[pid].sess.sessionTeam != ent->client->sess.sessionTeam)
{
G_refPrintf(ent, "Can't vote to kick players on opposing team!");
return G_INVALID;
}
}
Com_sprintf(level.voteInfo.vote_value, VOTE_MAXSTRING, "%d", pid);
Com_sprintf(arg2, VOTE_MAXSTRING, "%s", level.clients[pid].pers.netname);
// Vote action (vote has passed)
}
else
{
// Kick a player
trap_SendConsoleCommand(EXEC_APPEND, va("clientkick %d\n", atoi(level.voteInfo.vote_value)));
AP(va("cp \"%s\n^3has been kicked!\n\"", level.clients[atoi(level.voteInfo.vote_value)].pers.netname));
}
return G_OK;
}
示例12: G_Unreferee_v
// *** Un-Referee voting ***
int G_Unreferee_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd)
{
// Vote request (vote is being initiated)
if(arg) {
int pid;
if(!vote_allow_referee.integer && ent && !ent->client->sess.referee) {
G_voteDisableMessage(ent, arg);
return(G_INVALID);
}
// yada - ent==NULL for console...
if( (!ent || ent->client->sess.referee) && trap_Argc() == 2) {
G_playersMessage(ent);
return(G_INVALID);
} else if(ent && trap_Argc() == 2) pid = ent - g_entities; // yada - ent still NULL for console...
else if(G_voteDescription(ent, fRefereeCmd, dwVoteIndex)) return(G_INVALID);
else if((pid = ClientNumberFromString(ent, arg2)) == -1) return(G_INVALID);
if(level.clients[pid].sess.referee == RL_NONE) {
G_refPrintf(ent, "[lof]%s [lon]isn't a referee!", level.clients[pid].pers.netname);
return(G_INVALID);
}
if(level.clients[pid].sess.referee == RL_RCON) {
G_refPrintf(ent, "[lof]%s's [lon]status cannot be removed", level.clients[pid].pers.netname);
return(G_INVALID);
}
if( level.clients[pid].pers.localClient ) {
G_refPrintf(ent, "[lof]%s [lon]^7is the Server Host", level.clients[pid].pers.netname);
return(G_INVALID);
}
Com_sprintf(level.voteInfo.vote_value, VOTE_MAXSTRING, "%d", pid);
Com_sprintf(arg2, VOTE_MAXSTRING, "%s^7", level.clients[pid].pers.netname);
// Vote action (vote has passed)
} else {
// Stripping of referee status
gclient_t *cl = &level.clients[atoi(level.voteInfo.vote_value)];
cl->sess.referee = RL_NONE;
if( !cl->sess.shoutcaster ) { // don't remove shoutcaster's invitation
cl->sess.spec_invite = 0;
}
AP(va("cp \"%s^7\nis no longer a referee\n\"", cl->pers.netname));
ClientUserinfoChanged( atoi(level.voteInfo.vote_value) );
}
return(G_OK);
}
示例13: G_Kick_v
// *** Player Kick ***
int G_Kick_v( gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd ) {
// Vote request (vote is being initiated)
if( arg ) {
int pid;
if( !vote_allow_kick.integer && ent && !ent->client->sess.referee ) {
G_voteDisableMessage(ent, arg);
return G_INVALID;
} else if( G_voteDescription(ent, fRefereeCmd, dwVoteIndex) ) {
return G_INVALID;
} else if( ( pid = ClientNumberFromString( ent, arg2 ) ) == -1 ) {
return G_INVALID;
}
if( level.clients[ pid ].sess.referee ) {
G_refPrintf( ent, "Can't vote to kick referees!" );
return G_INVALID;
}
if(G_shrubbot_permission(&g_entities[pid], SBF_IMMUNITY)) {
G_refPrintf( ent, "Can't vote to kick admins!" );
return G_INVALID;
}
// pheno: prevent ettv slaves from being callvote kicked
if( level.clients[pid].sess.ettv &&
( g_ettvFlags.integer & ETTV_IMMUNITY ) ) {
G_refPrintf( ent, "Can't vote to kick ettv slaves!" );
return G_INVALID;
}
if( !fRefereeCmd && ent ) {
if( level.clients[ pid ].sess.sessionTeam != TEAM_SPECTATOR && level.clients[ pid ].sess.sessionTeam != ent->client->sess.sessionTeam ) {
G_refPrintf( ent, "Can't vote to kick players on opposing team!" );
return G_INVALID;
}
}
Com_sprintf( level.voteInfo.vote_value, VOTE_MAXSTRING, "%d", pid );
Com_sprintf( arg2, VOTE_MAXSTRING, "%s^7", level.clients[pid].pers.netname );
// Vote action (vote has passed)
} else {
// Kick a player
//trap_SendConsoleCommand( EXEC_APPEND, va( "clientkick %d\n", atoi( level.voteInfo.vote_value ) ) );
// tjw: clientkick doesn't work in 2.60
trap_DropClient(atoi(level.voteInfo.vote_value),
"You have been kicked", 120);
AP( va( "cp \"%s\n^3has been kicked!\n\"", level.clients[ atoi( level.voteInfo.vote_value ) ].pers.netname ) );
}
return G_OK;
}
示例14: G_PutSpec_v
// *** Player PutSpec ***
int G_PutSpec_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd)
{
// yada - my ass... this isnt handled elsewhere at all
//if( fRefereeCmd ){
// // handled elsewhere
// return(G_NOTFOUND);
//}
// Vote request (vote is being initiated)
if(arg) {
int pid;
if(!vote_allow_putspec.integer && ent && !ent->client->sess.referee) {
G_voteDisableMessage(ent, arg);
return(G_INVALID);
} else if(G_voteDescription(ent, fRefereeCmd, dwVoteIndex)) return(G_INVALID);
else if((pid = ClientNumberFromString(ent, arg2)) == -1) return(G_INVALID);
if(level.clients[pid].sess.referee) {
G_refPrintf(ent, "Can't vote to PutSpec referees!");
return(G_INVALID);
}
if(G_shrubbot_permission(&g_entities[pid], SBF_IMMUNITY)) {
G_refPrintf( ent, "Can't vote to PutSpec admins!" );
return G_INVALID;
}
if(level.clients[pid].sess.sessionTeam == TEAM_SPECTATOR ||
level.clients[pid].sess.sessionTeam != ent->client->sess.sessionTeam) {
G_refPrintf(ent, "You can only PutSpec players in your own team!");
return G_INVALID;
}
Com_sprintf(level.voteInfo.vote_value, VOTE_MAXSTRING, "%d", pid);
Com_sprintf(arg2, VOTE_MAXSTRING, "%s^7", level.clients[pid].pers.netname);
// Vote action (vote has passed)
} else {
int pid = atoi(level.voteInfo.vote_value);
SetTeam( &g_entities[pid], "s", qtrue, -1, -1, qfalse );
trap_SendServerCommand( pid, va( "cpm \"^3You have been moved to the Spectators\"") );
AP(va("cp \"%s ^3has been\nmoved to the Spectators!\n\"", level.clients[pid].pers.netname));
ClientUserinfoChanged( pid );
if(g_gamestate.integer == GS_WARMUP || g_gamestate.integer == GS_WARMUP_COUNTDOWN) {
G_readyMatchState();
}
}
return(G_OK);
}
示例15: G_refPlayerPut_cmd
// Puts a player on a team.
void G_refPlayerPut_cmd( gentity_t *ent, int team_id )
{
int pid;
char arg[ MAX_TOKEN_CHARS ];
gentity_t *player;
// Works for teamplayish matches
if ( g_gametype.integer < GT_WOLF )
{
G_refPrintf( ent, "\"put[allies|axis]\" only for team-based games!" );
return;
}
// Find the player to place.
trap_Argv( 2, arg, sizeof( arg ) );
if ( ( pid = ClientNumberFromString( ent, arg ) ) == -1 )
{
return;
}
player = g_entities + pid;
// Can only move to other teams.
if ( player->client->sess.sessionTeam == team_id )
{
G_refPrintf( ent, "\"%s\" is already on team %s!", player->client->pers.netname, aTeams[ team_id ] ); // CHRUKER: b047 - Removed unneeded linebreak
return;
}
if ( team_maxplayers.integer && TeamCount( -1, team_id ) >= team_maxplayers.integer )
{
G_refPrintf( ent, "Sorry, the %s team is already full!", aTeams[ team_id ] ); // CHRUKER: b047 - Removed unneeded linebreak
return;
}
player->client->pers.invite = team_id;
player->client->pers.ready = qfalse;
if ( team_id == TEAM_AXIS )
{
SetTeam( player, "red", qtrue, -1, -1, qfalse );
}
else
{
SetTeam( player, "blue", qtrue, -1, -1, qfalse );
}
if ( g_gamestate.integer == GS_WARMUP || g_gamestate.integer == GS_WARMUP_COUNTDOWN )
{
G_readyMatchState();
}
}