RedM Natives

GET_PLAYER_TIME_ONLINE

Gets the current time online for a specified player.

Hash0x67D2E605
Runtime nameGetPlayerTimeOnline
NamespaceCFX
SideServer
NameOfficial
Docs

Signature

int GET_PLAYER_TIME_ONLINE(char* playerSrc);

Parameters

NameTypeDescription
playerSrcchar*

A player.

Returns int — The current time online in seconds.

Description

Cfx.re native reference

Gets the current time online for a specified player.

Usage

Lua
local retval = GetPlayerTimeOnline(playerSrc)

-- always works, by hash
local retval = Citizen.InvokeNative(0x67d2e605, playerSrc, Citizen.ResultAsInteger())
JavaScript and C#
JavaScript
const retval = GetPlayerTimeOnline(playerSrc);

// by hash
const retval = Citizen.invokeNative('0x67d2e605', playerSrc, Citizen.returnResultAnyway(), Citizen.resultAsInteger());
C#
int retval = Function.Call<int>((Hash)0x67d2e605, playerSrc);

Examples

LUA · Cfx.re native reference
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

Cfx.re native reference

Something wrong or missing? Contribute a verified note — corrections ship through pull requests.