How does one go about doing this in LUA.

I’ve looked through multiple sources and none of them seem to make sense to me. Can someone please clarify for me?

1 Like

https://runtime.fivem.net/doc/reference.html#_0x7302dbcf

0 identifier is the one you want steam id (steam:XXXXXXXXXXXXXXX)

I try that and I get this for some reason.

I use PlayerId() as the input for this function and call it through an event in a client script. Any idea?

You need to pass players server id and not local id. Also, that native is supposed to be executed on server-side. Get the identifier in your server script and pass it with this event that you are calling.

It’s returning the same type of value.

I’m passing in GetPlayerServerId(PlayerId()) and the function in the server script is GetPlayerIdentifiers(varfromclient)

function PlayerIdentifier(type, id)
    local identifiers = {}
    local numIdentifiers = GetNumPlayerIdentifiers(id)

    for a = 0, numIdentifiers do
        table.insert(identifiers, GetPlayerIdentifier(id, a))
    end

    for b = 1, #identifiers do
        if string.find(identifiers[b], type, 1) then
            return identifiers[b]
        end
    end
    return false
end

TRIGGER IT LIKE THIS

local identifier = PlayerIdentifier('steam', players_server_id)

NOTE YOU ARE TRIGGERING CLIENT EVENTS. YOU CAN ONLY GET THE IDENTIFIER ON THE SERVER.

2 Likes

I finally got it to work thanks to the help of @xander1998! Thank you man!

1 Like

how to convert this code to a list under hex? I have been working in different ways and I can not grasp it …
Please help
@xander1998

 -- Add our players to the list :)
    for _,i in ipairs(pTable) do

        PushScaleformMovieFunction(scaleform, "ADD_SLOT")

        PushScaleformMovieFunctionParameterInt(i+1) -- index
        PushScaleformMovieFunctionParameterInt(1) -- menuId

        PushScaleformMovieFunctionParameterInt(i) -- uniqueID
        PushScaleformMovieFunctionParameterInt(2) -- type
        PushScaleformMovieFunctionParameterInt(0) -- initialIndex
        PushScaleformMovieFunctionParameterInt(0) -- isSelectable

        local name = GetPlayerName(i)
        local id = GetPlayerServerId(i)
        --Citizen.Trace("Name(" .. i .. "): " .. GetPlayerName(i))
        -- If for some reason, their name is invalid..
        if name == "**Invalid**" then
            name = "Player_" .. i
            id = i
        end

        PushScaleformMovieFunctionParameterString(name) -- leftText

        PushScaleformMovieFunctionParameterInt(0) -- r* icon
        PushScaleformMovieFunctionParameterInt(0) -- missionIcon

        PushScaleformMovieFunctionParameterString( id ) -- rightText

        -- Since we set "type" to 2, we need to pass the colour of the text as well..
        PushScaleformMovieFunctionParameterInt(getColourForName(name))

        PushScaleformMovieFunctionParameterBool(false) -- Not actually set
        PushScaleformMovieFunctionParameterBool(false) -- Not actually set

        PushScaleformMovieFunctionParameterBool(true) -- Border


        PopScaleformMovieFunctionVoid()
    end
end


how should i fix it

The overlords prefer that you create new threads instead of bumping topics that are years old. This one will likely get locked because of your bump and you won’t be able to receive continued assistance.

As for your issue, try using GetPlayerIdentifiers to retrieve the identifiers.

https://docs.fivem.net/docs/scripting-reference/runtimes/lua/functions/GetPlayerIdentifiers/

1 Like