This script show up player ingame playtime. You can setup in this script translate and also you can define how that command will be called.
In default are these commands
“/playtime” (for players) - It show up player playtime of himself
“/playtime acc ID” (for admins) - It show up player playtime
“/playtime char” (for players) - It show up player playtime on his character
“/playtime char ID” (for admins) - It show up player playtime on his character
Config = {}
Config.Framework = 'esx' -- qb-core/esx | Don't touch this. Change it only if you have renamed qb or you use ESX
Config.Debug = false --Command for me to debug script. It print to console passes trough conditions. true/false
Config.Language = 'en' --Language: 'en' or 'cs'
Config.ThreadIncrease = 1 --This value mean how often is playtime increased 1 = 1min, default 5 = 5min, that means every 5 minutes will be added 5 minutes to playtime
Config.Command = 'playtime' -- Command which will display playtime
-- ---------------
-- VVV PLAYERS VVV
-- ---------------
-- Usage: '/playtime char' It shows playtime of the player's character
-- Usage: '/playtime acc' It shows playtime of the player's account
Config.Permissions = {
'admin',
'god',
}
-- -------------
-- VVV ADMIN VVV
-- -------------
-- Usage: '/playtime char ID' for example '/playtime char 1' will display playtime of Player with ID 1 on his character
-- Usage: '/playtime acc ID' for example '/playtime acc 1' will display playtime of Player with ID 1 on his account
Config.VersionCheck = true
if Config.Language == 'en' then
Translations = {
notifications = {
playtime = "You've played ",
wrongid = "Wrong ID or Player isn't online",
playtimeplayer = " has played ",
acc = " (Account)",
char = " (Character)",
},
time = {
days = "days",
hours = "hours",
minutes = "minutes",
},
utils = {
descriptions = "Displays player's playtime",
IDPlayer = "Player ID (Admin Only)",
Char_Acc = "Player's playtime on character (char) / playtime on account (acc)"
},
}
end
local function NotifySystem(src, text, typ)
if ESX then
-- ESX
local xPlayer = ESX.GetPlayerFromId(src)
if not xPlayer then return end
xPlayer.showNotification(text)
else
-- QB-Core
TriggerClientEvent('QBCore:Notify', src, text, typ)
end
end
function Notify(event, src, data)
if event == 'WrongID' then
NotifySystem(src, Translations.notifications.wrongid, 'error')
elseif event == 'AccountAdminCommand' then
NotifySystem(src, 'ID: ' .. data.ID .. Translations.notifications.playtimeplayer .. data.playtime .. Translations.notifications.acc, 'success')
elseif event == 'AccountPlayerCommand' then
NotifySystem(src, Translations.notifications.playtime .. data.playtime .. Translations.notifications.acc, 'success')
elseif event == 'PlayerAdminCommand' then
NotifySystem(src, 'ID: ' .. data.ID .. Translations.notifications.playtimeplayer .. data.playtime .. Translations.notifications.char, 'success')
elseif event == 'PlayerCommand' then
NotifySystem(src, Translations.notifications.playtime .. data.playtime .. Translations.notifications.char, 'success')
end
end