コード例 #1
0
ファイル: vote.c プロジェクト: QuakePhil/ktx-hoonymode
void vote_check_elect ()
{
	gedict_t *p;

	if( !get_votes_req( OV_ELECT, true ) ) {

		for( p = world; (p = find_client( p )); )
			if ( p->v.elect_type != etNone )
				break;

		if ( !p ) { // nor admin nor captain found - probably bug
			AbortElect();
			return;
		}

		if( !(p->ct == ctSpec && match_in_progress) )
		if( is_elected(p, etAdmin) ) // s: election was admin election
			BecomeAdmin(p, AF_ADMIN);

		if( !match_in_progress )
		if( is_elected(p, etCaptain) ) // s: election was captain election
			BecomeCaptain(p);

		AbortElect();
		return;
	}
}
コード例 #2
0
ファイル: admin.c プロジェクト: deurk/ktx
void AdminImpBot ()
{
    float coef, i1;

    if( self->k_adminc < 1 )
    {
        self->k_adminc = 0;
        return;
    }

    i1   = (int)(self->k_adminc -= 1);
    coef = self->s.v.impulse;

    while( i1 > 0 )
    {
        coef *= 10;
        i1--;
    }

    self->k_added += coef;

    if( self->k_adminc < 1 )
    {
		int iPass = cvar( "k_admincode" );
		int till = Q_rint(self->k_adm_lasttime + 5 - g_globalvars.time);

        self->k_adminc = 0;

		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;
		}

        if( iPass && self->k_added == iPass )
        {
			BecomeAdmin(self, AF_REAL_ADMIN);
			return;
        }
        else
        {
            G_sprint(self, 2, "%s...\n", redtext("Access denied"));
			self->k_adm_lasttime = g_globalvars.time;
        }
    }
    else
        G_sprint(self, 2, "%d %s\n", (int)self->k_adminc, redtext("more to go"));
}
コード例 #3
0
ファイル: admin.c プロジェクト: 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") );
}