Beispiel #1
0
void SetTeamName( gedict_t * p )
{
        if ( p->isBot )
        {
                if( p->team_no >0 && p->team_no <=4)
                        trap_SetBotUserInfo(NUM_FOR_EDICT( p ),"team",team_names[p->team_no-1 ]);
                else
                        trap_SetBotUserInfo(NUM_FOR_EDICT( p ),"team","");
        }else
	       stuffcmd( p, "team %s\n", GetTeamName( p->team_no ) );
}
Beispiel #2
0
Datei: vote.c Projekt: deurk/ktx
// !!! do not confuse rpickup and pickup
void vote_check_rpickup ()
{
	float frnd;
    int i, tn, pl_cnt, pl_idx;
	gedict_t *p;
	int veto;

	if ( match_in_progress || k_captains )
		return;

	if ( !get_votes( OV_RPICKUP ) )
		return;

   	// Firstly obtain the number of players we have in total on server
   	pl_cnt = CountPlayers();

	if ( pl_cnt < 4 )
		return;

	veto = is_admins_vote( OV_RPICKUP );

	if( veto || !get_votes_req( OV_RPICKUP, true ) ) {
		vote_clear( OV_RPICKUP );

		for( p = world; (p = find_plr( p )); )
			p->k_teamnumber = 0;

		for( tn = 1; pl_cnt > 0; pl_cnt-- ) {
			frnd = g_random(); // bound is macros - so u _can't_ put g_random inside bound
			pl_idx = bound(0, (int)( frnd * pl_cnt ), pl_cnt-1 ); // select random player between 0 and pl_cnt

			for( i = 0, p = world; (p = find_plr( p )); ) {
				if ( p->k_teamnumber )
					continue;

				if ( i == pl_idx ) {
					p->k_teamnumber = tn;
					tn = (tn == 1 ? 2 : 1); // next random player will be in other team

					if (p->k_teamnumber == 1) {
						if (p->isBot) {
							trap_SetBotUserInfo(NUM_FOR_EDICT(p), "team", "red", 0);
							trap_SetBotUserInfo(NUM_FOR_EDICT(p), "topcolor", "4", 0);
							trap_SetBotUserInfo(NUM_FOR_EDICT(p), "bottomcolor", "4", 0);
						}
						else {
							stuffcmd_flags(p, STUFFCMD_IGNOREINDEMO, "break\ncolor  4\nskin \"\"\nteam red\n");
						}
					}
					else {
						if (p->isBot) {
							trap_SetBotUserInfo(NUM_FOR_EDICT(p), "team", "blue", 0);
							trap_SetBotUserInfo(NUM_FOR_EDICT(p), "topcolor", "13", 0);
							trap_SetBotUserInfo(NUM_FOR_EDICT(p), "bottomcolor", "13", 0);
						}
						else {
							stuffcmd_flags(p, STUFFCMD_IGNOREINDEMO, "break\ncolor 13\nskin \"\"\nteam blue\n");
						}
					}

					break;
				}

				i++;
			}
		}

		if ( veto )
			G_bprint(2, "console: admin veto for %s\n", redtext("random pickup"));
		else
    		G_bprint(2, "console: %s game it is then\n", redtext("random pickup"));

		return;
	}
}