GET_PLAYER_TIME_ONLINE
Gets the current time online for a specified player.
Signature
int GET_PLAYER_TIME_ONLINE(char* playerSrc);Parameters
| Name | Type | Description |
|---|---|---|
playerSrc | char* | A player. |
Returns int — The current time online in seconds.
Description
Gets the current time online for a specified player.
Usage
local retval = GetPlayerTimeOnline(playerSrc)
-- always works, by hash
local retval = Citizen.InvokeNative(0x67d2e605, playerSrc, Citizen.ResultAsInteger())JavaScript and C#
const retval = GetPlayerTimeOnline(playerSrc);
// by hash
const retval = Citizen.invokeNative('0x67d2e605', playerSrc, Citizen.returnResultAnyway(), Citizen.resultAsInteger());int retval = Function.Call<int>((Hash)0x67d2e605, playerSrc);Examples
local function ShowTimeOnline()
local player = source
local secondsTotalOnline = GetPlayerTimeOnline(player)
print(("Time online : %f H %f min %f"):format(
(secondsTotalOnline / 3600),
((secondsTotalOnline / 60) % 60),
(secondsTotalOnline % 60)
))
end
RegisterNetEvent("myTimeOnline", ShowTimeOnline)Sources
Something wrong or missing? Contribute a verified note — corrections ship through pull requests.