Hi i need some help to be able to have sats with ignored list and the ignored players must be able to see the stats of the others
Acually with my code they cannot
/Done
class Stats extends Mutator config(MH2Stats);
var config string Pname[5000], TopPname[10];
var config int Frags[5000], TopFrags[10], Games[5000], TopGames[10];
var config int MaxScorePerMap, MapBonus;
Var config string Ignorlist[30];
var string TempPname[64];
var int TempFrags[64];
var bool bInit, bStatsTransfered, bMatchEnded;
var int Cycle;
function AssignTopInfo(PlayerPawn Other)
{
local IPRI PRI;
PRI = IPRI(Other.PlayerReplicationInfo);
PRI.Name1 = TopPname[0];
PRI.Name2 = TopPname[1];
PRI.Name3 = TopPname[2];
PRI.Name4 = TopPname[3];
PRI.Name5 = TopPname[4];
PRI.Name6 = TopPname[5];
PRI.Name7 = TopPname[6];
PRI.Name8 = TopPname[7];
PRI.Name9 = TopPname[8];
PRI.Name10 = TopPname[9];
PRI.Frags1 = TopFrags[0];
PRI.Frags2 = TopFrags[1];
PRI.Frags3 = TopFrags[2];
PRI.Frags4 = TopFrags[3];
PRI.Frags5 = TopFrags[4];
PRI.Frags6 = TopFrags[5];
PRI.Frags7 = TopFrags[6];
PRI.Frags8 = TopFrags[7];
PRI.Frags9 = TopFrags[8];
PRI.Frags10 = TopFrags[9];
PRI.G1 = TopGames[0];
PRI.G2 = TopGames[1];
PRI.G3 = TopGames[2];
PRI.G4 = TopGames[3];
PRI.G5 = TopGames[4];
PRI.G6 = TopGames[5];
PRI.G7 = TopGames[6];
PRI.G8 = TopGames[7];
PRI.G9 = TopGames[8];
PRI.G10 = TopGames[9];
Other.Tag = 'tagged';
/*
//if you would use arrays for Name, Frags and G in IPRI, you could use this one..
local IPRI PRI;
local int i;
PRI = IPRI(Other.PlayerReplicationInfo);
for (i=0; i<ArrayCount(PRI.Name); i++) {
PRI.Name[i] = TopPname[i];
PRI.Frags[i] = TopFrags[i];
PRI.G[i] = TopGames[i];
}
Other.Tag = 'tagged';
*/
}
function PostBeginPlay()
{
local int i;
if (bInit) {
return;
}
bInit = True;
Log("Stats mutator activated");
SetTimer(0.001, true); //its realy fast, or not?
for (i=0; i<64; i++) {
TempPname[i] = "";
TempFrags[i] = 0;
}
if (NextMutator != None) {
NextMutator.PostBeginPlay();
}
}
function Timer()
{
// To call just a function in Timer() is to slow i think.
// So do all the DataHandler() stuff in Timer().
// DataHandler();
local IPRI PRI;
local Pawn P;
local int i;
for (P = Level.PawnList; P != None; P = P.NextPawn) {
if (P.IsA('PlayerPawn')) {
PRI = IPRI(PlayerPawn(P).PlayerReplicationInfo);
// Stops incomplete stats being given to default name Player
// if (P.PlayerReplicationInfo.PlayerName != "Player") { //will done in IsAcceptedName().
// Check if PlayerName is on the Ignorlist
if (IsAcceptedName(P)) {
// if (P.PlayerReplicationInfo.PlayerName != "§" ) { // Stops stats given by name = "§"
for (i=0; i<64; i++) {
if (TempPname[i] == PRI.PlayerName || TempPname[i] == "") {
TempPname[i] = PRI.PlayerName;
TempFrags[i] = PRI.Score;
if (Pname[Cycle] == PRI.PlayerName) {
PRI.Games = Games[Cycle];
if (!bMatchEnded) {
PRI.TotalFrags = Frags[Cycle] + PRI.Score;
} else {
PRI.TotalFrags = Frags[Cycle];
}
}
if (P.Tag != 'tagged') {
AssignTopInfo(PlayerPawn(P));
}
i = 65;
}
}
}
// }
}
}
Cycle++;
if (Cycle > 5000 || Pname[Cycle] == "") {
Cycle = 0;
}
}
function bool IsAcceptedName(Pawn P)
{
local string PName;
local int i;
PName = P.PlayerReplicationInfo.PlayerName;
if (PName == "Player") {
return False;
}
for (i=0; i < ArrayCount(Ignorlist); i++) {
/*
used Caps, so you dont need to do this:
Ignorlist[0]=<[MHA]>mister_under
Ignorlist[1]=<[MHA]>Mister_Under
*/
if (Caps(PName) == Caps(Ignorlist[i])) {
return False;
}
}
return True;
}
function StatsActivated()
{
local IPRI PRI;
local Pawn P;
local int i,ii;
if (!bStatsTransfered) {
// DataHandler(); // the Timer should still run on HandleEndGame(), so not needed i think.
for (i=0; i<64; i++) {
if (TempPname[i] != "") {
for (ii=0; ii<5000; ii++) {
if (Pname[ii] == TempPname[i] || Pname[ii] == "") {
Pname[ii] = TempPname[i];
if (TempFrags[i] > MaxScorePerMap)
TempFrags[i] = MaxScorePerMap;
TempFrags[i] = TempFrags[i] + (Games[i] * MapBonus);
Frags[ii] += TempFrags[i];
Games[ii]++;
ii = MaxScorePerMap;
}
}
}
}
bStatsTransfered = True;
Log("Stats have been transfered to the database succesfully.");
}
}
function GetTopPlayers()
{
local int i, ii, k;
local bool bAlreadyInList;
for (i=0; i < ArrayCount(TopPname); i++) {
for (ii=0; ii < ArrayCount(Pname); ii++) {
bAlreadyInList = False;
for (k=0; k < i; k++) {
if (PName[ii] == TopPname[k]) {
bAlreadyInList = True;
break;
}
}
if (Frags[ii] > TopFrags[i] && !bAlreadyInList) {
TopPname[i] = Pname[ii];
TopFrags[i] = Frags[ii];
TopGames[i] = Games[ii];
}
}
}
}
function bool HandleEndGame()
{
super.HandleEndGame();
StatsActivated();
GetTopPlayers();
bMatchEnded = True;
SaveConfig();
Log("Initiating transferring of stats to the database.");
}
defaultproperties
{
MaxScorePerMap=10000
MapBonus=250
}
Gopostal told me i should ask here because you have a good system who be able to suport check without causing lag
and he have said i sould revrite the stats for what i want to do.
Here you can see the bug :
http://www.unrealadmin.org/forums/showpost.php?p=162892&postcount=13