GetPlayerIdentifiers - only license and NO Steam ID?

Hi,

I am rewriting ESX so it can work without Steam. Only with FiveM licenses. I had no problem to create new character, save it into DB, buy a car, take it out from the garage. Everything works so far as it should.

But.

My friend connected with Steam running in the background and suddenly, few errors showed up in server console. I’ve tracked down the problem to GetPlayerIdentifiers() native (and hold on, I’ve find out only singular “GetPlayerIdentifier” in natives for FiveM, so is the plural “GetPlayerIdentifiers()” some ESX thing?

Again, I am sorry for these expressions, but English is my second language and I don’t have previous programmer background.

Any thoughts? Ideas how to tell the client to pass only FiveM license?

Thank you for any reply!

1 Like

No, the plural isn’t documented anywhere, AFAIK, because it’s not a native. It simply returns all GetPlayerIdentifier()s as elements in an array.

So how come you are taking on the responsibility of making changes to a very popular framework? Doesn’t make any sense at all.

To get a specific identifier, just iterate through GetPlayerIdentifiers(). Like so:

for k, v in ipairs(GetPlayerIdentifiers(--[[string: playerSrc]])) do
   if string.match(v, "license:") then
      license = v
      break
   end
end

Ok, thank you. I will try what it gives first, when it’s singular. Should be license… That would be easy fix then

GetPlayerIdentifier() – if you read the documentation for it – requires a param to specify which identifer you want.

1 Like

Well, it didn’t really work, @zee. I am getting errors and not sure what am I doing wrong here. I am probably tired already… Could you help me with this, please?

AddEventHandler('chatMessage', function(s, n, m)
local license = nil
local _source = source
	local message = string.lower(m)
	local license = GetPlayerIdentifier(_source, 2)
	if message == "/test" then
		
		print(license)
		
	end
end)

Gives me nil no matter what…

Why are you listening for chatMessage for commands? Use RegisterCommand(). chatMessage has been deprecated for a long time.

Another thing, the reasoning behind iterating through GetPlayerIdentifiers() was that the index is not static and can change between players. So you need to iterate to find a specific part of the string (identifier), and then use that identifier.

RegisterCommand("test", function(source, args, raw)
   local license
   for k, v in ipairs(GetPlayerIdentifiers(source)) do
      if string.match(v, "license:") then
         license = v
         break
      end
   end
   print(license)
end, false)
4 Likes

Thank you, this helped!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.