Client.h in struct local_player_info:
PHP:
--------------------------------------------------------------------------------
int frags; // int representing one number
int headshots; // int representing one number
float hspercent; // Float representing a decimal
--------------------------------------------------------------------------------
in class PlayerInfo:
PHP:
--------------------------------------------------------------------------------
// infos needed for points system:
int frags;
int deaths;
float ratio;
bool bestplayer; // based on ratio, not frags!
float fovangle; // minimum fov a player is in
--------------------------------------------------------------------------------
Client.cpp
PHP:
--------------------------------------------------------------------------------
//Headshot counter
int hscounter=0;
static bool bGotHeadshot=false;
below //======================== USER MESSAGE HOOKS ===============================================:
// ==================================================
======================================
USER_MSG_INTERCEPT(DeathMsg)
{
updateLocalPlayer();
BEGIN_READ( pbuf, iSize );
int x = displayCenterX*2 + 1;
int y = displayCenterY*2 + 100;
int killer = READ_BYTE();
int victim = READ_BYTE();
int headshot = READ_BYTE();
vPlayers[victim].health = 0;
vPlayers[victim].hitpoints = 0;
if(victim==me.ent->index)
{
cvar.spec_fix = false;
}
if(cvar.alive_method==1)
{
vPlayers[victim].setAlive(false);
if(victim==me.ent->index){ me.alive = false; }
}
if( victim!=me.ent->index && killer==me.ent->index && headshot)
{
bGotHeadshot=true; // Making sure you got a headshot
}
return USER_MSG_CALL(DeathMsg);
}
// ==================================================
======================================
// ==================================================
======================================
USER_MSG_INTERCEPT(ScoreInfo)
{
updateLocalPlayer();
BEGIN_READ(pbuf, iSize);
int idx = READ_BYTE();
PlayerInfo& r = vPlayers[idx];
r.frags = READ_SHORT();
r.deaths = READ_SHORT();
if(r.frags<=0 ) { r.ratio=0; }
else { r.ratio = (double)r.frags / ((r.deaths<=0)?1:r.deaths); }
r.bestplayer = false;
bool foundbetter = false;
for(int i=0;i<vPlayers.size();i++)
{
if ( r.ratio < vPlayers.ratio ) foundbetter = true;
else if( r.ratio > vPlayers.ratio ) vPlayers.bestplayer=false;
}
if(!foundbetter) r.bestplayer = true;
if(idx==me.ent->index)
{
static int lastfrags=0;
static int lastdeaths=0;
if(me.headshots>r.frags || r.frags==0)
{
me.headshots = 0;
me.hspercent = 0;
bGotHeadshot = false;
lastfrags = r.frags;
lastdeaths = r.deaths;
}
else
{
if(bGotHeadshot) { ++me.headshots; }
double den = r.frags ? (double)r.frags : 1.0;
me.hspercent = (double)me.headshots/den*100.0;
if(cvar.saystats && (lastfrags!=r.frags || lastdeaths!=r.deaths ))
{
switch(cvar.saystats)
{
case 1:
sprintf(tmp,"say Saystats Tutorial: Kills: %d | Deaths: %d | HeadShots[%d = %4.1f]",
r.frags,r.deaths,me.headshots,me.hspercent);
gEngfuncs.pfnClientCmd(tmp);
break;
}
}
}
bGotHeadshot = false;
lastfrags = r.frags;
lastdeaths = r.deaths;
}
return USER_MSG_CALL(ScoreInfo);
}
// ==================================================
======================================
REDIRECT_MESSAGE( DeathMsg )
REDIRECT_MESSAGE( ScoreInfo )