Exemplo n.º 1
0
void
_CheckKickVote (void)
{
  int i, j, votes, maxvotes, playernum, playervoted;
  edict_t *other, *target, *mtarget;

  if (kickvotechanged == false)
    return;

  kickvotechanged = false;
  playernum = _numclients ();

  if (playernum < kickvote_need->value)
    return;

  maxvotes = 0;
  mtarget = NULL;
  playervoted = 0;
  for (i = 1; i <= game.maxclients; i++)
    {
      other = &g_edicts[i];
      if (other->client && other->inuse && other->client->resp.kickvote)
	{
	  votes = 0;
	  target = other->client->resp.kickvote;
	  playervoted++;
	  for (j = 1; j <= game.maxclients; j++)
	    {
	      other = &g_edicts[j];
	      if (other->client && other->inuse
		  && other->client->resp.kickvote == target)
		votes++;
	    }
	  if (votes > maxvotes)
	    {
	      maxvotes = votes;
	      mtarget = target;
	    }
	}
    }

  Mostkickvotes = NULL;

  if (!mtarget)
    return;

  Mostkickvotes = mtarget;
  Mostkickpercent = (float) (((float) maxvotes / (float) playernum) * 100.0);
  Allkickvotes = (float) (((float) playervoted / (float) playernum) * 100.0);

  if (Allkickvotes < kickvote_need->value)
    return;
  if (Mostkickpercent < kickvote_pass->value)
    return;

  // finally
  _DoKick (mtarget);
}
Exemplo n.º 2
0
void _CheckKickVote (void)
{
	int i, j, votes, maxvotes, playernum, playervoted;
	edict_t *ent, *other, *target, *mtarget;

	if (kickvotechanged == false)
		return;

	kickvotechanged = false;
	playernum = _numclients ();

	maxvotes = 0;
	mtarget = NULL;
	playervoted = 0;
	for (i = 0, other = g_edicts + 1; i < game.maxclients; i++, other++)
	{
		if (!other->client || !other->inuse)
			continue;

		target = other->client->resp.kickvote;
		if (!target || target == mtarget)
			continue;

		votes = 0;
		playervoted++;
		for (j = 0, ent = g_edicts + 1; j < game.maxclients; j++, ent++)
		{
			if (ent->client && ent->inuse && ent->client->resp.kickvote == target)
				votes++;
		}
		if (votes > maxvotes)
		{
			maxvotes = votes;
			mtarget = target;
		}
	}

	Mostkickvotes = NULL;

	if (!mtarget)
		return;

	Mostkickvotes = mtarget;
	Mostkickpercent = (float) (((float) maxvotes / (float) playernum) * 100.0);
	Allkickvotes = (float) (((float) playervoted / (float) playernum) * 100.0);

	if (playernum < kickvote_min->value)
		return;
	if (Allkickvotes < kickvote_need->value)
		return;
	if (Mostkickpercent < kickvote_pass->value)
		return;

	// finally
	_DoKick (mtarget);
}