{"hash":"0x9A928294","ns":"CFX","name":"GET_PLAYER_PEER_STATISTICS","slug":"GET_PLAYER_PEER_STATISTICS","official":true,"named":true,"luaName":"GetPlayerPeerStatistics","game":"cfx","apiset":"server","returnType":"int","params":[{"name":"playerSrc","type":"char*","description":"The player to get the stats of"},{"name":"peerStatistic","type":"int","description":"The statistic to get, this will error if its out of range"}],"returnsDescription":"See `ENetStatisticType` for what this will return.","summary":"const int ENET_PACKET_LOSS_SCALE = 65536; These statistics only update once every 10 seconds.","descriptions":[{"source":"cfx","format":"md","body":"```cpp\nconst int ENET_PACKET_LOSS_SCALE = 65536;\n\nenum PeerStatistics\n{\n\t// PacketLoss will only update once every 10 seconds, use PacketLossEpoch if you want the time\n\t// since the last time the packet loss was updated.\n\n\t// the amount of packet loss the player has, needs to be scaled with PACKET_LOSS_SCALE\n\tPacketLoss = 0,\n\t// The variance in the packet loss\n\tPacketLossVariance = 1,\n\t// The time since the last packet update in ms, relative to the peers connection time\n\tPacketLossEpoch = 2,\n\t// The mean amount of time it takes for a packet to get to the client (ping)\n\tRoundTripTime = 3,\n\t// The variance in the round trip time\n\tRoundTripTimeVariance = 4,\n\t// Despite their name, these are only updated once every 5 seconds, you can get the last time this was updated with PacketThrottleEpoch\n\t// The last recorded round trip time of a packet\n\tLastRoundTripTime = 5,\n\t// The last round trip time variance\n\tLastRoundTripTimeVariance = 6,\n\t// The time since the last packet throttle update, relative to the peers connection time\n\tPacketThrottleEpoch = 7,\n};\n```\n\nThese statistics only update once every 10 seconds."}],"examples":[{"lang":"js","code":"\nsetInterval(() => {\n\tconst ENET_PACKET_LOSS_SCALE = 65536;\n\n\tconst PLAYER_SERVER_ID = 1;\n\n\tconst packetLoss = GetPlayerPeerStatistics(PLAYER_SERVER_ID, 0 /* PacketLoss */);\n\tconst packetLossVariance = GetPlayerPeerStatistics(PLAYER_SERVER_ID, 1 /* PacketLossVariance */);\n\tconst packetLossEpoch = GetPlayerPeerStatistics(PLAYER_SERVER_ID, 2 /* PacketLossEpoch */)\n\tconst rtt = GetPlayerPeerStatistics(PLAYER_SERVER_ID, 3 /* RoundTripTime */);\n\tconst rttVariance = GetPlayerPeerStatistics(PLAYER_SERVER_ID, 4 /* RoundTripTimeVariance */);\n\tconst lastRtt = GetPlayerPeerStatistics(PLAYER_SERVER_ID, 5 /* LastRoundTripTime */);\n\tconst lastRttVariance = GetPlayerPeerStatistics(PLAYER_SERVER_ID, 6 /* LastRoundTripTimeVariance */);\n\tconst packetThrottleEpoch = GetPlayerPeerStatistics(PLAYER_SERVER_ID, 7 /* PacketThrottleEpoch */);\n\n\tconsole.log(`packetLoss: ${packetLoss}`);\n\tconsole.log(`packetLossVariance: ${packetLossVariance}`);\n\tconsole.log(`packetLossEpch: ${packetLossEpoch}`);\n\n\tconsole.log(`packetLossScaled: ${packetLoss / ENET_PACKET_LOSS_SCALE}`);\n\tconsole.log(`packetLossVarianceScaled: ${packetLossVariance / ENET_PACKET_LOSS_SCALE}`);\n\n\tconsole.log(`rtt: ${rtt}`);\n\tconsole.log(`rttVariance: ${rttVariance}`);\n\n\tconsole.log(`lastRtt: ${lastRtt}`);\n\tconsole.log(`lastRttVariance: ${lastRttVariance}`);\n\tconsole.log(`packetThrottleEpoch: ${packetThrottleEpoch}`);\n}, 10000)","source":"cfx"}],"aliases":[],"enums":[],"related":[],"sources":["cfx"],"doc":3,"url":"https://natives.borderlinerp.com/natives/CFX/GET_PLAYER_PEER_STATISTICS","markdownUrl":"https://natives.borderlinerp.com/natives/CFX/GET_PLAYER_PEER_STATISTICS.md","snippets":{"lua":"local retval = GetPlayerPeerStatistics(playerSrc, peerStatistic)","luaInvoke":"local retval = Citizen.InvokeNative(0x9a928294, playerSrc, peerStatistic, Citizen.ResultAsInteger())","js":"const retval = GetPlayerPeerStatistics(playerSrc, peerStatistic);","jsInvoke":"const retval = Citizen.invokeNative('0x9a928294', playerSrc, peerStatistic, Citizen.returnResultAnyway(), Citizen.resultAsInteger());","csharp":"int retval = Function.Call<int>((Hash)0x9a928294, playerSrc, peerStatistic);","notes":[]}}