Raised This Month: $235 Target: $400
 58% 

Fix SteamIDs for the new update


Post New Thread Reply   
 
Thread Tools Display Modes
Weasel
AlliedModders Donor
Join Date: Apr 2004
Location: Undisclosed / Secure
Old 08-22-2014 , 21:09   Re: Fix SteamIDs for the new update
Reply With Quote #11

Quote:
Originally Posted by Horsedick View Post
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.
__________________
Pwease pardon by bad Engrish.
Steam Profile, Steam Group, YouTube Channel, Stats, Twitter
Weasel is offline
Phaiz
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 08-23-2014 , 09:09   Re: Fix SteamIDs for the new update
Reply With Quote #12

Is this supposed to change old steam IDs to the new ID?
Phaiz is offline
C00ller
Junior Member
Join Date: Sep 2007
Old 08-23-2014 , 10:31   Re: Fix SteamIDs for the new update
Reply With Quote #13

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).

Last edited by C00ller; 08-23-2014 at 18:00. Reason: game dependance added, redudant cycle replaced
C00ller is offline
Phaiz
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 08-23-2014 , 10:55   Re: Fix SteamIDs for the new update
Reply With Quote #14

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.
Phaiz is offline
Weasel
AlliedModders Donor
Join Date: Apr 2004
Location: Undisclosed / Secure
Old 08-23-2014 , 14:50   Re: Fix SteamIDs for the new update
Reply With Quote #15

Quote:
Originally Posted by C00ller View Post
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?
__________________
Pwease pardon by bad Engrish.
Steam Profile, Steam Group, YouTube Channel, Stats, Twitter
Weasel is offline
C00ller
Junior Member
Join Date: Sep 2007
Old 08-23-2014 , 15:37   Re: Fix SteamIDs for the new update
Reply With Quote #16

Quote:
Originally Posted by Weasel View Post
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 View Post
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.
C00ller is offline
bottiger
AlliedModders Donor
Join Date: Dec 2010
Old 08-23-2014 , 16:56   Re: Fix SteamIDs for the new update
Reply With Quote #17

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.
__________________

Last edited by bottiger; 08-23-2014 at 16:58.
bottiger is offline
Weasel
AlliedModders Donor
Join Date: Apr 2004
Location: Undisclosed / Secure
Old 08-24-2014 , 23:36   Re: Fix SteamIDs for the new update
Reply With Quote #18

Quote:
Originally Posted by C00ller View Post
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 View Post
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.
__________________
Pwease pardon by bad Engrish.
Steam Profile, Steam Group, YouTube Channel, Stats, Twitter
Weasel is offline
Phaiz
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 08-25-2014 , 09:35   Re: Fix SteamIDs for the new update
Reply With Quote #19

I'm assuming that these "cosmetic" issues would include a players stats page not showing their avatar?
Phaiz is offline
Weasel
AlliedModders Donor
Join Date: Apr 2004
Location: Undisclosed / Secure
Old 08-25-2014 , 12:09   Re: Fix SteamIDs for the new update
Reply With Quote #20

Quote:
Originally Posted by Phaiz View Post
I'm assuming that these "cosmetic" issues would include a players stats page not showing their avatar?
Yes, it sure does.
__________________
Pwease pardon by bad Engrish.
Steam Profile, Steam Group, YouTube Channel, Stats, Twitter
Weasel is offline
Reply


Thread Tools
Display Modes

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:52.


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