Skip to content
TheChatArchiveThe Chat Archive
gpt-4-0314· OpenAIAi2 WildChat-4.8M (AI2)

fivem lua if NetworkIsPlayerActive(serverID) then is a client native trying to get find…

  1. User

    fivem lua if NetworkIsPlayerActive(serverID) then is a client native trying to get find the equivalent which is server side

  2. Assistant

    There is no direct equivalent to NetworkIsPlayerActive server-side in FiveM's Lua scripting. However, you can perform a similar check by using the GetPlayerPing native function. Here's how you can do that:

    -- server-side script
    
    local serverID = 1 -- change this to the player server ID you're trying to check
    
    if GetPlayerPing(serverID) ~= -1 then
        print("Player with server ID "..serverID.." is active.")
    else
        print("Player with server ID "..serverID.." is not active.")
    end
    

    GetPlayerPing returns -1 if the player is not active or not connected to the server. If the player is active, it returns the player's ping value, which will be a non-negative number.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.