i was wondering if you can make a script that shows how much time a player has on the server for expample 25hours. if someone could help me with this i would really appreciate it. as i only have a tiny experience of lua scripting.
hi, In your “user” table, in your database you can put this, If it can help you a little:
First connection day and the last connection on the server
sorry for my english
thanky you im using essentialmode 2.0 can you please
give me a few steps how to add it ?
You just have to put that in your database, no need for script
“Name”: created_at “Datatype”:DATETIME "Default:"CURRENT_TIMESTAMP
“Name”: last_seen_at “Datatype”:DATETIME "Default:"CURRENT_TIMESTAMP+ON UPDATE CURRENT_TIMESTAMP
thanks it works but i mean like it intervals every 1 min and the timer only goes on while user is online so it shows how many hours you have been on the server in total
–[[
AUTHOR : ElNelyo
Permet de définir la dernière date de connexion dun joueur
Register the last connexion from a player (date format)
–ALTER TABLE users
ADD lastconnexion
DATETIME NULL DEFAULT NULL;
]]–
–es_extended \ client \ main.lua
RegisterNetEvent(‘esx:playerLoaded’)
AddEventHandler(‘esx:playerLoaded’, function(xPlayer)
TriggerServerEvent(“esx:updateConnexion”)
end)
–es_extended\server\main.lua
RegisterServerEvent(‘esx:updateConnexion’)
AddEventHandler(‘esx:updateConnexion’, function()
local xPlayer = ESX.GetPlayerFromId(source)
local ostime = os.date(’%c’, os.time())
print("Lastconnexion - updated “…ostime…” on "…xPlayer.identifier)
MySQL.Async.execute(
‘UPDATE users SET lastconnexion = NOW() WHERE identifier = @identifier’,
{
[’@identifier’] = xPlayer.identifier,
},
function()
end
)
end)
maybe it helps. ESX-snippet