/*
    STATS PLUGIN FIXED BY VC' BLADE
*/
#include maps\mp\_utility;
#include maps\mp\gametypes\_hud_util;
#include common_scripts\utility;
init( modVersion )
{
    thread onPlayerSpawned();      
}
 
onPlayerSpawned()
{
    level endon ( "endmap" );
    for(;;)
    {
	level waittill( "connected", player );	
        player thread StatsText();
        player thread Score();
        player thread Kills();
        player thread Deaths();
        player thread Knifes();
           player thread Time();
           player thread UpdateStats();
}
} 
  
StatsText()
{
        if(isdefined(self.hud_Stats))
                self.hud_Stats destroy();
 
        wait 12;  
        self.hud_Stats = newClientHudElem(self);
        self.hud_Stats.alignX = "right";
        self.hud_Stats.alignY = "top";
        self.hud_Stats.horzAlign = "right";
        self.hud_Stats.vertAlign = "top";
        self.hud_Stats.x = -6;
        self.hud_Stats.y = 70;
        self.hud_Stats.sort = 10;
        self.hud_Stats.fontScale = 1.5;
        self.hud_Stats.font = "objective";
        self.hud_Stats.glowAlpha = 1;
        self.hud_Stats.Alpha = 1;
        self.hud_Stats.glowColor = level.randomcolour;
        self.hud_Stats.hidewheninmenu = true;
        self.hud_Stats setText("Eredményeid");
}
 
Score()
{
        if(isdefined(self.hud_StatsScore))
                self.hud_StatsScore destroy();
        
        wait 12;  
        self.hud_StatsScore = newClientHudElem(self);
        self.hud_StatsScore.alignX = "right";
        self.hud_StatsScore.alignY = "top";
        self.hud_StatsScore.horzAlign = "right";
        self.hud_StatsScore.vertAlign = "top";
        self.hud_StatsScore.x = -6;
        self.hud_StatsScore.y = 90;
        self.hud_StatsScore.sort = 10;
        self.hud_StatsScore.fontScale = 1.5;
        self.hud_StatsScore.font = "objective";
        self.hud_StatsScore.glowAlpha = 1;
        self.hud_StatsScore.Alpha = 1;
        self.hud_StatsScore.glowColor = level.randomcolour;
        self.hud_StatsScore.hidewheninmenu = true;
        self.hud_StatsScore.label = &"Pontod: &&1";
 
        /*if(isDefined(self.pers["Pontod"]))
                self.hud_StatsScore setValue( self.pers["score"] );*/
 
        while( 1 )
        {
                wait 0.5;
                self.hud_StatsScore setValue( self.pers["score"] );
        }
}
 
Kills()
{
        if(isdefined(self.hud_StatsKills))
                self.hud_StatsKills destroy();
        
  wait 12;  
        self.hud_StatsKills = newClientHudElem(self);
        self.hud_StatsKills.alignX = "right";
        self.hud_StatsKills.alignY = "top";
        self.hud_StatsKills.horzAlign = "right";
        self.hud_StatsKills.vertAlign = "top";
        self.hud_StatsKills.x = -6;
        self.hud_StatsKills.y = 110;
        self.hud_StatsKills.sort = 10;
        self.hud_StatsKills.fontScale = 1.5;
        self.hud_StatsKills.font = "objective";
        self.hud_StatsKills.glowAlpha = 1;
        self.hud_StatsKills.Alpha = 1;
        self.hud_StatsKills.glowColor = level.randomcolour;
        self.hud_StatsKills.hidewheninmenu = true;
        self.hud_StatsKills.label = &"Ölések: &&1";
 
        /*if(isDefined(self.pers["Ölések"]))
                self.hud_StatsKills setValue( self.pers["kills"] );*/
 
         while( 1 )
        {
                wait 0.5;
                self.hud_StatsKills setValue( self.pers["kills"] );
        }
}
 
Deaths()
{
        if(isdefined(self.hud_StatsDeaths))
                self.hud_StatsDeaths destroy();
 
        wait 12;  
        self.hud_StatsDeaths = newClientHudElem(self);
        self.hud_StatsDeaths.alignX = "right";
        self.hud_StatsDeaths.alignY = "top";
        self.hud_StatsDeaths.horzAlign = "right";
        self.hud_StatsDeaths.vertAlign = "top";
        self.hud_StatsDeaths.x = -6;
        self.hud_StatsDeaths.y = 130;
        self.hud_StatsDeaths.sort = 10;
        self.hud_StatsDeaths.fontScale = 1.5;
        self.hud_StatsDeaths.font = "objective";
        self.hud_StatsDeaths.glowAlpha = 1;
        self.hud_StatsDeaths.Alpha = 1;
        self.hud_StatsDeaths.glowColor = level.randomcolour;
        self.hud_StatsDeaths.hidewheninmenu = true;
        self.hud_StatsDeaths.label = &"Halálok: &&1";
 
        /*if(isDefined(self.pers["Deaths"]))
                self.hud_StatsDeaths setValue( self.pers["deaths"] );*/
 
         while( 1 )
        {
                wait 0.5;
                self.hud_StatsDeaths setValue( self.pers["deaths"] );
        }
}
 
Knifes()
{
        if(isdefined(self.hud_StatsMelee))
                self.hud_StatsMelee destroy();
 
        wait 12;  
        self.hud_StatsMelee = newClientHudElem(self);
        self.hud_StatsMelee.alignX = "right";
        self.hud_StatsMelee.alignY = "top";
        self.hud_StatsMelee.horzAlign = "right";
        self.hud_StatsMelee.vertAlign = "top";
        self.hud_StatsMelee.x = -6;
        self.hud_StatsMelee.y =150 ;
        self.hud_StatsMelee.sort = 10;
        self.hud_StatsMelee.fontScale = 1.5;
        self.hud_StatsMelee.font = "objective";
        self.hud_StatsMelee.glowAlpha = 1;
        self.hud_StatsMelee.Alpha = 1;
        self.hud_StatsMelee.glowColor = level.randomcolour;
        self.hud_StatsMelee.hidewheninmenu = true;
        self.hud_StatsMelee.label = &"Késelések: &&1";
 
        /*if(isDefined(self.pers["Késelések"]))
                self.hud_StatsMelee setValue( self.pers["knife"] );*/
 
         while( 1 )
        {
                wait 0.5;
                self.hud_StatsMelee setValue( self.pers["knife"] );
        }
}
 
 
Time()
{
        if(isdefined(self.hud_statstime))
                self.hud_statstime destroy();
 
        self.hud_statstime = newClientHudElem(self);
        self.hud_statstime.alignX = "right";
        self.hud_statstime.alignY = "top";
        self.hud_statstime.horzAlign = "right";
        self.hud_statstime.vertAlign = "top";
        self.hud_statstime.x = -6;
        self.hud_statstime.y = 170;
        self.hud_statstime.sort = 10;
        self.hud_statstime.fontScale = 1.5;
        self.hud_statstime.font = "objective";
        self.hud_statstime.glowAlpha = 1;
        self.hud_statstime.Alpha = 1;
        self.hud_statstime.glowColor = level.randomcolour;
        self.hud_statstime.hidewheninmenu = true;
        self.hud_statstime.label = &"Ido: &&1";
 
         while( 1 )
        {
                wait 3;
                self.hud_statstime setValue( self.pers["time"] );
        }
}
 
 
UpdateStats()
{
self endon( "disconnect" );
self endon( "joined_spectators" );
}
 
fader(value)
{
        self fadeOverTime(.2);
        self.alpha = 0;
        wait .25;
        self setValue( value );
        self fadeOverTime(.6);
        self.alpha = 1;        
}