Raised This Month: $51 Target: $400
 12% 

[L4D2]How to calcuate average player data


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
paintokill
Junior Member
Join Date: Oct 2015
Old 02-22-2021 , 05:37   [L4D2]How to calcuate average player data
Reply With Quote #1

For example I'm using mysql to store player score like 'infected killed'. I want calculate the average player data each player current in the server, any help about this?

Sorry for my bad english.
paintokill is offline
jeremyvillanueva
AlliedModders Donor
Join Date: Jan 2021
Location: dcord:Jeremy333#7632
Old 03-14-2021 , 15:03   Re: [L4D2]How to calcuate average player data
Reply With Quote #2

Hi,
I use this in vscript
// Obtenga el número real de personas con Client_Count//获取实际人数
local clientcount =0;
local survivorcount=0;
nowPlayersIntensity=0;
nowPlayersTimeAveragedIntensity=0;
foreach( survivor in ::VSLib.EasyLogic.Players.Survivors() )
{
survivorcount++
nowPlayersIntensity=nowPlayersIntensity+survi vor.GetIntensity()
nowPlayersTimeAveragedIntensity=nowPlayersTim eAveragedIntensity+survivor.GetTimeAveragedIn tensity()
if(survivor.IsBot())
continue;
KillNum.insert(clientcount++,survivor.GetInde x());
if(!PlayerKillCout.rawin(survivor.GetIndex()) )
{
PlayerKillCout[survivor.GetIndex()] <- 0;
PlayerRandCout[survivor.GetIndex()] <- RandomInt(0,9);
}
}


This would be in sourcepawn
int currentAverage = 0;
int max_index = 0;
int survivorCount=0;
for (int i = 1; i < MaxClients+1; i++)
{
if(IsClientInGame(i))
{
if (GetClientTeam(i) == TEAM_SURVIVORS && IsPlayerAlive(i))//IsFakeClient=bot//solo contamos intensidad de vivos y bots
{
PlayerIntensity[max_index] = GetEntProp(i, Prop_Send, "m_clientIntensity" );
PlayerTotalIntensity[max_index] += PlayerIntensity[max_index];
currentAverage += PlayerIntensity[max_index];
PlayerTick[max_index]++;
PrintToServer("\x04[balance] \x01player %N %d intensity: current %d",i,max_index,PlayerIntensity[max_index]);
PrintToServer("\x04[balance] \x01player %N %d intensity/tick %d,total intensity/ticks %d",i,max_index,PlayerIntensity[max_index] / PlayerTick[max_index],PlayerTotalIntensity[max_index] / PlayerTick[max_index]);
}
else
{
PlayerTick[max_index]++;
}
}
else PlayerIntensity[max_index] = 0;//0 until enter a team
max_index++;
}
jeremyvillanueva is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:50.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode