|
How can one check the connectivity of the player? Like Mad Paintball 2 and etc. It checks to see if you're fast enough to play and not lag out. How would I be able to do that and then if they are not fast enough, then kick them? |
|
LaedereJoin Date: 2013-06-17 Post Count: 23630 |
with a remote function and tick
|
|
|
Can I see how this is done? |
|
SoybeenJoin Date: 2010-02-17 Post Count: 21462 |
If there's an official way, I don't know about it. Maybe you could leverage the Stats service somehow:
http://wiki.roblox.com/index.php?title=API:Class/Stats
Alternatively you could ping them with a RemoteFunction and print how long it takes to come back
Put the RemoteFunciton in the ReplicatedStorage and call it PingTest, then when they join, run it a few times and average it.
local rep = game:GetService("ReplicatedStorage")
game.Players.PlayerAdded:connect(function(player)
local checks = 20
local total = 0
for i = 1,checks do
local start = tick()
result = rep.Events.PingTest:InvokeClient(player)
local stop = tick()
total = total + (stop-start)
wait()
end
total = total/checks -- this will be your ping in seconds.
end) |
|
|
Is there anything I need on the event side? cause I'm gonna put this client side. |
|
|
I can't seem to get that script to work either. |
|
|
|
SoybeenJoin Date: 2010-02-17 Post Count: 21462 |
This goes server side. You are invoking the client.
Put a Folder in the ReplicatedStorage named Events, and put your RemoteFunction named PingTest in that.
On the client, you will say
local rep = game:GetService("ReplicatedStorage")
function rep.Events.PingTest.OnClientInvoke()
return
end |
|
|
Ok so I got it to work. Now how do I tell if it's a bad connection? |
|
SoybeenJoin Date: 2010-02-17 Post Count: 21462 |
total = total/checks -- this will be your ping in seconds.
This is in seconds.
So, now you tell me, how is Ping measured? |
|
|
Welp. My average is about 0.000andthenabunchofnumbers. So I'm gonna assume that a bad ping would be like 3-5 seconds? |
|
200EthanJoin Date: 2013-04-01 Post Count: 302 |
I would make it a high-ish number, because I got pretty angry when I couldn't play Mad Paintball 2 because my WiFi sucked at the time. |
|
|
Make sure you're not testing the latency in studio, the server and client are one and therefore will have inaccurately low results
|
|