Raised This Month: $ Target: $400
 0% 

[L4D & L4D2] Custom Player Stats v1.4B121


Post New Thread Reply   
 
Thread Tools Display Modes
muukis
Veteran Member
Join Date: Apr 2009
Old 08-29-2012 , 02:03   Re: [L4D & L4D2] Custom Player Stats v1.4B117
Reply With Quote #1531

Quote:
Originally Posted by chatyak View Post
Thank you for your efforts - works well

Is there a way to change how the players are ranked? Instead of how many points (somewhat related to time on server), simply by who has most points per minute averaged? (displayed on the website for #1 - etc.... )

I do know you can view ranking by top 10 PPM in game.

Best,
Sure, but there is no configurations for changing that, so you need to alter it (the query that loads the top-10 players) manually. There are queries ready for the ppm view, so search them and change the code the way you like it best. I don't know if I have the time to do it for you, sorry!
__________________
Monster Hunter

Though certainly not superhuman, the man's prowess inspires an excess of whispered rumors. But those rumors remain in the realm of speculation.

Last edited by muukis; 08-29-2012 at 02:04.
muukis is offline
chatyak
Senior Member
Join Date: Aug 2011
Old 08-30-2012 , 01:50   Re: [L4D & L4D2] Custom Player Stats v1.4B117
Reply With Quote #1532

Quote:
Originally Posted by muukis View Post
Sure, but there is no configurations for changing that, so you need to alter it (the query that loads the top-10 players) manually. There are queries ready for the ppm view, so search them and change the code the way you like it best. I don't know if I have the time to do it for you, sorry!
That's alright. I'll see what I can do - also I'm not sure if its related, but I keep crashing... checked the logs... saw these errors - could it cause a server crash?

L 08/30/2012 - 00:47:25: Info (map "c1m3_mall") (file "errors_20120830.log")
L 08/30/2012 - 00:47:25: [admin-sql-prefetch.smx] Could not connect to database "default": Configuration "default" not found
L 08/30/2012 - 00:47:25: [admin-sql-prefetch.smx] Could not connect to database "default": Configuration "default" not found
L 08/30/2012 - 00:47:25: [admin-sql-prefetch.smx] Could not connect to database "default": Configuration "default" not found



This is my databases.cfg file:

"Databases"
{
"driver_default" "mysql"

"l4dstats"
{
"driver" "mysql"
"host" "***************"
"database" "***************"
"user" "************"
"pass" "**************"
//"timeout" "0"
"port" "3306"
}

"storage-local"
{
"driver" "sqlite"
"database" "sourcemod-local"
}

"clientprefs"
{
"driver" "sqlite"
"host" "localhost"
"database" "clientprefs-sqlite"
"user" "root"
"pass" ""
//"timeout" "0"
//"port" "0"
}
}

I don't know what to do for fixing that - have been searching and reading...

Last edited by chatyak; 08-30-2012 at 02:27.
chatyak is offline
chatyak
Senior Member
Join Date: Aug 2011
Old 08-30-2012 , 16:36   Re: [L4D & L4D2] Custom Player Stats v1.4B117
Reply With Quote #1533

Ah - when I created the databses setup for the stats tracker - I deleted the "default" listing. I will add that back in there and it should take care of the error.... I would think...?
chatyak is offline
chatyak
Senior Member
Join Date: Aug 2011
Old 08-30-2012 , 16:50   Re: [L4D & L4D2] Custom Player Stats v1.4B117
Reply With Quote #1534

Quote:
Originally Posted by muukis View Post
Sure, but there is no configurations for changing that, so you need to alter it (the query that loads the top-10 players) manually. There are queries ready for the ppm view, so search them and change the code the way you like it best. I don't know if I have the time to do it for you, sorry!

Also, where do I look for these queries? I understand I need to replace the code that changes the way people are ranked, but I'm not sure where to look.
chatyak is offline
muukis
Veteran Member
Join Date: Apr 2009
Old 09-03-2012 , 06:38   Re: [L4D & L4D2] Custom Player Stats v1.4B117
Reply With Quote #1535

Quote:
Originally Posted by chatyak View Post
Also, where do I look for these queries? I understand I need to replace the code that changes the way people are ranked, but I'm not sure where to look.
I think it's in the common.php?

Look for this line:
PHP Code:
$result mysql_query("SELECT * FROM " $mysql_tableprefix "players ORDER BY " $TOTALPOINTS " DESC LIMIT 10"); 
__________________
Monster Hunter

Though certainly not superhuman, the man's prowess inspires an excess of whispered rumors. But those rumors remain in the realm of speculation.
muukis is offline
PatriotGames
AlliedModders Donor
Join Date: Feb 2012
Location: root@irs:/# rm -rf /
Old 09-09-2012 , 00:23   Re: [L4D & L4D2] Custom Player Stats v1.4B117
Reply With Quote #1536

Quote:
Originally Posted by noctua View Post
Rly nice plugin!
But muukis, how i remove the player-multiplier?

Like: survival
1 player online = 50 points for killing a tank
5 players online = 250 points for killing a tank

thats not fair
how do i remove the multiplier?

thx
That calculation, I believe, comes from this code starting on line 3540:
PHP Code:
// Tank death code. Points are given to all players.

public Action:event_TankKilled(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (
StatsDisabled() || CampaignOver)
        return;

    if (
TankCount >= 3)
        return;
    new 
Score ModifyScoreDifficulty(GetConVarInt(cvar_Tank), 24TEAM_SURVIVORS);
    new 
Mode GetConVarInt(cvar_AnnounceMode);
    new 
Deaths 0;
    new 
Modifier 0;

    new 
maxplayers GetMaxClients();
    for (new 
1<= maxplayersi++)
    {
        if (
IsClientConnected(i) && IsClientInGame(i) && !IsClientBot(i))
        {
            if (
IsPlayerAlive(i))
                
Modifier++;
            else
                
Deaths++;
        }
    }

    
Score Score Modifier
The last line, Score = Score * Modifier, multiplies the score by the Modifier, where Modifier is the count of living survivors. Therefore, points per player get multiplied by the total number of living players.

example with one player on normal difficulty:
Base points = 50
Normal difficulty multiplier = 1
Modifier = 1 (one living player )

Score = (base points * difficulty multiplier)
Score = Score * Modifier
- or -
Score = (50 * 1)
Score = 50 * 1 ----> player earns 50 points for the tank kill

example with 5 players on Normal difficulty:
Base points = 50
Normal difficulty multiplier = 1
Modifier = 5 (five living players)

Score = (base points * difficulty multiplier)
Score = Score * Modifier
- or -
Score = (50 * 1)
Score = 50 * 5 ----> each player earns 250 points for the tank kill!

I have opted to divide Score by Modifier (where Modifier is total number of living players), thus reducing the score/player for each additional living survivor.
PHP Code:
Score Score Modifier
Score for one player reamains unchanged. But with 5 players on Normal difficulty:
Base points = 50
Normal difficulty multiplier = 1
Modifier = 5 (five living players)

Score = (base points * difficulty multiplier)
Score = Score / Modifier
- or -
Score = (50 * 1)
Score = 50 / 5 ----> each player earns 10 points for the tank kill

This may be overly simplistic, but it will work better on my 8-player co-op server where we often play on Expert.

Best regards,

Patriot
PatriotGames is offline
el_psycho
Member
Join Date: Feb 2012
Location: Vancouver, Canada
Old 09-10-2012 , 18:35   Re: [L4D & L4D2] Custom Player Stats v1.4B117
Reply With Quote #1537

TL;DR go to EDIT 2

Hi muukis, I've been looking into the encoding problem with some special characters causing the names to be blank. I'm fairly certain its an encoding problem. UTF-8 unicode works just fine, but the same special character encoded in ANSI will cause the issue. I know UTF-8 is backwards compatible with ASCII encoding but i don't know if it is with ANSI. As far as I've been able to find, ASCII and ANSI (or Windows-1252) differ in some aspects.

Anyways. the PHP code asumes the content of the blob is UTF-8 and so, cant handle ANSI correctly causing the problems. I wanted to find a way to detect what encoding a string in a blob was using.
Although i dont have a final solution, i found some promesing information here:
http://php.net/manual/en/function.mb...t-encoding.php
Which will detect the encoding used for a string. Once knowing if its ANSI we can take apropiate action like converting the value to UTF-8 enconding for display on the page?

Take a look and let me know if this is a step in the right direction.
I know what the problem is but I'm not sure how to fix it.

EDIT:
I'm now 100% sure the problem is caused by ANSI encoded characters. I can reproduce the problem at will.

I'm having trouble implementing a fix in the php. My php knowledge is very limited. This is what im tryring to do:

- Use mb_detect_encoding function to detect if the encoding is Windows-1252 (ANSI).
PHP Code:
if (mb_detect_encoding($NAMEstring'windows-1252'true) !== FALSE
- Then, If it is ANSI, convert the string from windows-1252 to UTF8 using iconv.
PHP Code:
$NAMEstring iconv('windows-1252''utf-8//TRANSLIT'$NAMEstring); 
It's hard for me to figure out where to do this.
You can read more about these functions here:
mb_detect_encoding
iconv

EDIT 2:
Good news!!! I got my fix for the empty names working! I didn't need iconv after all.

Fix example for playerlist.php starting at line 160:
PHP Code:
 while ($row mysql_fetch_array($result))
                    {
                            
$line createtablerowtooltip($row$i);
                if (
mb_detect_encoding($row['name'], 'UTF-8'true) === FALSE)
                        
$line .= "<td align=\"center\">" number_format($i) . "</td><td>" . ($showplayerflags $ip2c->get_country_flag($row['ip']) : "") . "<a href=\"player.php?steamid=" $row['steamid']. "\">" htmlentities($row['name'], ENT_COMPAT"cp1252") . "</a></td>";
                else
                        
$line .= "<td align=\"center\">" number_format($i) . "</td><td>" . ($showplayerflags $ip2c->get_country_flag($row['ip']) : "") . "<a href=\"player.php?steamid=" $row['steamid']. "\">" htmlentities($row['name'], ENT_COMPAT"UTF-8") . "</a></td>";
                
$line .= "<td>" number_format($row['real_points']) . "</td>";
                
$line .= "<td>" formatage($row['real_playtime'] * 60) . "</td>";
                
$line .= "<td>" formatage(time() - $row['lastontime']) . " ago</td></tr>\n";
                
//$line .= "<td>" . $query . "</td></tr>\n";
                
$arr_players[] = $line;
                
$i++;
                    } 
EDIT 3:

OK, this works well but its not perfect. I've noticed an issue with a couple of names using cyrillic characters not being detected as UTF-8. They do show up in the lists but the names have the wrong characters (becuase i assumed if they're not UTF8 then they're Windows-1252). Its probably a matter of properly detecting what charset those names are using (which isn't easy in PHP apparently) and then applying a proper fix that takes that into account.

The following function looks like it could be the answer to our problem, we just need to add more charsets to the array. But i cant get it to work for some reason: UPDATE: scratch that. same problem as with mb_detect_encoding. it cant tell the difference between windows-1252 and other ISO-8859-* charsets.
PHP Code:
<?php
function detect_encoding($string) {  
  static 
$list = array('utf-8''windows-1251');
  
  foreach (
$list as $item) {
    
$sample iconv($item$item$string);
    if (
md5($sample) == md5($string))
      return 
$item;
  }
  return 
null;
}
?>

Last edited by el_psycho; 09-17-2012 at 07:40.
el_psycho is offline
Kahl_Drogo
Senior Member
Join Date: Apr 2012
Old 09-14-2012 , 07:47   Re: [L4D & L4D2] Custom Player Stats v1.4B117
Reply With Quote #1538

Chow change port in web config ? I see only:
mysql_server = "";
$mysql_db = "";
$mysql_user = "";
$mysql_password = "";
$mysql_tableprefix = "";

But nothing about mysql port My SQL work on 3307)
Kahl_Drogo is offline
muukis
Veteran Member
Join Date: Apr 2009
Old 09-17-2012 , 02:58   Re: [L4D & L4D2] Custom Player Stats v1.4B117
Reply With Quote #1539

Quote:
Originally Posted by PatriotGames View Post
...
Quote:
Originally Posted by el_psycho View Post
...
Thanks! Both of you
I'll add these to the next update.

Quote:
Originally Posted by Kahl_Drogo View Post
Chow change port in web config ? I see only:
mysql_server = "";
$mysql_db = "";
$mysql_user = "";
$mysql_password = "";
$mysql_tableprefix = "";

But nothing about mysql port My SQL work on 3307)
This works:
PHP Code:
// MySQL information for L4D Stats DB
$mysql_server "127.0.0.1:3307"
__________________
Monster Hunter

Though certainly not superhuman, the man's prowess inspires an excess of whispered rumors. But those rumors remain in the realm of speculation.
muukis is offline
el_psycho
Member
Join Date: Feb 2012
Location: Vancouver, Canada
Old 09-17-2012 , 07:53   Re: [L4D & L4D2] Custom Player Stats v1.4B117
Reply With Quote #1540

Quote:
Originally Posted by PatriotGames View Post
I have opted to divide Score by Modifier (where Modifier is total number of living players), thus reducing the score/player for each additional living survivor.
PHP Code:
Score Score Modifier
Score for one player reamains unchanged. But with 5 players on Normal difficulty:
Base points = 50
Normal difficulty multiplier = 1
Modifier = 5 (five living players)

Score = (base points * difficulty multiplier)
Score = Score / Modifier
- or -
Score = (50 * 1)
Score = 50 / 5 ----> each player earns 10 points for the tank kill

This may be overly simplistic, but it will work better on my 8-player co-op server where we often play on Expert.

Best regards,

Patriot
muukis, please dont make that the default, I think the way it is now is better. all that needs to be done is change the base score. This new proposed way rewards players for dying and penalizes them for staying alive. The whole point of the original code was to reward the survivors for killing the tank with few or no deaths.

Last edited by el_psycho; 09-17-2012 at 07:55.
el_psycho 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 00:40.


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