Raised This Month: $32 Target: $400
 8% 

Solved Time Played plugin based off Dr. McKay's Player Analytics


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sneaK
SourceMod Moderator
Join Date: Feb 2015
Location: USA
Old 09-11-2016 , 02:05   Time Played plugin based off Dr. McKay's Player Analytics
Reply With Quote #1

I'm aware there are already a couple "time played" plugins, but I was looking to consolidate and use my existing player analytics databases.

Basically I'm requesting a plugin that when a player types !timeplayed they get their total time played in hours and minutes. The plugin would only read from the current databases, not write, dr mckay's plugin would still do all that work.

Dr McKay's Player Analytics plugin


If necessary I can provide a sample database as well. Game specifically I'm looking for is CS:GO, but can be for any I'm sure

Last edited by sneaK; 01-18-2017 at 16:35. Reason: marked solved
sneaK is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 09-11-2016 , 06:11   Re: Time Played plugin based off Dr. McKay's Player Analytics
Reply With Quote #2

I bet I can do that. Gimme a few houres, no PC acces right now.
__________________
Want to check my plugins ?
Arkarr is offline
sneaK
SourceMod Moderator
Join Date: Feb 2015
Location: USA
Old 09-11-2016 , 17:09   Re: Time Played plugin based off Dr. McKay's Player Analytics
Reply With Quote #3

Quote:
Originally Posted by Arkarr View Post
I bet I can do that. Gimme a few houres, no PC acces right now.
Thanks, that'd be great!
sneaK is offline
OSWO
Senior Member
Join Date: Jul 2015
Location: United Kingdom, London
Old 09-11-2016 , 17:59   Re: Time Played plugin based off Dr. McKay's Player Analytics
Reply With Quote #4

Mind providing the column name of time played? Or how is it arranged? Does every new connection from the player create a new entry, or does it keep updating as steamID is the primary key?

Mind running this query through phpmyadmin?

"SELECT * FROM `table_name` WHERE auth = 'your authid'";
__________________
SourceTimer | WeaponSkins++ | BasePlugins++ https://github.com/OSCAR-WOS

Last edited by OSWO; 09-11-2016 at 18:01.
OSWO is offline
sneaK
SourceMod Moderator
Join Date: Feb 2015
Location: USA
Old 09-11-2016 , 19:12   Re: Time Played plugin based off Dr. McKay's Player Analytics
Reply With Quote #5

Here is a partial screenshot of the database (with personal info blocked, of course):



Every new connection from the player creates a new entry, the primary key is ID. I did a sample export of a couple rows in my player analytics database, here's the pastebin: http://pastebin.com/5BqU1RH0

I guess the plugin would need to find all entries for the player's auth and add the duration together, and spit it out in a legible format.

Last edited by sneaK; 09-11-2016 at 19:22.
sneaK is offline
OSWO
Senior Member
Join Date: Jul 2015
Location: United Kingdom, London
Old 09-11-2016 , 20:35   Re: Time Played plugin based off Dr. McKay's Player Analytics
Reply With Quote #6

"SELECT SUM(duration) AS total FROM `table_name` WHERE auth = '%s'", yourauthid);

Hook that into a TQuery on when the command is run, then format the seconds.

PHP Code:
if (SQL_FetchRow(hndl)) {
    
int I_MonthsI_WeeksI_DaysI_HoursI_MinutesI_Seconds;
    
I_Seconds SQL_FetchInt(hndl0);

    
//Formating Seconds > Months ... etc

    //Months
    
if (I_Seconds >= 2628000) {
        
I_Months RoundToFloor(I_Seconds 2628000.0);
        
I_Seconds I_Seconds 2628000;
    }

    
//Weeks
    
if (I_Seconds >= 604800) {
        
I_Weeks RoundToFloor(I_Seconds 604800.0);
        
I_Seconds I_Seconds 604800;
    }

    
//Days
    
if (I_Seconds >= 86400) {
        
I_Days RoundToFloor(I_Seconds 86400.0);
        
I_Seconds I_Seconds 86400;
    }

    
//Hours
    
if (I_Seconds >= 3600) {
        
I_Hours RoundToFloor(I_Seconds 3600.0);
        
I_Seconds I_Seconds 3600;
    }

    
//Minutes
    
if (I_Seconds >= 60) {
        
I_Minutes RoundToFloor(I_Seconds 60.0);
        
I_Seconds I_Seconds 60;
    }

Messy code but I think you know what to do.
__________________
SourceTimer | WeaponSkins++ | BasePlugins++ https://github.com/OSCAR-WOS
OSWO is offline
sneaK
SourceMod Moderator
Join Date: Feb 2015
Location: USA
Old 09-13-2016 , 12:09   Re: Time Played plugin based off Dr. McKay's Player Analytics
Reply With Quote #7

Quote:
Originally Posted by OSWO View Post
"SELECT SUM(duration) AS total FROM `table_name` WHERE auth = '%s'", yourauthid);

Hook that into a TQuery on when the command is run, then format the seconds.
Interesting, anyone able to do this?
sneaK is offline
AeroAcrobat
AlliedModders Donor
Join Date: Apr 2011
Location: lives in a circus
Old 10-14-2016 , 11:54   Re: Time Played plugin based off Dr. McKay's Player Analytics
Reply With Quote #8

Any news on this?
__________________
AeroAcrobat is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 10-14-2016 , 13:37   Re: Time Played plugin based off Dr. McKay's Player Analytics
Reply With Quote #9

Oh wow... haha... I guess I forgot this thread. I'll see what I can do.
__________________
Want to check my plugins ?

Last edited by Arkarr; 10-14-2016 at 13:38.
Arkarr is offline
Deathknife
Senior Member
Join Date: Aug 2014
Old 10-14-2016 , 15:22   Re: Time Played plugin based off Dr. McKay's Player Analytics
Reply With Quote #10

Try this. Uses mysql config 'timeplayed'

EDIT:
You might want to use the following: https://forums.alliedmods.net/showpo...6&postcount=17
Won't show invalid command in console anymore https://forums.alliedmods.net/showpo...1&postcount=18
Attached Files
File Type: zip timeplayed.zip (16.7 KB, 65 views)
File Type: sp Get Plugin or Get Source (timeplayed.sp - 118 views - 6.5 KB)
__________________

Last edited by Deathknife; 10-14-2016 at 20:09.
Deathknife 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:26.


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