AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   HLstatsX:CE (https://forums.alliedmods.net/forumdisplay.php?f=156)
-   -   Fix SteamIDs for the new update (https://forums.alliedmods.net/showthread.php?t=246712)

Weasel 08-22-2014 21:09

Re: Fix SteamIDs for the new update
 
Quote:

Originally Posted by Horsedick (Post 2187492)
I'd try this but I'm sure they will release an update tomorrow or sometime this weekend.

I am with you on that. I think I'll wait for few days to see if there is an update that includes some sort of fix before hacking-up existing code myself.

Phaiz 08-23-2014 09:09

Re: Fix SteamIDs for the new update
 
Is this supposed to change old steam IDs to the new ID?

C00ller 08-23-2014 10:31

Re: Fix SteamIDs for the new update
 
Another solution: update old SteamIDs to new format right in the database.

I wrote PHP-script to update old SteamIDs to new ones (in order to use that change $DB* vars accordingly) for TF2-related stats:

Code:

<?php

// RUN ONLY ONCE!!! Or restore from backup before any extra run!

$DBServ = "localhost";
$DBUser = "root";
$DBPass = "";
$DBName = "hlstats";
$DBTable = "hlstats_PlayerUniqueIds";

$db = mysql_connect($DBServ, $DBUser, $DBPass) or die("Can't connect to MySQL server");
mysql_select_db($DBName) or die("Can't select DB");

$now = time();

mysql_query("CREATE TABLE " . $DBTable . "_copy_" . $now . " LIKE $DBTable");
mysql_query("INSERT " . $DBTable . "_copy_" . $now . " SELECT * FROM $DBTable");

mysql_query("DELETE FROM $DBTable WHERE game = 'tf' AND INSTR(uniqueId, 'U') > 0");
mysql_query("UPDATE $DBTable SET uniqueId=CONCAT('[U:1:', SUBSTR(uniqueId, 1, 1)+SUBSTR(uniqueId, 3)*2, ']') WHERE game = 'tf'");

// Redundant code :)
/*
$players = mysql_query("SELECT * FROM $DBTable");
while($row = mysql_fetch_assoc($players))
{
    $id = $row["playerId"];
    $oldsteamid = $row["uniqueId"];

    $idparts = explode(':', $oldsteamid);
    $newsteamid = "[U:1:" . ($idparts[1] * 2 + $idparts[0]) . "]";
    mysql_query("UPDATE $DBTable SET game='$oldsteamid', uniqueId = '$newsteamid' WHERE playerId = $id");
}

mysql_free_result($players);
*/

mysql_close($db);

echo "Done";

Script does the backup copy of used table and deletes player records with new IDs (to prevent uniqueId duplicating after update).

Phaiz 08-23-2014 10:55

Re: Fix SteamIDs for the new update
 
I added the changes in the original post after I updated sourcemod. The hlstats daemon will not continue running now.

Code:

**:/**/scripts$ ./run_hlstats start

HLstatsX:CE daemon control
http://www.hlxce.com
---------------------------
Attempting to start HLstatsX:CE daemon on port 27500...
Daemon successfully started on port 27500
**:/**/scripts$ ./run_hlstats start

HLstatsX:CE daemon control
http://www.hlxce.com
---------------------------
Attempting to start HLstatsX:CE daemon on port 27500...
Daemon successfully started on port 27500

Those were back to back commands, it should have said it was already running on port 27500.

If I check the status,
Code:

**:/**/scripts$ ./run_hlstats status

HLstatsX:CE daemon control
http://www.hlxce.com
---------------------------
A stale process was found for daemon on port 27500.  It has been removed.


Weasel 08-23-2014 14:50

Re: Fix SteamIDs for the new update
 
Quote:

Originally Posted by C00ller (Post 2188245)
Another solution: update old SteamIDs to new format right in the database.

I wrote PHP-script to update old SteamIDs to new ones (in order to use that change $DB* vars accordingly):

Spoiler

Script does the backup copy of used table and deletes player records with new IDs (to prevent uniqueId duplicating after update).

Eh... wait. We only want to update SteamID's in the hlstats_PlayerUniqueIds that are relevant to Team Fortress 2 - right? So, just those that match the value "tf" in the "game" field? - right? I have a bunch of other game-servers using the same HLStatsX:CE database - including both Source-engine games and mods as well as older GoldSrc-engine games and mods. I thought only TF2 was using the new Steam3 ID format so far?

C00ller 08-23-2014 15:37

Re: Fix SteamIDs for the new update
 
Quote:

Originally Posted by Weasel (Post 2188386)
We only want to update SteamID's in the hlstats_PlayerUniqueIds that are relevant to Team Fortress 2 - right? So, just those that match the value "tf" in the "game" field? - right?


You're definitely right! I've made corrections to my original post, thanks for notice.


Quote:

Originally Posted by Weasel (Post 2188386)
I thought only TF2 was using the new Steam3 ID format so far?

I'm not sure. Thought the new format is Steam-related, not game.

bottiger 08-23-2014 16:56

Re: Fix SteamIDs for the new update
 
You can update hlstats to use the new format internally by running this SQL command

Code:

UPDATE hlstats_PlayerUniqueIds SET uniqueId=SUBSTR(uniqueId, 1, 1)+SUBSTR(uniqueId, 3)*2 WHERE uniqueId REGEXP('[01]:[0-9]+')
And replacing the $uniqueid in hlstats.pl sub getPlayerInfo with this.

Code:

                $uniqueid =~ /^\[U:1:(\d+)\]/;
                $uniqueid = $1;

There are few other cosmetic changes such as searching and player display which shouldn't be too difficult to figure out and I am sure the hlstats team will do.

Weasel 08-24-2014 23:36

Re: Fix SteamIDs for the new update
 
Quote:

Originally Posted by C00ller (Post 2188403)
Regarding the script/query: You're definitely right! I've made corrections to my original post, thanks for notice.

Thanks! I ran that PHP script (with proper authentication parameters inserted in the required variables, etc.) and it updated all my TF2 users just fine - without interfering with players logged for other games in the same HLStats database. HLStats itself still has some cosmetic/display issues to deal with - hopefully to be fixed in a coming update, but otherwise seems to be running fine.

The cosmetic stuff is includes things such as the display of steam IDs incorrectly on-screen (with "Steam:0" prefixed - regardless of whether it is a Steam2 or Steam3 format ID in the database for that particular game), and linking to Steam profiles where the Steam ID in the database is updated to the Steam3 format.

Personally, I can live with the cosmetic stuff - until there is an "official" update to deal with that stuff - rather than hack it up myself.

Quote:

Originally Posted by C00ller (Post 2188403)
Regarding other games: I'm not sure. Thought the new format is Steam-related, not game.

I definitely do not see the Steam3 ID's showing-up in any other games that I happen to currently host (Fistful of Frags, CS:S, etc.). I seem to recall somebody saying there are some other games already using the new format prior to TF2? (maybe CS:GO? or DOTA?).

So, I would assume that eventually all Valve titles that are using some Source-engine variant will be converting to this new format, and eventually mods based on Source-engine will get forced over to it as well.

It wouldn't surprise me if Valve did the same thing for all Valve titles using the old GoldSrc-engine too - in which case AMX-Mod-X will likely need to be similarly patched to accommodate the change. At the moment, from what I see my GoldSrc-engine games (HL1, TFC, Counter-Strike, DMC, and some mods) are still using the old format.

Phaiz 08-25-2014 09:35

Re: Fix SteamIDs for the new update
 
I'm assuming that these "cosmetic" issues would include a players stats page not showing their avatar?

Weasel 08-25-2014 12:09

Re: Fix SteamIDs for the new update
 
Quote:

Originally Posted by Phaiz (Post 2189233)
I'm assuming that these "cosmetic" issues would include a players stats page not showing their avatar?

Yes, it sure does.


All times are GMT -4. The time now is 01:54.

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