{"hash":"0x344EA166","ns":"CFX","name":"GET_PLAYER_FROM_SERVER_ID","slug":"GET_PLAYER_FROM_SERVER_ID","official":true,"named":true,"luaName":"GetPlayerFromServerId","game":"cfx","apiset":"client","returnType":"Player","params":[{"name":"serverId","type":"int","description":"The player's server ID."}],"returnsDescription":"A valid Player ID if one is found, `-1` if not.","summary":"Gets a local client's Player ID from its server ID counterpart, assuming the passed serverId exists on the client.","descriptions":[{"source":"cfx","format":"md","body":"Gets a local client's Player ID from its server ID counterpart, assuming the passed `serverId` exists on the client.\n\nIf no matching client is found, or an invalid value is passed over as the `serverId` native's parameter, the native result will be `-1`.\n\nIt's worth noting that this native method can only retrieve information about clients that are culled to the connected client."}],"examples":[{"lang":"lua","code":"--We will assume the serverId is '4' in this scenario and that it's a valid serverId.\n\n-- Passing invalid Player IDs such as 'nil' or IDs that don't exist will result in playerId being -1.\n\nlocal playerId = GetPlayerFromServerId(serverId);\n\n-- If the resulting playerId is not invalid (not equal to -1)\nif playerId ~= -1 then\n    -- Do our stuff on this player.\nend\n","source":"cfx"}],"aliases":[],"enums":[],"related":[],"sources":["cfx"],"doc":3,"url":"https://natives.borderlinerp.com/natives/CFX/GET_PLAYER_FROM_SERVER_ID","markdownUrl":"https://natives.borderlinerp.com/natives/CFX/GET_PLAYER_FROM_SERVER_ID.md","snippets":{"lua":"local retval = GetPlayerFromServerId(serverId)","luaInvoke":"local retval = Citizen.InvokeNative(0x344ea166, serverId, Citizen.ResultAsInteger())","js":"const retval = GetPlayerFromServerId(serverId);","jsInvoke":"const retval = Citizen.invokeNative('0x344ea166', serverId, Citizen.returnResultAnyway(), Citizen.resultAsInteger());","csharp":"int retval = Function.Call<int>((Hash)0x344ea166, serverId);","notes":[]}}