Skip to content

Commit a45da53

Browse files
added some NetStat functions
1 parent d58ebc5 commit a45da53

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

amx/server/natives/a_samp.lua

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -953,11 +953,13 @@ function SetSpawnInfo(amx, player, team, skin, x, y, z, angle, weap1, weap1_ammo
953953
end
954954

955955
function NetStats_BytesReceived(amx, player)
956-
notImplemented('NetStats_BytesReceived')
956+
local networkStat = getNetworkStats(player)
957+
return networkStat.bytesReceived or 0
957958
end
958959

959960
function NetStats_BytesSent(amx, player)
960-
notImplemented('NetStats_BytesSent')
961+
local networkStat = getNetworkStats(player)
962+
return networkStat.bytesSent or 0
961963
end
962964

963965
function NetStats_ConnectionStatus(amx, player)
@@ -968,8 +970,12 @@ function NetStats_GetConnectedTime(amx, player)
968970
notImplemented('NetStats_GetConnectedTime')
969971
end
970972

971-
function NetStats_GetIpPort(amx, player)
972-
notImplemented('NetStats_GetIpPort')
973+
function NetStats_GetIpPort(amx, player, ip_port, ip_port_len)
974+
local ip = getPlayerIP(player)
975+
local port = 0 -- We haven't a solution for getting a client port
976+
local ipandport = tostring(ip).. ":".. tostring(port)
977+
writeMemString(amx, ip_port, ipandport)
978+
return string.len(tostring(ip).. ":".. tostring(port));
973979
end
974980

975981
function NetStats_MessagesReceived(amx, player)
@@ -985,5 +991,6 @@ function NetStats_MessagesSent(amx, player)
985991
end
986992

987993
function NetStats_PacketLossPercent(amx, player)
988-
notImplemented('NetStats_PacketLossPercent')
994+
local networkStat = getNetworkStats(player)
995+
return networkStat.packetlossTotal or 0
989996
end

0 commit comments

Comments
 (0)