Example #1
0
// ktpro (c)
void force_spec()
{
	qbool found = false;
	gedict_t *p = NULL;
	char *c_fs, arg_2[1024];
	int i_fs, argc = trap_CmdArgc();

	if ( !is_adm( self ) )
		return;

	trap_CmdArgv( 1, arg_2, sizeof( arg_2 ) );
	c_fs = (argc >= 2 ? arg_2 : ezinfokey(self, "fs"));

	if ( strnull( c_fs ) ) {
		G_sprint(self, 2, "set setinfo \"fs\" properly\n");
		G_sprint(self, 2, "to force spec all not ready players\n");
		G_sprint(self, 2, "type: %s\n", redtext("setinfo fs \"*\""));
		G_sprint(self, 2, "or: %s to force spec specified player\n", redtext("setinfo fs \"playername\""));
		G_sprint(self, 2, "or just: %s\n", redtext("/force_spec \"playername\""));
		return;
	}

	if ( streq( c_fs, "*") || streq( c_fs, "* ") ) {
		//ok move all not ready players to specs
		for( p = world; (p = find_plr( p )); ) {
			if ( p->ready || p == self )
				continue;

			found = true;
			do_force_spec(p, self, true);
		}
	}
	else {
		p = ( (i_fs = atoi( c_fs ) ) < 0 ? spec_by_id( -i_fs ) : SpecPlayer_by_IDorName( c_fs ));
		if ( p ) {
			found = true;
			do_force_spec(p, self, p->ct != ctSpec);
		}
	}

	if ( !found ) 
		G_sprint(self, 2, "can't find specified players\n");
}
Example #2
0
File: ui.c Project: MrPnut/QHome
void Bot()
{
        
        char    cmd_command[50];
        int argc,i;
        bot_cmd_t*ucmd;

        if( api_ver < 7 )
        {
                G_sprint( self, 2, "Bots disabled (API version %d)\n",api_ver );
                return;
        }

	if ( !tf_data.enable_bot )
	{
		G_sprint( self, 2, "Bots disabled\n" );
//FIXME!!!!
                return;
	}

	argc = trap_CmdArgc();
	
	if( argc == 1 )
	{
	        G_sprint( self, 2, "Avaliable commands\n");
		for ( ucmd = bot_cmds ; ucmd->command  ; ucmd++ )
		{
			G_sprint( self, 2, "%s\n",ucmd->command);
		}
		return;
	}

	trap_CmdArgv( 1, cmd_command, sizeof( cmd_command ) );
	for ( ucmd = bot_cmds,i=0 ; ucmd->command  ; ucmd++,i++ )
	{
		if( !strcmp(cmd_command,ucmd->command) )
		{
			ucmd->func();
			return;
		}
	}
}
Example #3
0
File: admin.c Project: deurk/ktx
void AdminKick ()
{
	int argc = trap_CmdArgc();

    if( !is_adm( self ) )
    {
        G_sprint(self, 2, "You are not an admin\n");
        return;
    }

    if( self->k_kicking ) {
        ExitKick( self );
		return;
	}

	if ( argc >= 2 ) {
		gedict_t *p;
		char arg_2[1024], *str;

		trap_CmdArgv( 1, arg_2, sizeof( arg_2 ) );

		if ( !(p = SpecPlayer_by_IDorName( arg_2 )) && !(p = not_connected_by_IDorName( arg_2 )) ) {
			G_sprint(self, 2, "kick: client %s not found\n", arg_2);
			return;
		}

		if ( DoKick( p, self ) && !strnull( str = params_str(2, -1) ) ) // show reason
			G_bprint(2, "\x90%s\x91\n", str);

		return;
	}

    G_sprint(self, 2, "Kicking process started\n"
					  "�����������������������\n"
					  "Type \371 to kick, \356 for next, %s to leave\n", redtext("kick"));

    self->k_kicking = g_globalvars.time;
    self->k_playertokick = world;

    NextClient();
}
Example #4
0
void ModCommand()
{
        char    cmd_command[1024];
        int argc;
        const mod_t  *ucmd;

        argc = trap_CmdArgc();
        if( argc < 2 )
                return;


        trap_CmdArgv( 1, cmd_command, sizeof( cmd_command ) );

	for ( ucmd = mod_cmds; ucmd->command; ucmd++ )
	{
		if ( strcmp( cmd_command, ucmd->command ) )
			continue;
		ucmd->Action( argc );
		return;
	}
	return;

}
Example #5
0
File: admin.c Project: deurk/ktx
void ReqAdmin ()
{
    //  check for election
    if( is_elected(self, etAdmin) )
    {
        G_sprint(self, 2, "Abort %sion first\n", redtext("elect"));
        return;
    }

    if( is_adm( self ) )
    {
        G_bprint(2, "%s is no longer an %s\n", self->netname, redtext("admin"));

        if( self->k_kicking )
            ExitKick( self );

        self->k_admin = 0; // ok, remove all admin flags

		on_unadmin( self );

        return;
    }

    if( self->k_adminc )
	{
        G_sprint(self, 2, "%s code canceled\n", redtext("admin"));
    	self->k_adminc = 0;
		return;
	}

	if( !cvar( "k_admins" ) ) {
		G_sprint(self, 2, "%s on this server!\n", redtext("NO admins"));
		return;
	}

	if ( VIP_IsFlags( self, VIP_ADMIN ) ) // this VIP does't required pass
    {
		BecomeAdmin(self, AF_REAL_ADMIN);
		return;
    }
	
	// parse /admin <pass>
	if ( trap_CmdArgc() == 2 ) {
		char arg_2[1024];
		char *pass = cvar_string( "k_admincode" );
		int till = Q_rint(self->k_adm_lasttime + 5 - g_globalvars.time);

		if( self->k_adm_lasttime && till > 0  ) { // probably must help against brute force
			G_sprint(self, 2, "Wait %d second%s!\n", till, count_s(till) );
			return;
		}

		trap_CmdArgv( 1, arg_2, sizeof( arg_2 ) );

		if ( !strnull(pass) && strneq(pass, "none") && streq(arg_2, pass) )
			BecomeAdmin(self, AF_REAL_ADMIN);
		else {
            G_sprint(self, 2, "%s...\n", redtext("Access denied"));
			self->k_adm_lasttime = g_globalvars.time;
		}

		return;
	}

    self->k_adminc = 6;
    self->k_added  = 0;

    // You can now use numbers to enter code
    G_sprint(self, 2, "Use %s or %s to enter code\n", redtext("numbers"), redtext("impulses") );
}
Example #6
0
void WP_command( int argc )
{
        char    cmd_command[1024];
        if( argc < 3)
                return;
        
        trap_CmdArgv( 2, cmd_command, sizeof( cmd_command ) );

        if(!strcmp(cmd_command, "add"))
        {
                waypoint_t wp;

                if( argc < 7 )
                        return;

                memset(&wp, 0 ,sizeof(wp));
                trap_CmdArgv( 3, cmd_command, sizeof( cmd_command ) );
                wp.index = atoi( cmd_command );
                trap_CmdArgv( 4, cmd_command, sizeof( cmd_command ) );
                wp.origin[0] = atof( cmd_command );
                trap_CmdArgv( 5, cmd_command, sizeof( cmd_command ) );
                wp.origin[1] = atof( cmd_command );
                trap_CmdArgv( 6, cmd_command, sizeof( cmd_command ) );
                wp.origin[2] = atof( cmd_command );
                wp.teams = 15 ;// (1<<0)+(1<<1)+(1<<2)+(1<<3);
                if( argc > 7 )
                {
                        trap_CmdArgv( 7, cmd_command, sizeof( cmd_command ) );
                        wp.flags = atoi( cmd_command );
                        
                }
                if( argc > 8 )
                {
                        trap_CmdArgv( 8, cmd_command, sizeof( cmd_command ) );
                        wp.teams = atoi( cmd_command );
                }

                if( argc > 9 )
                {
                        trap_CmdArgv( 9, cmd_command, sizeof( cmd_command ) );
                        wp.radius = atof( cmd_command );
                        
                }
                AddWaypoint(&wp);
                return;
        }

        if(!strcmp(cmd_command, "link"))
        {
                wp_link_t link;
                int i1,i2;
                if( argc < 5 )
                        return;

                memset(&link, 0 ,sizeof(link));
                trap_CmdArgv( 3, cmd_command, sizeof( cmd_command ) );
                i1 = atoi( cmd_command );
                trap_CmdArgv( 4, cmd_command, sizeof( cmd_command ) );
                i2 = atoi( cmd_command );
                link.teams = 15;
                if( argc > 5 )
                {
                        trap_CmdArgv( 5, cmd_command, sizeof( cmd_command ) );
                        link.flags = atoi( cmd_command );
                }
                if( argc > 6 )
                {
                        trap_CmdArgv( 6, cmd_command, sizeof( cmd_command ) );
                        link.teams = atoi( cmd_command );
                }

                if( argc > 7 )
                {
                        trap_CmdArgv( 7, cmd_command, sizeof( cmd_command ) );
                        link.req_velocity = atof( cmd_command );
                        
                }
                AddLink( i1, i2, &link);
                return;
        }

        if(!strcmp(cmd_command, "dlink"))
        {
                wp_link_t link;
                int i1,i2;
                if( argc < 5 )
                        return;

                memset(&link, 0 ,sizeof(link));
                trap_CmdArgv( 3, cmd_command, sizeof( cmd_command ) );
                i1 = atoi( cmd_command );
                trap_CmdArgv( 4, cmd_command, sizeof( cmd_command ) );
                i2 = atoi( cmd_command );
                link.teams = 15;
                if( argc > 5 )
                {
                        trap_CmdArgv( 5, cmd_command, sizeof( cmd_command ) );
                        link.flags = atoi( cmd_command );
                }
                if( argc > 6 )
                {
                        trap_CmdArgv( 6, cmd_command, sizeof( cmd_command ) );
                        link.teams = atoi( cmd_command );
                }

                if( argc > 7 )
                {
                        trap_CmdArgv( 7, cmd_command, sizeof( cmd_command ) );
                        link.req_velocity = atof( cmd_command );
                        
                }
                AddLink( i1, i2, &link);
                AddLink( i2, i1, &link);
                return;
        }

        if(!strcmp(cmd_command, "target"))
        {
                if( argc < 6 )
                        return;

                trap_CmdArgv( 3, cmd_command, sizeof( cmd_command ) );
                end_pos[0] = atof( cmd_command );
                trap_CmdArgv( 4, cmd_command, sizeof( cmd_command ) );
                end_pos[1] = atof( cmd_command );
                trap_CmdArgv( 5, cmd_command, sizeof( cmd_command ) );
                end_pos[2] = atof( cmd_command );
                return;
        }
        if(!strcmp(cmd_command, "draw"))
        {
                DrawWPS();
                return;
        }
        if(!strcmp(cmd_command, "clear"))
        {
                ClearWaypoints();
                return;
        }
}
Example #7
0
void Red_Def_command( int argc )
{
        char    cmd_command[1024];
        static  qboolean red_def_mode =  false;
	gedict_t *Goal,*saveself;
	gedict_t *te,*owner;

	if( tf_data.mtfl )
	{
       	        if( self != world )
      		         G_sprint(self,2,"Not allowed for mtfl.\n" );
      		return;
	}
        if( argc < 3)
        {
                if( self == world )
                        return;
                if( red_def_mode )
                        G_sprint(self, 2, "Red-Def mode is ON\n");
                else
                        G_sprint(self, 2, "Red-Def mode is OFF\n");
                return;
        }
        saveself = self;
        trap_CmdArgv( 2, cmd_command, sizeof( cmd_command ) );
        if( !strcmp(cmd_command,"on") )
        {
                if( red_def_mode )
                {
        	        if( self != world )
                                G_sprint(self, 2, "Red-Def mode already activated\n");
                        return;
                }

	        Goal = trap_find( world, FOFS( s.v.classname ), "info_tfdetect" );

                if ( !Goal )
	       	       return;
	        if ( !Goal->display_item_status1 )
	                return;
       	        te = Finditem( Goal->display_item_status1 );

       	        if( !te || te == world || te->team_no != 2 )
       	        {
       	                te = Finditem( Goal->display_item_status2 );
       	        }
       	        if( !te || te == world || te->team_no != 2 )
       	        {
       	                te = Finditem( Goal->display_item_status3 );
       	        }
       	        if( !te || te == world || te->team_no != 2 )
       	        {
       	                te = Finditem( Goal->display_item_status4 );
       	        }

                if ( te == world || te->team_no != 2 )
        	{
        	        if( self != world )
             		         G_sprint(self,2,"Item is missing.\n" );
        		return;
        	}
        	owner = PROG_TO_EDICT(te->s.v.owner);
        	if( owner != world )
        	{
        	        tfgoalitem_RemoveFromPlayer( te, owner, 1 );
        	}
        	te->take_sshot = 1;
                red_def_mode = true;
                G_bprint(2,"�εδ-ΔΕζ νοδε αγτιφατεδ\n");
                return;
        }
        if( !strcmp(cmd_command,"off") )
        {
                if( !red_def_mode )
                {
        	        if( self != world )
                                G_sprint(self,2,"Red-Def mode not active\n");
                        return;
                }
	        Goal = trap_find( world, FOFS( s.v.classname ), "info_tfdetect" );

                if ( !Goal )
	       	       return;
	        if ( !Goal->display_item_status1 )
	                return;
       	        te = Finditem( Goal->display_item_status1 );
       	        if( !te || te == world || te->team_no != 2 )
       	        {
       	                te = Finditem( Goal->display_item_status2 );
       	        }
       	        if( !te || te == world || te->team_no != 2 )
       	        {
       	                te = Finditem( Goal->display_item_status3 );
       	        }
       	        if( !te || te == world || te->team_no != 2 )
       	        {
       	                te = Finditem( Goal->display_item_status4 );
       	        }

                if ( te == world || te->team_no != 2 )
        	{
        	        if( self != world )
             		         G_sprint(self,2,"Item is missing.\n" );
        		return;
        	}
        	te->take_sshot = 0;
                red_def_mode = false;
                G_bprint(2,"�εδ-ΔΕζ νοδε δεαγτιφατεδ\n");
                return;
        }

}
Example #8
0
void TG_Cmd()
{
        char    cmd_command[50];
        char    st[50];
        int argc;


	if( !tg_data.tg_enabled )
	{
		G_sprint(self, 2, "Training Ground mode not active\n");
		return;
	
	}
	argc = trap_CmdArgc();
	if(argc<2)
		return;

        trap_CmdArgv( 1, cmd_command, sizeof( cmd_command ) );
        if(!strcmp(cmd_command,"sgppl"))
        {
                if(argc<3)
                {
                	G_sprint(self, 2, "sgppl %d\n",tf_data.sgppl);
                	return;
                }
                	
                trap_CmdArgv( 2, st, sizeof( st ) );
                tf_data.sgppl = atoi(st);
                if( tf_data.sgppl < 0)
                	tf_data.sgppl = 0;
                return;
        }

        if(!strcmp(cmd_command,"sg_fire"))
        {
                if(argc<3)
                {
                	G_sprint(self, 2, "SG_Fire %s\n",(!tg_data.sg_disable_fire)?"On":"Off");
                	return;
                }
                	
                trap_CmdArgv( 2, st, sizeof( st ) );
          	if ( !strcmp( st, "off" ) )
          		tg_data.sg_disable_fire = 1;
          	else if( !strcmp( st, "toggle" ) )
          	{
          	        tg_data.sg_disable_fire = (tg_data.sg_disable_fire)?0:1;
          	}else
          	{
          		tg_data.sg_disable_fire = 0;
          	}
                return;
        }
        if(!strcmp(cmd_command,"sg_find"))
        {
                if(argc<3)
                {
                	G_sprint(self, 2, "SG_Find \n");
                	return;
                }
                	
                trap_CmdArgv( 2, st, sizeof( st ) );
          	if ( !strcmp( st, "all" ) )
          		tg_data.sg_allow_find = TG_SG_FIND_IGNORE_OFF;
          	else if( !strcmp( st, "self" ) )
          		tg_data.sg_allow_find = TG_SG_FIND_IGNORE_OWNER;
          		else if( !strcmp( st, "no" ) )
          				tg_data.sg_allow_find = TG_SG_FIND_IGNORE_ALL;
          			else
          				tg_data.sg_allow_find = TG_SG_FIND_IGNORE_TEAM;
                return;
        }

        if(!strcmp(cmd_command,"sg_fire_bullets"))
        {
                if(argc<3)
                {
                	G_sprint(self, 2, "sg_fire_bullets is %s\n", tg_data.sg_fire_bullets?"on":"off");
                	return;
                }
                trap_CmdArgv( 2, st, sizeof( st ) );
         	if( !strcmp(st,"off") )
         	        tg_data.sg_fire_bullets = false;
         	else
         	        tg_data.sg_fire_bullets = true;
         	return;
        }
        if(!strcmp(cmd_command,"sg_fire_rockets"))
        {
                if(argc<3)
                {
                	G_sprint(self, 2, "sg_fire_rockets is %s\n", tg_data.sg_fire_rockets?"on":"off");
                	return;
                }
                trap_CmdArgv( 2, st, sizeof( st ) );
         	if( !strcmp(st,"off") )
         	        tg_data.sg_fire_rockets = false;
         	else
         	        tg_data.sg_fire_rockets = true;
         	return;
        }
        if(!strcmp(cmd_command,"sg_fire_lighting"))
        {
                if(argc<3)
                {
                	G_sprint(self, 2, "sg_fire_lighting is %s\n", tg_data.sg_fire_lighting?"on":"off");
                	return;
                }
                trap_CmdArgv( 2, st, sizeof( st ) );
         	if( strcmp(st,"on") )
         	        tg_data.sg_fire_lighting = false;
         	else
         	        tg_data.sg_fire_lighting = true;
         	return;
        }

/*        if(!strcmp(cmd_command,"sg_fire_type"))
        {
                if(argc<3)
                {
                	G_sprint(self, 2, "sg_fire_type \n");
                	return;
                }
                	
                trap_CmdArgv( 2, st, sizeof( st ) );
        	if ( !strcmp( st, "nodmg" ) )
        		tg_data.sg_fire_type = TG_SG_FIRE_LIGHTING;
        	else if( !strcmp( st, "bullets" ) )
        			tg_data.sg_fire_type = TG_SG_FIRE_BULLETS;
       		else
        			tg_data.sg_fire_type = TG_SG_FIRE_NORMAL;
                return;
        }*/
	if ( !strcmp( cmd_command, "eff_conc" ) )
	{
	     TG_Eff_Conc(self);
	     return;
	}

	if ( !strcmp( cmd_command, "god" ) )
	{

	     if ( ( int ) self->s.v.flags & FL_GODMODE )
	     {
	        G_sprint(self,2,"God mode off\n");
	        self->s.v.flags = ( int ) self->s.v.flags - FL_GODMODE;
	     }else
	     {
	        G_sprint(self,2,"God mode on\n");
	        self->s.v.flags = ( int ) self->s.v.flags | FL_GODMODE;
	     }
	     return;
	}
}
Example #9
0
qboolean ClientUserInfoChanged(  )
{
	char    key[1024];
	char    value[1024];
	const   char   *sk;
	int     color;

	self = PROG_TO_EDICT( g_globalvars.self );

	trap_CmdArgv( 1, key, sizeof( key ) );
	trap_CmdArgv( 2, value, sizeof( value ) );

	if ( !strcmp( key, "team" ) )
	{
		if ( !self->team_no )
			return 0;
		sk = GetTeamName( self->team_no );
		if ( strneq( value, sk ) )
		{
			SetTeamName( self );
			G_sprint( self, 2, "you cannot change your team setinfo\n" );
			return 1;
		}
		return 0;
	}
	if ( !strcmp( key, "skin" ) )
	{
		if ( !self->playerclass || !self->team_no )
			return 0;
		sk = TeamFortress_GetSkin( self );
		if ( strneq( value, sk ) )
		{
			G_sprint( self, 2, "you cannot change your skin setinfo\n" );
			TeamFortress_SetSkin( self );
			return 1;
		}
		return 0;
	}
	if ( ( !strcmp( key, "topcolor" ) ) && tf_data.topcolor_check )
	{
		if ( !self->team_no )
			return 0;
		color = atoi( value );
		if ( self->playerclass == PC_SPY && self->undercover_team )
		{
			if ( TeamFortress_TeamGetTopColor( self->undercover_team ) != color )
			{
				G_sprint( self, 2, "you cannot change your topcolor setinfo\n" );
				return 1;
			}
		} else
		{
			if ( TeamFortress_TeamGetTopColor( self->team_no ) != color )
			{
				G_sprint( self, 2, "you cannot change your topcolor setinfo\n" );
				return 1;
			}
		}
		return 0;
	}

	if ( ( !strcmp( key, "bottomcolor" ) ) )
	{
		if ( !self->team_no )
			return 0;
		color = atoi( value );
		if ( self->playerclass == PC_SPY && self->undercover_team )
		{
			if ( TeamFortress_TeamGetColor( self->undercover_team ) - 1 != color )
			{
				G_sprint( self, 2, "you cannot change your bottomcolor setinfo\n" );
				return 1;
			}
		} else
		{
			if ( TeamFortress_TeamGetColor( self->team_no ) - 1 != color )
			{
				G_sprint( self, 2, "you cannot change your bottomcolor setinfo\n" );
				return 1;
			}
		}
		return 0;
	}

	SetClientSetting( self, Q_strlwr( key ), value);
	return 0;

}