This repository has been archived by the owner on Nov 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TimePlayed.py
42 lines (38 loc) · 1.48 KB
/
TimePlayed.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
__author__ = 'Corrosion X'
__name__ = 'TimePlayed'
__version__ = '0.2'
import clr
import sys
clr.AddReferenceByPartialName("Pluton", "UnityEngine")
import UnityEngine
import Pluton
from System import String
import datetime
class TimePlayed:
def On_PluginInit(self):
Commands.Register("timeonline")\
.setCallback("timeonline")\
.setDescription("Gives your time online stats.")\
.setUsage("/timeonline")
def On_PlayerDisconnected(self, player):
playerid = player.GameID
getstamp = Plugin.GetTimestamp()
DataStore.Add("LastConnected", playerid, getstamp)
timedsession = player.TimeOnline
totaltime = DataStore.Get("TotalTimePlayed", playerid)
if totaltime is None:
totaltime = 0
totaltime += timedsession
DataStore.Add("TotalTimePlayed", playerid, totaltime)
def timeonline(self, unused, player):
playerid = player.GameID
##getstamp = Plugin.GetTimestamp()
timeplayed = DataStore.Get("LastConnected", playerid)
totaltime = DataStore.Get("TotalTimePlayed", playerid)
timeplayed = datetime.datetime.fromtimestamp(timeplayed).strftime('%Y-%m-%d %H:%M:%S')
if timeplayed and totaltime is not None:
player.Message("Last Played:" + str(timeplayed))
player.Message("Total Time Played:" + str(totaltime))
else:
player.Message("Your time hasn't been recorded yet.")
##player.Message(getstamp)