Skip to content

Commit ea50010

Browse files
authored
Merge pull request #66 from Disinterpreter/amx-network-natives
added some NetStat functions
2 parents 95402ef + a45da53 commit ea50010

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
@@ -955,11 +955,13 @@ function SetSpawnInfo(amx, player, team, skin, x, y, z, angle, weap1, weap1_ammo
955955
end
956956

957957
function NetStats_BytesReceived(amx, player)
958-
notImplemented('NetStats_BytesReceived')
958+
local networkStat = getNetworkStats(player)
959+
return networkStat.bytesReceived or 0
959960
end
960961

961962
function NetStats_BytesSent(amx, player)
962-
notImplemented('NetStats_BytesSent')
963+
local networkStat = getNetworkStats(player)
964+
return networkStat.bytesSent or 0
963965
end
964966

965967
function NetStats_ConnectionStatus(amx, player)
@@ -970,8 +972,12 @@ function NetStats_GetConnectedTime(amx, player)
970972
notImplemented('NetStats_GetConnectedTime')
971973
end
972974

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

977983
function NetStats_MessagesReceived(amx, player)
@@ -987,5 +993,6 @@ function NetStats_MessagesSent(amx, player)
987993
end
988994

989995
function NetStats_PacketLossPercent(amx, player)
990-
notImplemented('NetStats_PacketLossPercent')
996+
local networkStat = getNetworkStats(player)
997+
return networkStat.packetlossTotal or 0
991998
end

0 commit comments

Comments
 (0)