Jump to content

Recommended Posts

Hello!

 

I am trying to fetch the steam ids of connected players using a mod. It works fine on a listen server hosted from my PC, but it does not work on a dedicated server, where I get empty strings are results.

 

Here is the relevant code: 

 

local function SteamID()  local clients = GLOBAL.TheNet:GetClientTable()  for i,j in pairs(clients) do    if (j and j["playerage"] > 0) then    clientsno = clientsno + 1    print(j["steamid"])  endendAddSimPostInit(function()  periodic = scheduler:ExecutePeriodic(15, SteamID) end)

What am I doing wrong?

 

Thanks for any hints!

 

  • Developer

This is on our end, due to an assumption that GetClientTable would only be used for FE, which did not matter on dedicated servers.

For the next update, I'll change it to include all available data even on dedicated servers.

 

One thing to note is that in many cases, you would want to exclude or filter out the dedicated host (because the dedicated host shares ID's with the account that generated the server token).

 

Here is an example:

-- Return a listing of currently active playersfunction c_listplayers()    local isdedicated = TheNet:GetServerIsDedicated()    local index = 1    for i, v in ipairs(TheNet:GetClientTable()) do        if not isdedicated or v.performance == nil then            print(string.format("%s[%d] %s <%s>", v.admin and "*" or " ", index, v.name, v.prefab))            index = index + 1        end    endend

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...