Beispiel #1
0
void Vote_Cmd()
{
        char    cmd_command[50];
        int argc,i;
        const vote_t*ucmd;

	if ( tf_data.cb_prematch_time > g_globalvars.time )
	{
		return;
	}

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

	trap_CmdArgv( 1, cmd_command, sizeof( cmd_command ) );
	if( current_vote != -1 )
	{
		if(!strcmp(cmd_command,"yes"))
		{
		        votes[current_vote].VoteYes();
			return;
		}

		if(!strcmp(cmd_command,"no"))
		{
		        votes[current_vote].VoteNo();
			return;
		}
		G_sprint( self, 2, "Vote %s in progress\n",votes[current_vote].command);
	        return;
	}
	if( g_globalvars.time < self->last_vote_time )
	{
		G_sprint( self, 2, "You cannot vote at this time.\n");
		return;
	}
	for ( ucmd = votes,i=0 ; ucmd->command  ; ucmd++,i++ )
	{
		if( !strcmp(cmd_command,ucmd->command) )
		{
		        current_vote = i;
		        self->last_vote_time = g_globalvars.time + votes[current_vote].pause * 60;
			ucmd->VoteInit();
			return;
		}
	}
	G_sprint( self, 2, "Unknown vote.\n");
}
Beispiel #2
0
Datei: admin.c Projekt: deurk/ktx
// 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");
}
Beispiel #3
0
Datei: admin.c Projekt: deurk/ktx
// multi kick
void m_kick ()
{
	int i, k;
	gedict_t *p;
	char arg_x[1024], *str;
	int argc = trap_CmdArgc();

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

	trap_CmdArgv( 1, arg_x, sizeof( arg_x ) );

	if ( argc < 2 || !only_digits(arg_x) ) {
        G_sprint(self, 2, "mkick <id1 [id2 [id3 ...]] [reason]>\n");
		return;
	}

	for ( k = 0, i = 1; i < argc; i++ ) {
		trap_CmdArgv( i, arg_x, sizeof( arg_x ) );

		if ( !only_digits(arg_x) )
			break;

		if ( !(p = SpecPlayer_by_id( atoi(arg_x) )) && !(p = not_connected_by_id( atoi(arg_x) )) ) {
			G_sprint(self, 2, "mkick: client %s not found\n", arg_x);
			continue;
		}

		if( !DoKick( p, self ) )
			continue;

		k++;
	}

	if ( !k )
		return;

	if ( !strnull( str = params_str(i, -1) ) ) // show reason
		G_bprint(2, "\x90%s\x91\n", str);
}
Beispiel #4
0
Datei: ui.c Projekt: 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;
		}
	}
}
Beispiel #5
0
Datei: admin.c Projekt: 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();
}
Beispiel #6
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;

}
Beispiel #7
0
Datei: admin.c Projekt: 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") );
}
Beispiel #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;
	}
}