Forum

> > CS2D > Scripts > Record ping and save
Forums overviewCS2D overview Scripts overviewLog in to reply

English Record ping and save

2 replies
To the start Previous 1 Next To the start

old Record ping and save

olieo
User Off Offline

Quote
Is there any way to record all players ping and save it into a file?

Something like saving the ping of every player existing every minute and average out all the players ping into one number.

I have two servers and would like to compare average pings of players.

old Re: Record ping and save

Rainoth
Moderator Off Offline

Quote
1
2
3
4
5
6
-- Create a save file (use forum search function or wait somebody else to post it for you)
-- Loop everyone in server
for k,v in pairs (player(0,"table")) do
	local PingOfPlayer = player(v,"ping")
	-- Place the writing to file here
end

Do the same with the other server too.

old Re: Record ping and save

olieo
User Off Offline

Quote
@user Rainoth: That's perfect thank you

EDIT: Does latency mean ping? right now i'm getting back around 54 average ping for just me on the server but it stays around 30 latency...

Here's the script i ended up with:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
savestrp = {}
addhook("minute","pingpong")
function pingpong(id)
	for id = 1,32 do
	local pingofplayer = player(id,"ping")
	ping = readfile("sys/lua/autorun/ping/totalping.txt", 1)-1+1
		if ping > 0 then
		pingofplayer = pingofplayer + ping / 2
		sping = io.open("sys/lua/autorun/ping/totalping.txt", "w")
		sping:write(""..pingofplayer.."")
		sping:close()
		return 1
		end
	return 1
	end
end

function readfile(filelocation, linenum) 
saveline=1
for line in io.lines(filelocation) do 
savestr[saveline]=line
saveline=saveline+1
end
return savestr[linenum]
end
edited 1×, last 19.05.15 05:41:56 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview