Beispiel #1
0
/*
===================
Svcmd_ForceTeam_f

forceteam <player> <team>
===================
*/
static void Svcmd_ForceTeam_f( void )
{
  gclient_t *cl;
  char      str[ MAX_TOKEN_CHARS ];
  team_t    team;

  if( trap_Argc( ) != 3 )
  {
    G_Printf( "usage: forceteam <player> <team>\n" );
    return;
  }

  trap_Argv( 1, str, sizeof( str ) );
  cl = ClientForString( str );

  if( !cl )
    return;

  trap_Argv( 2, str, sizeof( str ) );
  team = G_TeamFromString( str );
  if( team == NUM_TEAMS )
  {
    G_Printf( "forceteam: invalid team \"%s\"\n", str );
    return;
  }
  G_ChangeTeam( &g_entities[ cl - level.clients ], team );
}
Beispiel #2
0
static void Svcmd_DumpUser_f( void )
{
  char name[ MAX_STRING_CHARS ], userinfo[ MAX_INFO_STRING ];
  char key[ BIG_INFO_KEY ], value[ BIG_INFO_VALUE ];
  const char *info;
  gclient_t *cl;

  if( trap_Argc( ) != 2 )
  {
    G_Printf( "usage: dumpuser <player>\n" );
    return;
  }

  trap_Argv( 1, name, sizeof( name ) );
  cl = ClientForString( name );
  if( !cl )
    return;

  trap_GetUserinfo( cl-level.clients, userinfo, sizeof( userinfo ) );
  info = &userinfo[ 0 ];
  G_Printf( "userinfo\n--------\n" );
  //Info_Print( userinfo );
  while( 1 )
  {
    Info_NextPair( &info, key, value );
    if( !*info )
      return;

    G_Printf( "%-20s%s\n", key, value );
  }
}
/*
===================
Svcmd_SendAway_f
Tequila: Replacement for kick command from server engine with sendaway one
*
sendaway <playername>
===================
*/
void Svcmd_SendAway_f(void) {
	// find the player
	gclient_t *cl = ClientForString( ConcatArgs(1) );
	if ( cl )
		trap_SendConsoleCommand( EXEC_INSERT, va("clientkick %i\n", cl->ps.clientNum) );
	else
		trap_SendServerCommand( -1, va("print \"Can't kick %s\"", ConcatArgs(1)) );
}
Beispiel #4
0
static void Svcmd_EjectClient_f( void )
{
	char *reason, name[ MAX_STRING_CHARS ];

	if ( trap_Argc() < 2 )
	{
		G_Printf( "usage: eject <player|-1> <reason>\n" );
		return;
	}

	trap_Argv( 1, name, sizeof( name ) );
	reason = ConcatArgs( 2 );

	if ( atoi( name ) == -1 )
	{
		int i;

		for ( i = 0; i < level.maxclients; i++ )
		{
			if ( level.clients[ i ].pers.connected == CON_DISCONNECTED )
			{
				continue;
			}

			if ( level.clients[ i ].pers.localClient )
			{
				continue;
			}

			trap_DropClient( i, reason, 0 );
		}
	}
	else
	{
		gclient_t *cl = ClientForString( name );

		if ( !cl )
		{
			return;
		}

		if ( cl->pers.localClient )
		{
			G_Printf( "eject: cannot eject local clients\n" );
			return;
		}

		trap_DropClient( cl - level.clients, reason, 0 );
	}
}
/*
===================
Svcmd_ForceTeam_f

forceteam <player> <team>
===================
*/
void	Svcmd_ForceTeam_f( void ) {
    gclient_t	*cl;
    char		str[MAX_TOKEN_CHARS];

    // find the player
    trap_Argv( 1, str, sizeof( str ) );
    cl = ClientForString( str );
    if ( !cl ) {
        return;
    }

    // set the team
    trap_Argv( 2, str, sizeof( str ) );
    SetTeam( &g_entities[cl - level.clients], str );
}
/*
===================
Svcmd_BigText_f
Tequila: BigText command suggested by villa
[bigtext|cp] [-1|clientNumber|playername] <message>
===================
*/
void Svcmd_BigText_f(void) {
	gclient_t	*cl;
	char		str[MAX_TOKEN_CHARS];

	trap_Argv( 1, str, sizeof( str ) );
	verbose = qfalse ;
	cl = ClientForString( str );
	verbose = qtrue ;

	if ( cl ) {
		trap_SendServerCommand( cl->ps.clientNum, va("cp \"%s\"", ConcatArgs(2) ) );
	} else	if ( Q_stricmp ("-1", str) == 0 )
		trap_SendServerCommand( -1, va("cp \"%s\"", ConcatArgs(2) ) );
	else
		trap_SendServerCommand( -1, va("cp \"%s\"", ConcatArgs(1) ) );
}
Beispiel #7
0
/*
===================
Svcmd_ForceTeam_f

forceteam <player> <team>
===================
*/
void	Svcmd_ForceTeam_f( void ) {
	gclient_t	*cl;
	char		str[MAX_TOKEN_CHARS];

	if ( trap->Argc() < 3 ) {
		trap->Print("Usage: forceteam <player> <team>\n");
		return;
	}

	// find the player
	trap->Argv( 1, str, sizeof( str ) );
	cl = ClientForString( str );
	if ( !cl ) {
		return;
	}

	// set the team
	trap->Argv( 2, str, sizeof( str ) );
	SetTeam( &g_entities[cl - level.clients], str );
}
void Svcmd_CamCmd( void ) {
    char buf[MAX_TOKEN_CHARS];
    char cmd[MAX_TOKEN_CHARS];
    char name[MAX_TOKEN_CHARS];
    int i;
    gclient_t* cl;

    if( !level.cammode ) {
        return;
    }

    if( trap_Argc() < 2 ) {
        return;
    }

    trap_Argv( 1, cmd, sizeof(cmd) );

    if ( !Q_stricmp (cmd, "print")  )
    {
        trap_Argv( 2, buf, sizeof(buf) );
        trap_SendServerCommand( -1, va("cp \"%s\n\"", buf ) );
    }
    else if( !Q_stricmp (cmd, "setclientpos") ) {
        vec3_t	newOrigin;

        if( trap_Argc() != 8 && trap_Argc() != 6 ) {
            Com_Printf("usage: camcmd setclientpos name/id x y z (a b) \na = PITCH-angle, b = YAW-angle\n");
            return;
        }

        trap_Argv( 2, name, sizeof( name ) );

        cl = ClientForString( name ) ;
        if(!cl)
            return;

        for( i=0; i<3; i++) {
            trap_Argv( i+3, buf, sizeof( buf) );
            newOrigin[i] = atof( buf );
        }

        G_SetOrigin( &g_entities[cl->ps.clientNum], newOrigin );
        VectorCopy( newOrigin, cl->ps.origin );

        if(trap_Argc() == 8) {
            vec3_t	newAngles;

            memset(newAngles,0,sizeof(newAngles));
            trap_Argv( 6, buf, sizeof( buf ) );
            newAngles[PITCH] = atoi(buf);
            trap_Argv( 7, buf, sizeof( buf ) );
            newAngles[YAW] = atoi(buf);

            SetClientViewAngle( &g_entities[cl->ps.clientNum], newAngles );
        }
    }
    else if( !Q_stricmp (cmd, "setspawn")  )
    {
        if( trap_Argc() != 8 ) {
            Com_Printf("usage: camcmd setspawn x y z a b c \n");
            return;
        }

        for( i=0; i<3; i++) {
            trap_Argv( i+2, buf, sizeof(buf) );
            level.cam_spawnpos[i] = atof(buf);
        }
        for( i=0; i<3; i++) {
            trap_Argv( i+5, buf, sizeof(buf) );
            level.cam_spawnangles[i] = atof(buf);
        }
    }
    else if( !Q_stricmp (cmd, "botmove")  )
    {
        vec3_t pos;

        if( trap_Argc() != 6 ) {
            Com_Printf("usage: camcmd botmove name x y z \n");
            return;
        }

        trap_Argv( 2, name, sizeof( name ) );

        for( i=0; i<3; i++) {
            trap_Argv( i+3, buf, sizeof( buf) );
            pos[i] = atof( buf );
        }

        cl = ClientForString( name ) ;
        if(!cl)
            return;
        BotCamMoveTo( cl->ps.clientNum, pos );
    }
    else if( !Q_stricmp (cmd, "botviewangles")  )
    {
        vec3_t angles;

        if( trap_Argc() != 5 ) {
            Com_Printf("usage: camcmd botviewangles name x y \n");
            return;
        }

        trap_Argv( 2, name, sizeof( name ) );
        cl = ClientForString( name ) ;
        if(!cl)
            return;
        trap_Argv( 3, buf, sizeof( buf ) );
        angles[PITCH] = atoi(buf);
        trap_Argv( 4, buf, sizeof( buf ) );
        angles[YAW] = atoi(buf);

        BotCamViewangles( cl->ps.clientNum, angles );
    }
    else if( !Q_stricmp (cmd, "botviewtarget")  )
    {
        vec3_t target;

        if( trap_Argc() != 6 ) {
            Com_Printf("usage: camcmd botviewtarget name x y z \n");
            return;
        }

        trap_Argv( 2, name, sizeof( name ) );
        cl = ClientForString( name ) ;
        if(!cl)
            return;
        trap_Argv( 3, buf, sizeof( buf ) );
        target[0] = atoi(buf);
        trap_Argv( 4, buf, sizeof( buf ) );
        target[1] = atoi(buf);
        trap_Argv( 5, buf, sizeof( buf ) );
        target[2] = atoi(buf);

        BotCamViewTarget( cl->ps.clientNum, target );
    }
    else if( !Q_stricmp (cmd, "botviewentity")  )
    {
//		int target_bot;
        gclient_t* target_cl;
        if( trap_Argc() != 4 ) {
            Com_Printf("usage: camcmd botviewentity name targetname \n");
            return;
        }

        trap_Argv( 2, name, sizeof( name ) );
        cl = ClientForString( name ) ;
        if(!cl)
            return;

        trap_Argv( 3, buf, sizeof( buf ) );
        target_cl = ClientForString( buf );
        if(!target_cl)
            return;
        BotCamViewEntitiy( cl->ps.clientNum, target_cl->ps.clientNum );

    }
    else if( !Q_stricmp (cmd, "boteditinv")  )
    {
        if( trap_Argc() < 3)
            return;
        trap_Argv( 2, name, sizeof(name) );
        cl = ClientForString( name );
        if( !cl ) return;
        EditPlayerInventory( &g_entities[cl->ps.clientNum], 3 );
    }
    else if( !Q_stricmp (cmd, "botchooseweap")  )
    {
        if( trap_Argc() != 4 ) {
            Com_Printf("usage: camcmd botchooseweap name weapID \n");
            return;
        }
        trap_Argv( 2, name, sizeof( name ) );
        cl = ClientForString( name ) ;
        if(!cl)
            return;
        trap_Argv( 3, buf, sizeof( buf ) );
        BotChooseWeap( cl->ps.clientNum, atoi(buf) );
    }
    else if( !Q_stricmp (cmd, "bottaunt")  )
    {
        if( trap_Argc() != 3 ) {
            Com_Printf("usage: camcmd bottaunt name \n");
            return;
        }
        trap_Argv( 2, name, sizeof( name ) );
        cl = ClientForString( name ) ;
        if(!cl)
            return;

        BotCamTaunt( cl->ps.clientNum );
    }
    else if( !Q_stricmp(cmd, "botfire") )
    {
        if( trap_Argc() != 3 ) {
            Com_Printf("usage: camcmd botfire name \n");
            return;
        }
        trap_Argv( 2, name, sizeof( name ) );
        cl = ClientForString( name ) ;
        if(!cl)
            return;

        BotCamFire( cl->ps.clientNum );
    }
    else if( !Q_stricmp(cmd, "freeze") ) {
        int on;


        if( trap_Argc() != 3 ) {
            Com_Printf("usage: camcmd freeze [0|1] \n");
            return;
        }
        trap_Argv( 2, name, sizeof( name ) );

        on = atoi( name );
        FreezePlayers( on );
    }

}
gclient_t	*ClientForString( const char *s ) {
	gclient_t	*cl;
	int			i;
	int			idnum;

	// numeric values are just slot numbers
	if ( s[0] >= '0' && s[0] <= '9' ) {
		idnum = atoi( s );
		if ( idnum < 0 || idnum >= level.maxclients ) {
			Com_Printf( "Bad client slot: %i\n", idnum );
			return NULL;
		}

		cl = &level.clients[idnum];
		if ( cl->pers.connected == CON_DISCONNECTED ) {
			G_Printf( "Client %i is not connected\n", idnum );
			return NULL;
		}
		return cl;
	}

	// check for a name match
	for ( i=0 ; i < level.maxclients ; i++ ) {
		cl = &level.clients[i];
		if ( cl->pers.connected == CON_DISCONNECTED ) {
			continue;
		}
#ifndef SMOKINGUNS
		if ( !Q_stricmp( cl->pers.netname, s ) ) {
#else
		// Tequila: netname should match an unique name, so name can't be stolen
		if ( !strcmp( cl->pers.netname, s ) ) {
#endif
			return cl;
		}
	}

#ifdef SMOKINGUNS
	if (verbose)
#endif
		G_Printf( "User %s is not on the server\n", s );

	return NULL;
}

/*
===================
Svcmd_ForceTeam_f

forceteam <player> <team>
===================
*/
void	Svcmd_ForceTeam_f( void ) {
	gclient_t	*cl;
	char		str[MAX_TOKEN_CHARS];

	// find the player
	trap_Argv( 1, str, sizeof( str ) );
	cl = ClientForString( str );
	if ( !cl ) {
		return;
	}

	// set the team
	trap_Argv( 2, str, sizeof( str ) );
	SetTeam( &g_entities[cl - level.clients], str );
}