Need help for stats for Monsterhuntv2Gold

Started by Letylove49, Aug 23, 2011, 11:35 AM

Previous topic - Next topic

Letylove49

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
i edit mod i'm too noob to create my mod myself because i begin on script.

Helen

#1
I don't quite fully understand the code, but, try this. I took out all the commented stuff, only so you could see my own comments easier. I also formatted the code so I could read it first  :P



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

function PostBeginPlay()
{
     local int i;

     if (bInit)
     {
           return;
     }

     bInit = True;

     Log("Stats mutator activated");

     // Helen: This is 1/1000th of a second. This is insanely fast, considering all
     // the processing you are doing. Try slowing it down, try 0.1, or 0.25, or even 0.5
     SetTimer(0.001, true);

     for (i=0; i<64; i++)
     {
           TempPname[i] = "";
           TempFrags[i] = 0;
     }

     if (NextMutator != None)
     {
           NextMutator.PostBeginPlay();
     }
}

function Timer()
{
     local IPRI PRI;
     local Pawn P;
     local int i;

     // Helen - instead of iterating through the pawn list to get the PRI's, couldn't
     // you use Level.Game.GameReplicationInfo.PRIArray as a leaner way to get all the PRI's?
     // I'm not sure, you can experiment.
     for (P = Level.PawnList; P != None; P = P.NextPawn)
     {
           if (P.IsA('PlayerPawn'))
           {
                 PRI = IPRI(PlayerPawn(P).PlayerReplicationInfo);

                 // Helen - you had this once, I put it back in.
                 if (PRI.PlayerName != "Player")
                 {
                       for (i=0; i<64; i++)
                       {
                             if (TempPname[i] == PRI.PlayerName || TempPname[i] == "")
                             {
                                   TempPname[i] = PRI.PlayerName;

                                   // Helen - put this check here
                                   if(IsAcceptedName(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];
                                               }
                                         }
                                   }
                                   // Helen - added this else
                                   else
                                   {
                                         TempFrags[i] = 0;
                                         if (Pname[Cycle] == PRI.PlayerName)
                                         {
                                               PRI.Games = 0;
                                               PRI.TotalFrags = 0;
                                         }
                                   }

                                   if (P.Tag != 'tagged')
                                   {
                                         AssignTopInfo(PlayerPawn(P));
                                   }
                                   i = 65;
                             }
                       }
                 }
           }
     }
     Cycle++;

     if (Cycle > 5000 || Pname[Cycle] == "")
     {
           Cycle = 0;
     }
}

// Helen - I slightly edited this function
function bool IsAcceptedName(string PName)
{
     local int i;

     if (PName == "Player")
     {
           return False;
     }

     for (i=0; i < ArrayCount(Ignorlist); i++)
     {
           if (Caps(PName) == Caps(Ignorlist[i]))
           {
                 return False;
           }
     }

     return True;
}

function StatsActivated()
{
     local IPRI PRI;
     local Pawn P;
     local int i,ii;

     if (!bStatsTransfered)
     {
           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;

                 // Helen - added this check. This may not be necessary, not sure.
                 // It might be necessary say if the player had a good score before
                 // they got added to the ignore list.
                 if(IsAcceptedName(Pname)
                 {
                       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
}
One of the Scriveners.

Letylove49

I cannot compile it

i don't see where is the error

Error: L:\UnrealTournament\MonsterHunt2beta3MHA2\Classes\Stats.uc(155) : Error, Unexpected '{'
Critical: appError called:
Critical: Failed due to errors.
Exit: Executing UObject::StaticShutdownAfterError
Critical: CompileError
Critical: TryCompile
Critical: FScriptCompiler::CompileScript
Critical: (Class MonsterHunt2beta3MHA2.Stats, Pass 0, Line 155)
Critical: MakeScript
Critical: MakeScript
Critical: MakeScript
Critical: MakeScript
Critical: MakeScript
Critical: DoScripts
Critical: UEditorEngine::MakeScripts
Critical: UMakeCommandlet::Main
Exit: Exiting.
Uninitialized: Name subsystem shut down
Uninitialized: Log file closed, 08/24/11 20:56:20
i edit mod i'm too noob to create my mod myself because i begin on script.

Helen

When you get errors, comment stuff out until it compiles to narrow down where the problem is.

Anyways I was missing a bracket, this

// Helen - put this check here
if(IsAcceptedName(PRI.PlayerName)


should be this:

// Helen - put this check here
if(IsAcceptedName(PRI.PlayerName))


If it still doesn't compile, try my suggestion and see if you can figure it out.
One of the Scriveners.

Letylove49

#4
Log: Parsing Stats
Error: L:\UnrealTournament\MonsterHunt2beta3MHA2\Classes\Stats.uc(229) : Error, Unexpected end of file at end of Class
Critical: appError called:
Critical: Failed due to errors.
Exit: Executing UObject::StaticShutdownAfterError
Critical: CompileError
Critical: TryCompile
Critical: FScriptCompiler::CompileScript
Critical: (Class MonsterHunt2beta3MHA2.Stats, Pass 0, Line 229)
Uninitialized: Name subsystem shut down



Probabely a error somewere but i don't see it.
i edit mod i'm too noob to create my mod myself because i begin on script.

Helen

Do what I suggested, comment stuff out until it compiles to find the problem.

Or just take the spots I have changed, and put them into YOUR script.
One of the Scriveners.

Letylove49

i have alreday put this
Quote// Helen - put this check hereif(IsAcceptedName(PRI.PlayerName))

i will look again all the code to see if i  fund what is wrong.

i edit mod i'm too noob to create my mod myself because i begin on script.

Letylove49


Now i got this :
Error: L:\UnrealTournament\MonsterHunt2beta3MHA2\Classes\Stats.uc(205) : Error, Call to 'IsAcceptedName': type mismatch in parameter 1

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';
}
function PostBeginPlay()
{      local int i;

     if (bInit)      
     {            return;      
     }      bInit = True;      Log
     ("Stats mutator activated");
     
     // Helen: This is 1/1000th of a second. This is insanely fast, considering all      
     // the processing you are doing. Try slowing it down, try 0.1, or 0.25, or even 0.5      
     SetTimer(0.001, true);
     
     for (i=0; i<64; i++)      
     {            TempPname[i] = "";
                 TempFrags[i] = 0;      }
                 
     if (NextMutator != None)      
     
     {            
     NextMutator.PostBeginPlay();
     
     }
     
     }
     
function Timer()

{      local IPRI PRI;
     local Pawn P;
           local int i;      
           // Helen - instead of iterating through the pawn list to get the PRI's, couldn't      
           // you use Level.Game.GameReplicationInfo.PRIArray as a leaner way to get all the PRI's?      
           // I'm not sure, you can experiment.      
           
           for (P = Level.PawnList; P != None; P = P.NextPawn)      
           
           {            if (P.IsA('PlayerPawn'))            
           {                  PRI = IPRI(PlayerPawn(P).PlayerReplicationInfo);
                             // Helen - you had this once, I put it back in.      
                             
           if (PRI.PlayerName != "Player")                  
           {                        for (i=0; i<64; i++)                        
           {                              if (TempPname[i] == PRI.PlayerName || TempPname[i] == "")
                                         {                                    TempPname[i] = PRI.PlayerName;
                                         
                                   // Helen - put this check here                                    
                                   if(IsAcceptedName(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];
                                                                                                                 
                                   }                                          }                                    }                                    
                                   
                                   // Helen - added this else                                    
                                   else                                    {                                          
                                   TempFrags[i] = 0;                                          
                                   if (Pname[Cycle] == PRI.PlayerName)                                          
                                   {                                                PRI.Games = 0;                                                
                                                                                   PRI.TotalFrags = 0;                                          }
                                                                                   
                                                                                                                       }
                                                                                   if (P.Tag != 'tagged')                                    
                                                                                   
                                                                                   {                                    
                                                                                   AssignTopInfo(PlayerPawn(P));      
                                                                                   
                                                                             }                                    
                                                                             i = 65;      
                                                                                                                 
                                                                                                                 
                                                     }      
                                                                       
                                                           }
                                                                       }
                                                                                   }
     }                                                                                                                                                            
     Cycle++;      
     if (Cycle > 5000 || Pname[Cycle] == "")      
     {            
     Cycle = 0;
           }
           }
           
           // Helen - I slightly edited this function
           function bool IsAcceptedName(string PName)
           
           {      
           local int i;
           
           if (PName == "Player")
                       {            
                       return False;
                             }
                                   for (i=0;
                                    i < ArrayCount(Ignorlist); i++)      
                                    {            
                                    if (Caps(PName) == Caps(Ignorlist[i]))
                                                {                  return False;
                                                            }      
                                                            }      
                                                            return True;
                                                            }
                                                            
function StatsActivated()
{
           local IPRI PRI;      
           local Pawn P;
           local int i,ii;
           if (!bStatsTransfered)
                                                            {            
                                                            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;                  
                                         
                                         // Helen - added this check. This may not be necessary, not sure.                  
                                         // It might be necessary say if the player had a good score before                  
                                         // they got added to the ignore list.                  
                                         if(IsAcceptedName(PName)                  
                                         {                        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
}

i edit mod i'm too noob to create my mod myself because i begin on script.

Helen

Find my comment that looks like this:


// Helen - added this check. This may not be necessary, not sure.                  
// It might be necessary say if the player had a good score before                  
// they got added to the ignore list.                  


and then change the line below it to this:


if(IsAcceptedName(PName[ii])            

One of the Scriveners.