SHOW:
|
|
- or go back to the newest paste.
| 1 | print 'Admin Console 1.0 Loaded' | |
| 2 | ||
| 3 | --[[ | |
| 4 | ||
| 5 | Hio. Make sure you have the latest and greatest version of this tool. Get it at http://ironnoob.com/forums/index.php/board,26.0.html | |
| 6 | ||
| 7 | - John Shedletsky | |
| 8 | ||
| 9 | ]]-- | |
| 10 | ||
| 11 | -- Install Gui | |
| 12 | - | local copy = script.JohnsConsoleGui:Clone() |
| 12 | + | local copy = script.iSpringfield:Clone() |
| 13 | --copy.Archivable = false | |
| 14 | copy.Parent = game.StarterGui | |
| 15 | ||
| 16 | local lastPing = {} -- {player, ms}
| |
| 17 | ||
| 18 | ||
| 19 | function split(str, delimiter) | |
| 20 | local result = { }
| |
| 21 | local from = 1 | |
| 22 | local delim_from, delim_to = string.find( str, delimiter, from ) | |
| 23 | while delim_from do | |
| 24 | table.insert( result, string.sub( str, from , delim_from-1 ) ) | |
| 25 | from = delim_to + 1 | |
| 26 | delim_from, delim_to = string.find( str, delimiter, from ) | |
| 27 | end | |
| 28 | table.insert( result, string.sub( str, from ) ) | |
| 29 | return result | |
| 30 | end | |
| 31 | ||
| 32 | function getAvgPing() | |
| 33 | ||
| 34 | local p = game.Players:GetPlayers() | |
| 35 | local total = 0 | |
| 36 | ||
| 37 | for i=1,#p do | |
| 38 | if lastPing[p[i].Name] ~= nil then | |
| 39 | total = total + lastPing[p[i].Name] | |
| 40 | end | |
| 41 | end | |
| 42 | ||
| 43 | if #p == 0 then return 0 end | |
| 44 | ||
| 45 | return total / #p | |
| 46 | ||
| 47 | end | |
| 48 | ||
| 49 | function incomingMessage(msg) | |
| 50 | if string.sub(msg.Name, 1, 4) == "ping" then | |
| 51 | print("SERV MSG: " .. msg.Value)
| |
| 52 | local args = split(msg.Value, ",") | |
| 53 | ||
| 54 | print("player: " .. args[1] .. "ping: " .. args[2])
| |
| 55 | lastPing[args[1]] = args[2] | |
| 56 | ||
| 57 | local result = getAvgPing() | |
| 58 | print("avg ping: " .. result)
| |
| 59 | msg.Value = "." .. result | |
| 60 | end | |
| 61 | end | |
| 62 | ||
| 63 | script.ChildAdded:connect(incomingMessage) |