Beispiel #1
0
void VoteYes()
{
	int votes;

	if( !get_votes( OV_ELECT ) )
		return;

	if( self->v.elect_type != etNone ) {
		G_sprint(self, 2, "You cannot vote for yourself\n");
		return;
	}

	if( self->v.elect ) {
		G_sprint(self, 2, "--- your vote is still good ---\n");
		return;
	}

// register the vote
	self->v.elect = 1;

	G_bprint(2, "%s gives %s vote\n", self->s.v.netname, g_his( self ));

// calculate how many more votes are needed
	if ( (votes = get_votes_req( OV_ELECT, true )) )
		G_bprint(2, "\x90%d\x91 more vote%s needed\n", votes, count_s( votes ));

	vote_check_elect ();
}
Beispiel #2
0
Datei: admin.c Projekt: 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"));
}
Beispiel #3
0
void VoteNo()
{
	int votes;

// withdraw one's vote
	if( !get_votes( OV_ELECT ) || self->v.elect_type != etNone || !self->v.elect )
		return;

// unregister the vote
	self->v.elect = 0;

	G_bprint(2, "%s withdraws %s vote\n", self->s.v.netname, g_his( self ));

// calculate how many more votes are needed
	if ( (votes = get_votes_req( OV_ELECT, true )) )
		G_bprint(2, "\x90%d\x91 more vote%s needed\n", votes, count_s( votes ));

	vote_check_elect ();
}
Beispiel #4
0
Datei: admin.c Projekt: deurk/ktx
void VoteAdmin()
{
	gedict_t *p;
	int   till;

	gedict_t *electguard;

// Can't allow election and code entering for the same person at the same time
	if( self->k_adminc ) {
		G_sprint(self, 2, "Finish entering the code first\n");
		return;
	}

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

	if( is_elected( self, etAdmin ) ) {
		G_bprint(2, "%s %s!\n", self->netname, redtext("aborts election"));
		AbortElect();
		return;
	}

// Only one election per server because otherwise we wouldn't know how to count
// "yes"s or "no"s
	if( get_votes( OV_ELECT ) ) {
		G_sprint(self, 2, "An election is already in progress\n");
		return;
	}

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

// Check if voteadmin is allowed
	if( !cvar( "k_allowvoteadmin" ) ) {
		G_sprint(self, 2, "Admin election is not allowed on this server\n");
		return;
	}

	if( (till = Q_rint( self->v.elect_block_till - g_globalvars.time)) > 0  ) {
		G_sprint(self, 2, "Wait %d second%s!\n", till, count_s(till) );
		return;
	}

	if( self->ct == ctSpec && match_in_progress )
		return;

	G_bprint(2, "%s has %s rights!\n", self->netname, redtext("requested admin"));

	for( p = world; (p = find_client( p )); )
		if ( p != self && p->ct == ctPlayer )
			G_sprint(p, 2, "Type %s in console to approve\n", redtext("yes"));

	G_sprint(self, 2, "Type %s to abort election\n", redtext("elect"));

    // announce the election
	self->v.elect = 1;
	self->v.elect_type = etAdmin;

	electguard = spawn(); // Check the 1 minute timeout for election
	electguard->s.v.owner = EDICT_TO_PROG( world );
	electguard->classname = "electguard";
	electguard->think = ( func_t ) ElectThink;
	electguard->s.v.nextthink = g_globalvars.time + 60;
}
Beispiel #5
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") );
}